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

:root {
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;
  --border: rgba(226, 232, 240, 0.85);
  --border-light: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --accent: #007AFF;
  --accent-hover: #1390ff;
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.1);
  --red: #FF2D55;
  --red-dim: rgba(255, 45, 85, 0.1);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --cyan: #0ea5e9;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --pane-split: 55%;
  /* Semantic tokens for theme-dependent values */
  --bubble-bg: #ffffff;
  --bubble-border: #f1f5f9;
  --bubble-shadow: 0px 1px 2px rgba(0, 0, 0, 0.06);
  --code-color: var(--code-color);
  --input-bg: #ffffff;
  --presence-bg: rgba(255, 255, 255, 0.95);
  --presence-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --preview-bg: #ffffff;
  --logo-filter: none;
  --fade-gradient: white;
  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --sidebar-bg: #f8fafc;
  --sidebar-border: rgba(226, 232, 240, 0.85);
  --sidebar-hover: rgba(0, 0, 0, 0.04);
  --sidebar-active: rgba(0, 122, 255, 0.08);
  --sidebar-active-text: var(--accent);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #21242f;
  --surface3: #282c39;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --accent: #4da6ff;
  --accent-hover: #6db8ff;
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.1);
  --red: #ff6b8a;
  --red-dim: rgba(255, 107, 138, 0.1);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.1);
  --cyan: #38bdf8;
  --bubble-bg: #1e2130;
  --bubble-border: rgba(255, 255, 255, 0.06);
  --bubble-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
  --code-color: #fbbf24;
  --input-bg: #1a1d27;
  --presence-bg: rgba(26, 29, 39, 0.95);
  --presence-shadow: 0 2px 12px rgba(0,0,0,0.4);
  --preview-bg: #1a1d27;
  --logo-filter: brightness(1.8) saturate(1.1);
  --fade-gradient: #1e2130;
  /* Sidebar */
  --sidebar-bg: #151823;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-hover: rgba(255, 255, 255, 0.04);
  --sidebar-active: rgba(77, 166, 255, 0.1);
  --sidebar-active-text: var(--accent);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* Main content area — right of sidebar */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

/* ---- TOP BAR ---- */
.topbar {
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}

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

.topbar .logo {
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
}

.topbar .logo img { height: 22px; width: auto; filter: var(--logo-filter); }

.topbar .model-badge {
  font-size: 11px; padding: 3px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text-dim); font-family: var(--mono);
}

.persona-badge {
  font-size: 11px; padding: 3px 10px 3px 4px;
  background: var(--purple-dim); border: 1px solid var(--purple-dim);
  border-radius: 12px; color: var(--purple); font-weight: 600;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.persona-badge .persona-thumb {
  width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}

/* Photo upload in settings */
.photo-upload-area {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.photo-preview {
  width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
  background: var(--surface3); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; transition: all 0.2s;
  position: relative;
}
.photo-preview:hover { border-color: var(--purple); }
.photo-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.photo-preview .photo-placeholder {
  color: var(--text-muted); font-size: 10px; text-align: center; line-height: 1.3;
}
.photo-preview .photo-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; border-radius: 50%;
}
.photo-preview:hover .photo-overlay { opacity: 1; }
.photo-preview .photo-overlay svg { width: 18px; height: 18px; color: white; }
.photo-actions {
  display: flex; flex-direction: column; gap: 4px;
}
.photo-actions button {
  padding: 4px 10px; background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 11px;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.photo-actions button:hover { background: var(--surface2); color: var(--text); }
.photo-actions .remove-photo { border-color: rgba(255,45,85,0.3); color: var(--red); }
.photo-actions .remove-photo:hover { background: var(--red-dim); }

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

.cost-display {
  font-size: 12px; font-family: var(--mono); color: var(--green);
  background: var(--green-dim); padding: 4px 10px; border-radius: 12px; font-weight: 600;
}

.topbar-btn {
  padding: 6px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 12px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 6px;
}

.topbar-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-light); }
.topbar-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Theme toggle */
.theme-toggle { padding: 6px 8px; display: flex; align-items: center; }
.theme-toggle.hidden { display: none !important; }
.theme-toggle .theme-icon-light { display: block; }
.theme-toggle .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: block; }
.logo .logo-dark { display: none; }
[data-theme="dark"] .logo .logo-light { display: none; }
[data-theme="dark"] .logo .logo-dark { display: inline; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 10px;
  overflow: hidden;
}
.sidebar-header .logo {
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-header .logo img { height: 22px; width: auto; filter: var(--logo-filter); }
.sidebar.collapsed .sidebar-header .logo span { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-nav-item.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-nav-item svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px; }

.sidebar-section-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 12px 4px;
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-section-header { display: none; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-size: 12px;
  background: none; border: none; width: 100%; font-family: inherit;
  transition: background 0.1s;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: var(--text-dim); }
.sidebar-collapse-btn svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-collapse-btn .nav-label { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; padding: 10px; }

/* ---- PAGE CONTAINERS ---- */
.page { display: none; flex: 1; overflow: hidden; }
.page.active { display: flex; }
.page-chat { flex-direction: row; position: relative; }
.page-history { flex-direction: column; background: var(--bg); }
.page-projects { flex-direction: column; background: var(--bg); align-items: center; justify-content: center; }

/* ---- HISTORY PAGE ---- */
.history-page-body { flex: 1; overflow-y: auto; padding: 16px 24px; }

.history-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all 0.15s; margin-bottom: 8px;
}
.history-card:hover {
  border-color: var(--accent); background: var(--surface2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.history-card .hc-body { flex: 1; min-width: 0; }
.history-card .hc-prompt {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
.history-card .hc-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--text-muted);
  font-family: var(--mono); flex-wrap: wrap;
}
.history-card .hc-meta .hc-cost { color: var(--green); font-weight: 600; }
.history-empty {
  text-align: center; color: var(--text-muted); font-size: 14px;
  padding: 64px 32px;
}

/* Topbar title for non-chat pages */
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* Mobile menu button (hidden on desktop) */
.mobile-menu-btn { display: none !important; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.3); z-index: 59;
}
.sidebar-overlay.visible { display: block; }

/* ---- RESPONSIVE ---- */
@media (min-width: 769px) {
  .main-container {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
  }
  body.sidebar-collapsed .main-container {
    margin-left: var(--sidebar-collapsed);
  }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-container { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex !important; }
}

/* ---- LAYOUT ---- */

.pane-agent {
  width: var(--pane-split); display: flex; flex-direction: column;
  min-width: 300px; border-right: none;
}

.pane-output {
  flex: 1; display: flex; flex-direction: column;
  min-width: 260px; background: var(--bg);
  position: relative;
}

/* ---- RESIZER ---- */
.pane-resizer {
  width: 6px; cursor: col-resize; background: var(--border);
  position: relative; flex-shrink: 0; z-index: 5;
  transition: background 0.15s;
}

.pane-resizer:hover, .pane-resizer.dragging {
  background: var(--accent);
}

.pane-resizer::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 32px;
  background: var(--text-muted); border-radius: 1px;
  opacity: 0; transition: opacity 0.15s;
}

.pane-resizer:hover::after, .pane-resizer.dragging::after { opacity: 0.5; }

/* ---- PHASE LAYOUT ---- */
/* Dashboard: full-width, no output pane */
.phase-dashboard .pane-resizer,
.phase-dashboard .pane-output { display: none; }
.phase-dashboard .pane-agent { width: 100%; }
.phase-dashboard .chat-log {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; padding-top: 40px;
}
.phase-dashboard .input-area {
  max-width: 680px; margin: 0 auto; width: 100%;
  border-top: none; background: transparent; padding: 0 20px 24px;
}
.phase-dashboard .input-wrap textarea {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Chat: full-width, no output pane, input at bottom */
.phase-chat .pane-resizer,
.phase-chat .pane-output { display: none; }
.phase-chat .pane-agent { width: 100%; }

/* Chat+Output: split pane with slide-in animation */
.phase-chat-output .pane-agent {
  transition: width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.phase-chat-output .pane-resizer {
  animation: fadeIn 0.3s ease 0.2s both;
}
.phase-chat-output .pane-output {
  animation: slideInFromRight 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideInFromRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.pane-header {
  height: 40px; padding: 0 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: var(--surface);
  gap: 12px; min-width: 0;
}

.pane-header h3 {
  font-size: 14px; font-weight: 600;
  letter-spacing: 0; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1;
}

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

.copy-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 11px; background: none; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-dim); cursor: pointer; transition: all 0.15s;
}
.copy-btn:hover { color: var(--text); background: var(--surface2); border-color: var(--text-muted); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ---- SETTINGS DRAWER ---- */
.settings-drawer {
  position: fixed; top: 48px; right: 0; bottom: 0; width: 400px;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 50; transform: translateX(100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}

.settings-drawer.open { transform: translateX(0); }

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

.settings-drawer .drawer-header h3 { font-size: 14px; font-weight: 600; }
.settings-drawer .drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.setting-group { margin-bottom: 20px; }

.setting-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}

.setting-group select,
.setting-group input[type="number"],
.setting-group input[type="text"] {
  width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: var(--mono); outline: none; transition: border-color 0.15s;
}

.setting-group select:focus,
.setting-group input:focus { border-color: var(--accent); }
.setting-group select option { background: var(--surface); }

.setting-group textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 12px;
  font-family: var(--mono); line-height: 1.5; resize: vertical;
  min-height: 120px; outline: none; transition: border-color 0.15s;
}

.setting-group textarea:focus { border-color: var(--accent); }

.setting-group .pricing-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: var(--mono);
}

.setting-group .hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4;
}

.setting-divider {
  margin: 24px 0 20px;
  border: none; border-top: 1px solid var(--border);
}

.setting-section-title {
  font-size: 11px; font-weight: 700; color: var(--purple);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.setting-section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.tool-toggles { display: flex; flex-direction: column; gap: 6px; }

.tool-toggle {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s;
}

.tool-toggle:hover { background: var(--surface2); }
.tool-toggle input[type="checkbox"] { accent-color: var(--accent); }
.tool-toggle .tool-label { font-size: 13px; font-family: var(--mono); }
.tool-toggle .tool-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ---- CHAT LOG ---- */
.chat-log {
  flex: 1; overflow-y: auto; padding: 20px 20px 28px;
  display: flex; flex-direction: column; gap: 12px;
}

.chat-log::-webkit-scrollbar { width: 5px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- DASHBOARD ---- */
.dashboard {
  width: 100%; max-width: 680px; margin: 0 auto; padding: 0 20px 32px;
}

.dash-hero { text-align: center; margin-bottom: 32px; }

.dash-avatar {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--purple-dim); display: flex; align-items: center;
  justify-content: center; overflow: hidden;
  border: 3px solid var(--border); transition: transform 0.3s ease;
}
.dash-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dash-avatar:hover { transform: scale(1.05); }
.dash-avatar-fallback {
  font-size: 28px; font-weight: 700; color: var(--purple);
  line-height: 1; user-select: none;
}

.dash-greeting {
  font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 8px;
}
.dash-desc {
  font-size: 14px; color: var(--text-dim); max-width: 460px;
  margin: 0 auto; line-height: 1.6;
}

.dash-section { margin-top: 28px; }
.dash-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 12px;
}

/* Recent cards */
.dash-recents { display: flex; flex-direction: column; gap: 6px; }
.dash-recent-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s;
}
.dash-recent-card:hover {
  border-color: var(--accent); background: var(--surface2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.dash-recent-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--purple-dim); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  color: var(--purple); flex-shrink: 0; overflow: hidden;
}
.dash-recent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dash-recent-body { flex: 1; min-width: 0; }
.dash-recent-prompt {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-recent-meta {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
  font-family: var(--mono);
}

/* Suggestion cards */
.dash-suggestions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.dash-suggestion-card {
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s; text-align: left;
  font-family: inherit; font-size: inherit; color: inherit;
}
.dash-suggestion-card:hover {
  border-color: var(--accent); background: var(--surface2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.dash-suggestion-icon { font-size: 20px; margin-bottom: 8px; }
.dash-suggestion-title {
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px;
}
.dash-suggestion-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

@media (max-width: 768px) {
  .dash-suggestions { grid-template-columns: 1fr; }
  .dash-hero { margin-bottom: 24px; }
  .dash-avatar { width: 64px; height: 64px; }
  .dash-avatar-fallback { font-size: 22px; }
  .dash-greeting { font-size: 18px; }
}

.msg { display: flex; gap: 12px; animation: fadeIn 0.15s ease; }

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

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}

.msg-user .msg-avatar { background: var(--accent); color: white; }
.msg-assistant .msg-avatar { background: var(--purple); color: white; }
.msg-avatar.has-photo {
  background: none; padding: 0; overflow: hidden;
}
.msg-avatar.has-photo img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.msg-body { flex: 1; min-width: 0; }
.msg-sender { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.msg-content { font-size: 15px; line-height: 1.5; color: var(--text); }

/* User messages — Companio-style bubble */
.msg-user .msg-content {
  background: var(--bubble-bg);
  border: 1px solid var(--bubble-border); border-bottom-width: 2px;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: var(--bubble-shadow);
}

/* Assistant messages — same bubble style */
.msg-assistant .msg-content {
  background: var(--bubble-bg);
  border: 1px solid var(--bubble-border); border-bottom-width: 2px;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: var(--bubble-shadow);
}

.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 600; }
.msg-content code {
  background: var(--surface3); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: var(--mono); color: var(--code-color);
}
.msg-content pre {
  background: var(--surface2); padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto; margin: 8px 0; font-size: 12px; font-family: var(--mono); line-height: 1.5;
}

/* ---- TOOL CARDS (humanized) ---- */
.tool-group { padding-left: 44px; display: flex; flex-direction: column; gap: 4px; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.2s;
}

.tool-card:hover { border-color: var(--border-light); }

.tool-card-header {
  padding: 8px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  list-style: none; user-select: none;
}

.tool-card-header::-webkit-details-marker { display: none; }

.tool-card-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.tool-card-icon.file-read { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.tool-card-icon.file-write { background: var(--green-dim); color: var(--green); }
.tool-card-icon.file-edit { background: var(--amber-dim); color: var(--amber); }
.tool-card-icon.file-search { background: var(--purple-dim); color: var(--purple); }
.tool-card-icon.file-list { background: rgba(34, 211, 238, 0.12); color: var(--cyan); }

.tool-card-info { flex: 1; min-width: 0; }

.tool-card-action {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tool-card-detail {
  font-size: 11px; color: var(--text-dim); margin-top: 1px;
  font-family: var(--mono); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.tool-card-status {
  flex-shrink: 0; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}

.tool-card-spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.tool-card-check { color: var(--green); font-size: 14px; font-weight: 700; }
.tool-card-chev { color: var(--text-muted); font-size: 9px; transition: transform 0.15s; }
.tool-card[open] .tool-card-chev { transform: rotate(90deg); }

.tool-card-result {
  padding: 8px 12px; border-top: 1px solid var(--border);
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg);
}

.tool-card.pending .tool-card-icon { animation: pulseGlow 1.5s infinite; }

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

.turn-marker {
  display: flex; align-items: center; gap: 10px;
  font-size: 10px; color: var(--text-muted); padding: 2px 0;
}

.turn-marker::before, .turn-marker::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.completion-card {
  background: var(--green-dim); border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
}

.completion-card h4 { font-size: 12px; color: var(--green); margin-bottom: 10px; }

.completion-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.completion-stats .stat { font-size: 11px; }
.completion-stats .stat .label { color: var(--text-dim); display: block; margin-bottom: 1px; }
.completion-stats .stat .value { color: var(--text); font-weight: 600; font-size: 15px; font-family: var(--mono); }

.error-card {
  background: var(--red-dim); border: 1px solid rgba(255,45,85,0.2);
  border-radius: var(--radius); padding: 10px 14px; font-size: 12px; color: var(--red);
}

/* ---- MONOLOGUE (unified: thinking + writing narration) ---- */
.msg-monologue {
  animation: monoSlideIn 0.25s ease-out;
  --mono-accent: var(--purple);
}
.msg-monologue.mono-green { --mono-accent: var(--green); }
@keyframes monoSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-monologue .msg-avatar { display: none; }
.msg-monologue .msg-body { max-width: 85%; }

/* --- Sender label --- */
.msg-monologue .msg-sender {
  color: var(--mono-accent); opacity: 0.55;
  font-size: 10.5px; margin-bottom: 2px;
}
.mono-icon {
  font-size: 13px; margin-right: 3px; opacity: 0.9;
  font-style: normal; display: inline-block;
}
.mono-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  opacity: 0.6; font-weight: 500; font-style: normal;
}

/* --- Streaming bubble (active) --- */
.msg-monologue .msg-content {
  font-size: 13px; color: var(--text-dim); line-height: 1.55;
  background: color-mix(in srgb, var(--mono-accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--mono-accent) 12%, transparent);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px; box-shadow: none; position: relative;
  transition: background 0.3s, border-color 0.3s, border-radius 0.3s, padding 0.3s, opacity 0.3s;
}
.msg-monologue .msg-content p { margin: 0 0 4px 0; }
.msg-monologue .msg-content p:last-child { margin-bottom: 0; }
.msg-monologue .msg-content strong { color: var(--text); font-weight: 600; }
.msg-monologue .msg-content em { font-style: italic; opacity: 0.9; }
.msg-monologue .msg-content code {
  font-size: 11.5px; padding: 1px 5px; border-radius: 4px;
  background: color-mix(in srgb, var(--mono-accent) 10%, var(--surface));
}

/* Icon bob while streaming */
.msg-monologue:not(.finalized) .mono-icon {
  animation: monoBob 2s ease-in-out infinite;
}
@keyframes monoBob {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-2px) scale(1.12); }
  60% { transform: translateY(-1px) scale(1.06); }
}

/* Streaming — just a steady accent border, no glow */
.msg-monologue .msg-content.streaming {
  border-color: color-mix(in srgb, var(--mono-accent) 22%, transparent);
}

/* Blinking cursor that follows the text */
.msg-monologue .msg-content.streaming::after {
  content: '\25CD'; color: var(--mono-accent); opacity: 0.5;
  animation: monoCursor 0.8s ease-in-out infinite;
  font-weight: 300; font-size: 14px; margin-left: 1px;
}
@keyframes monoCursor {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.1; }
}

/* --- Finalized — bubble dissolves into nothing --- */
.msg-monologue.finalized .msg-content {
  background: transparent; border-color: transparent;
  border-radius: 0; padding: 0;
  animation: none; box-shadow: none;
}
.msg-monologue.finalized .msg-content::after { display: none; }

/* --- Collapsed — single inline trace --- */
.msg-monologue.finalized.collapsed { cursor: pointer; }
.msg-monologue.finalized.collapsed .msg-body {
  display: flex; align-items: baseline; gap: 6px;
}
.msg-monologue.finalized.collapsed .msg-sender {
  flex-shrink: 0; margin-bottom: 0;
}
.msg-monologue.finalized.collapsed .msg-content {
  opacity: 0.3; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-height: 1.6em; flex: 1; min-width: 0;
}
.msg-monologue.finalized.collapsed .msg-content p {
  display: inline; margin: 0;
}
.msg-monologue.finalized.collapsed .msg-content p + p::before {
  content: ' ';
}
.msg-monologue.finalized.collapsed:hover .msg-content { opacity: 0.5; }
.msg-monologue.finalized.collapsed:hover .mono-chevron { opacity: 0.7; }

/* Chevron affordance */
.mono-chevron {
  display: none; font-size: 10px; color: var(--text-dim);
  opacity: 0.5; transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0; user-select: none;
}
.msg-monologue.finalized.collapsed .mono-chevron { display: inline-block; }

/* --- Expanded — full text, still no bubble --- */
.msg-monologue.finalized.collapsed.expanded .msg-body { display: block; }
.msg-monologue.finalized.collapsed.expanded .msg-content {
  white-space: normal; overflow: visible; max-height: none;
  text-overflow: unset; opacity: 0.4; margin-top: 4px; font-size: 13px;
}
.msg-monologue.finalized.collapsed.expanded .msg-content p {
  display: block; margin: 0 0 4px 0;
}
.msg-monologue.finalized.collapsed.expanded .msg-content p + p::before {
  content: none;
}
.msg-monologue.finalized.collapsed.expanded .mono-chevron {
  transform: rotate(90deg);
}

/* --- Dark mode --- */
[data-theme="dark"] .msg-monologue .msg-content {
  color: #c5cdd5;
  background: color-mix(in srgb, var(--mono-accent) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--mono-accent) 15%, transparent);
}
[data-theme="dark"] .msg-monologue .msg-content strong { color: #e2e8f0; }
[data-theme="dark"] .msg-monologue .msg-sender { color: var(--mono-accent); opacity: 0.65; }
[data-theme="dark"] .msg-monologue .msg-content.streaming {
  border-color: color-mix(in srgb, var(--mono-accent) 20%, transparent);
}
[data-theme="dark"] .msg-monologue.finalized .msg-content {
  background: transparent; border-color: transparent;
}
[data-theme="dark"] .msg-monologue.finalized.collapsed .msg-content { opacity: 0.25; }

/* ---- CHAT MARKDOWN (left pane) ---- */
.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
  margin-top: 12px; margin-bottom: 6px; font-weight: 600;
}
.msg-content h1 { font-size: 18px; }
.msg-content h2 { font-size: 16px; }
.msg-content h3 { font-size: 15px; }
.msg-content h4 { font-size: 14px; }

.msg-content table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 12px; }
.msg-content th, .msg-content td {
  border: 1px solid var(--border); padding: 5px 8px; text-align: left;
}
.msg-content th { background: var(--surface); font-weight: 600; font-size: 11px; }
.msg-content tr:nth-child(even) { background: var(--surface); }

.msg-content ul, .msg-content ol { margin: 6px 0 8px 20px; }
.msg-content li { margin-bottom: 3px; }

.msg-content blockquote {
  border-left: 3px solid var(--accent); margin: 8px 0; padding: 6px 12px;
  background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim); font-size: 12px;
}

.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.msg-content a { color: var(--accent); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }

.msg-content img { max-width: 100%; border-radius: var(--radius-sm); }

/* Glowing inline typing cursor while Sarah is talking */
.streaming-cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1.5px;
  box-shadow: 0 0 6px rgba(0, 122, 255, 0.5);
  animation: chatCursorPulse 0.8s ease-in-out infinite;
}
[data-theme="dark"] .streaming-cursor {
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}
@keyframes chatCursorPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- DRAFT COLLAPSE (after file is saved) ---- */
.msg-draft-collapsed .msg-content {
  max-height: 120px;
  overflow: hidden;
  opacity: 0.6;
  position: relative;
}
.msg-draft-collapsed .msg-content::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--fade-gradient));
  pointer-events: none;
}
.msg-draft-collapsed .draft-toggle {
  display: block;
  padding: 4px 0;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}
.msg-draft-collapsed .draft-toggle:hover { text-decoration: underline; }
.msg-draft-collapsed.expanded .msg-content {
  max-height: none;
  opacity: 0.75;
}
.msg-draft-collapsed.expanded .msg-content::after { display: none; }

/* ---- WRITING NARRATION TICKER (fixed-height, zero bounce) ---- */
.narration-ticker {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
  margin: 0;
}
.narration-ticker > .narration-ticker-inner {
  overflow: hidden;
}
.narration-ticker.visible {
  grid-template-rows: 1fr;
  opacity: 1;
}
.narration-ticker-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--green);
  opacity: 0.65;
}
.narration-ticker-icon {
  flex-shrink: 0;
  font-size: 13px;
  animation: monoBob 2s ease-in-out infinite;
}
.narration-ticker-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  opacity: 0.7;
  flex-shrink: 0;
}
.narration-ticker-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-style: italic;
  color: var(--text-dim);
  transition: opacity 0.3s ease;
}
.narration-ticker-text.cross-fade {
  opacity: 0;
}
/* Finalized — collapse to trace */
.narration-ticker.finalized {
  opacity: 0.4;
  cursor: pointer;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}
.narration-ticker.finalized .narration-ticker-inner {
  max-height: 20px;
  gap: 6px;
}
.narration-ticker.finalized .narration-ticker-icon {
  animation: none;
  font-size: 11px;
}
.narration-ticker.finalized:hover {
  opacity: 0.6;
}
/* Removing — shrink to nothing */
.narration-ticker.removing {
  grid-template-rows: 0fr;
  opacity: 0;
  margin: 0;
}
[data-theme="dark"] .narration-ticker-inner {
  color: var(--green);
  opacity: 0.7;
}
[data-theme="dark"] .narration-ticker-text {
  color: #c5cdd5;
}

/* ---- LIVE FILE STREAMING ---- */
.output-source.streaming,
.output-rendered.streaming {
  position: relative;
}

.output-source.streaming::after,
.output-rendered.streaming::after {
  content: '\2588';
  animation: cursorBlink 0.5s step-end infinite;
  color: var(--green);
  font-weight: normal;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

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

/* Glow effect on the output pane while streaming */
.output-content.streaming-active {
  box-shadow: inset 0 0 30px rgba(16, 185, 129, 0.05);
  border-left: 2px solid rgba(16, 185, 129, 0.3);
}

.file-tab.writing {
  color: var(--green) !important;
  position: relative;
}

.file-tab.writing::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--accent), var(--green));
  background-size: 200% 100%;
  animation: writeShimmer 1.5s linear infinite;
}

@keyframes writeShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* output-header-status removed — presence indicator replaces it */
.output-header-status-legacy {
  display: none; /* kept as no-op for safety */
  animation: fadeIn 0.3s ease;
}

.output-header-status .status-dot {
  width: 6px; height: 6px; background: var(--green); border-radius: 50%;
  animation: pulse 1s infinite;
}

.output-header-status .status-bar {
  width: 60px; height: 3px; background: var(--border); border-radius: 2px;
  overflow: hidden;
}

.output-header-status .status-bar-fill {
  height: 100%; background: var(--green); border-radius: 2px;
  transition: width 0.3s ease;
}

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

/* Scrollbar lights up green during streaming */
.output-content.streaming-active::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.4);
}

/* Edit highlight — source mode (phase 1: shown for 2s) */
.edit-highlight {
  background: rgba(16, 185, 129, 0.2);
  border-left: 3px solid var(--green);
  margin-left: -3px;
  padding-left: 3px;
  animation: editFlashSource 2s ease-in-out infinite;
}
@keyframes editFlashSource {
  0%, 100% { background: rgba(16, 185, 129, 0.2); }
  50% { background: rgba(16, 185, 129, 0.35); }
}

/* Edit highlight — rendered WYSIWYG view (phase 2: persistent green glow) */
.edit-highlight-rendered {
  background: rgba(16, 185, 129, 0.12);
  border-left: 3px solid var(--green);
  padding: 8px 12px 8px 16px;
  margin: 4px 0 4px -3px;
  border-radius: 4px;
  transition: background 1.8s ease-out, border-color 1.8s ease-out;
  animation: editPulseRendered 2.5s ease-in-out 2;
}
.edit-highlight-rendered > *:first-child { margin-top: 0; }
.edit-highlight-rendered > *:last-child { margin-bottom: 0; }
@keyframes editPulseRendered {
  0%, 100% { background: rgba(16, 185, 129, 0.12); }
  50% { background: rgba(16, 185, 129, 0.25); }
}
.edit-highlight-rendered.fade {
  background: transparent;
  border-left-color: transparent;
}

/* Append highlight — shows newly appended content in preview */
.append-highlight {
  border-left: 3px solid var(--green);
  background: rgba(16, 185, 129, 0.08);
  margin-top: 8px;
  padding-top: 16px;
  transition: background 1.5s ease, border-color 1.5s ease;
}
.append-highlight.fade {
  background: transparent;
  border-left-color: transparent;
}

/* ---- OUTPUT STATUS BAR (below document) ---- */
.output-status {
  padding: 0 16px;
  border-top: 1px solid transparent;
  background: var(--bg);
  flex-shrink: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.35s ease, opacity 0.35s ease, padding 0.35s ease,
              border-color 0.35s ease;
}
.output-status.visible {
  height: 38px;
  padding: 8px 16px;
  opacity: 1;
  border-top-color: var(--border);
}

/* ---- PRESENCE INDICATOR (inside status bar) ---- */
.presence-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  transition: opacity 0.4s ease;
}
.presence-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  overflow: hidden; flex-shrink: 0;
}
.presence-avatar.agent { background: var(--purple); }
.presence-avatar.user { background: var(--accent); }
.presence-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.presence-name { color: var(--text-dim); white-space: nowrap; font-size: 12px; }
.presence-action {
  color: var(--green); font-size: 11px;
  animation: presenceBreathe 3s ease-in-out infinite;
}
@keyframes presenceBreathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Editable source view */
.output-source.editable {
  outline: none; cursor: text;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  min-height: 200px;
}
.output-source.editable:focus {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.03);
}
.output-source.editable::selection {
  background: rgba(99, 102, 241, 0.3);
}

/* WYSIWYG editable area (rendered markdown) */
.output-rendered.editable {
  outline: none; cursor: text;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  min-height: 200px;
  padding: 20px 24px;
  overflow-y: auto;
  line-height: 1.7;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}
.output-rendered.editable:focus {
  border-color: transparent;
}
.output-rendered.editable::selection {
  background: rgba(99, 102, 241, 0.3);
}
.output-rendered.editable h1 { font-size: 1.6em; margin: 0.5em 0 0.3em; }
.output-rendered.editable h2 { font-size: 1.3em; margin: 0.5em 0 0.3em; }
.output-rendered.editable h3 { font-size: 1.1em; margin: 0.5em 0 0.3em; }
.output-rendered.editable p { margin: 0.4em 0; }
.output-rendered.editable blockquote {
  border-left: 3px solid var(--accent); padding-left: 12px;
  margin: 0.5em 0; color: var(--text-dim);
}
.output-rendered.editable hr {
  border: none; border-top: 1px solid var(--border); margin: 1em 0;
}
.output-rendered.editable ul, .output-rendered.editable ol { padding-left: 24px; margin: 0.4em 0; }
.output-rendered.editable code { background: var(--surface3); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
.output-rendered.editable pre { background: var(--surface2); padding: 12px; border-radius: 6px; overflow-x: auto; }

/* Formatting toolbar — icon buttons */
.toolbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; color: var(--text-dim);
  cursor: pointer; position: relative;
  transition: background 0.12s, color 0.12s;
}
.toolbar-btn:hover { background: var(--surface3); color: var(--text); }
.toolbar-btn:active { transform: scale(0.95); }
.toolbar-btn.active {
  background: rgba(0, 122, 255, 0.1); color: var(--accent);
}
[data-theme="dark"] .toolbar-btn.active {
  background: rgba(77, 166, 255, 0.12);
}
.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.toolbar-divider {
  width: 1px; height: 18px; background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}

/* Toolbar tooltips (CSS-only) */
.toolbar-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px; background: var(--text); color: var(--bg);
  font-size: 11px; font-family: inherit; font-weight: 500;
  white-space: nowrap; border-radius: 5px;
  pointer-events: none; opacity: 0; z-index: 100;
  transition: opacity 0.15s ease 0.4s;
}
.toolbar-btn[data-tooltip]:hover::after { opacity: 1; }
[data-theme="dark"] .toolbar-btn[data-tooltip]::after {
  background: var(--surface3); color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Link popover */
.link-popover {
  position: absolute; top: calc(100% + 4px); left: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  z-index: 200; opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.link-popover.visible {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.link-popover input {
  width: 220px; padding: 5px 8px; font-size: 12px;
  font-family: inherit; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.link-popover input:focus { border-color: var(--accent); }
.link-popover input::placeholder { color: var(--text-muted); }
.link-popover-apply {
  padding: 5px 10px; font-size: 12px; font-weight: 500;
  font-family: inherit; background: var(--accent); color: white;
  border: none; border-radius: 5px; cursor: pointer;
  transition: opacity 0.12s;
}
.link-popover-apply:hover { opacity: 0.85; }
.link-popover-remove {
  padding: 5px; background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: color 0.12s, background 0.12s;
}
.link-popover-remove:hover { color: var(--danger, #ef4444); background: rgba(239, 68, 68, 0.08); }
[data-theme="dark"] .link-popover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Source toggle button (power users) */
.source-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; font-size: 11px; font-family: var(--mono);
  background: none; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s; letter-spacing: 0.02em;
}
.source-btn:hover { color: var(--text); background: var(--surface2); border-color: var(--text-muted); }
.source-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim, rgba(99, 102, 241, 0.08)); }

/* Inline edit toolbar — appears on content focus */
.inline-edit-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0; overflow: visible;
  opacity: 0; max-height: 0;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}
.inline-edit-toolbar.visible {
  opacity: 1; max-height: 44px;
}
[data-theme="dark"] .inline-edit-toolbar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ---- MAGIC WAND FLOATING BUTTON ---- */
.magic-wand-btn {
  position: absolute; z-index: 300;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
  cursor: pointer;
  opacity: 0; pointer-events: none;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.12s;
}
.magic-wand-btn.visible {
  opacity: 1; pointer-events: auto; transform: scale(1);
}
.magic-wand-btn:hover {
  background: var(--purple-dim); border-color: var(--purple);
}
.magic-wand-btn:active { transform: scale(0.92); }
.magic-wand-btn svg { width: 16px; height: 16px; color: var(--purple); }
.magic-wand-btn.rewriting { pointer-events: none; opacity: 0.5; }
[data-theme="dark"] .magic-wand-btn {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* ---- SELECTION CHIP (above chat input) ---- */
.selection-chip {
  display: none; align-items: center; gap: 8px;
  padding: 6px 10px 6px 12px; margin-bottom: 8px;
  background: var(--purple-dim);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: 20px;
  font-size: 12px; color: var(--purple);
  animation: chipSlideIn 0.15s ease;
}
.selection-chip.visible { display: flex; }
.selection-chip-icon {
  flex-shrink: 0; width: 14px; height: 14px; opacity: 0.7;
}
.selection-chip-text {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11px;
  max-width: 260px;
}
.selection-chip-dismiss {
  flex-shrink: 0; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--purple);
  border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1;
  opacity: 0.5; transition: opacity 0.12s, background 0.12s;
  padding: 0;
}
.selection-chip-dismiss:hover { opacity: 1; background: rgba(124, 58, 237, 0.12); }
@keyframes chipSlideIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
[data-theme="dark"] .selection-chip {
  border-color: rgba(167, 139, 250, 0.15);
}

/* ---- PERSISTENT SELECTION HIGHLIGHT ---- */
.rewrite-selection-highlight {
  background: rgba(124, 58, 237, 0.15);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
}
[data-theme="dark"] .rewrite-selection-highlight {
  background: rgba(167, 139, 250, 0.18);
}

/* ---- REWRITE SHIMMER ---- */
@keyframes rewriteShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.rewrite-shimmer {
  background: linear-gradient(90deg, transparent 0%, var(--purple-dim) 40%, rgba(124, 58, 237, 0.15) 50%, var(--purple-dim) 60%, transparent 100%);
  background-size: 200% 100%;
  animation: rewriteShimmer 1.5s ease-in-out infinite;
  border-radius: 2px;
}
[data-theme="dark"] .rewrite-shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(167, 139, 250, 0.08) 40%, rgba(167, 139, 250, 0.16) 50%, rgba(167, 139, 250, 0.08) 60%, transparent 100%);
  background-size: 200% 100%;
  animation: rewriteShimmer 1.5s ease-in-out infinite;
}

/* ---- REWRITE COST BADGE ---- */
.rewrite-cost-badge {
  position: absolute; z-index: 300;
  font-size: 10px; font-family: var(--mono);
  color: var(--green); background: var(--green-dim);
  padding: 2px 8px; border-radius: 10px;
  opacity: 1; transition: opacity 0.5s ease;
  pointer-events: none;
}
.rewrite-cost-badge.fading { opacity: 0; }

/* Content fade-in animation */
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.output-rendered.fade-in { animation: contentFadeIn 0.4s ease both; }

/* ---- MEMORY INDICATOR ---- */
.memory-card {
  background: var(--purple-dim); border: 1px solid var(--purple-dim);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 11px;
  color: var(--purple); display: flex; align-items: center; gap: 8px;
  animation: fadeIn 0.3s ease;
}

.memory-card .mem-icon { font-size: 14px; }
.memory-card .mem-text { color: var(--text-dim); }
.memory-card .mem-size { font-family: var(--mono); color: var(--purple); font-weight: 600; }

/* ---- MEMORY SETTINGS ---- */
.memory-preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  max-height: 200px; overflow-y: auto; line-height: 1.5; white-space: pre-wrap;
  word-break: break-word; margin-top: 6px;
}

.memory-actions { display: flex; gap: 6px; margin-top: 8px; }

.memory-actions button {
  padding: 5px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-dim); font-size: 11px;
  cursor: pointer; transition: all 0.15s;
}

.memory-actions button:hover { background: var(--surface3); color: var(--text); }
.memory-actions button.danger { border-color: rgba(255,45,85,0.3); color: var(--red); }
.memory-actions button.danger:hover { background: var(--red-dim); }

/* ---- INPUT ---- */
.input-area { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.input-wrap { display: flex; gap: 10px; align-items: flex-end; }

.input-wrap textarea {
  flex: 1; background: var(--input-bg); border: 1px solid var(--border-light);
  border-radius: 24px; color: var(--text); font-size: 15px;
  font-family: inherit; padding: 10px 14px; resize: none;
  min-height: 42px; max-height: 100px; line-height: 1.4;
  outline: none; transition: border-color 0.15s;
}

.input-wrap textarea:focus { border-color: var(--accent); }
.input-wrap textarea::placeholder { color: var(--text-muted); }

.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--accent); color: white; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, opacity 0.15s; flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- STOP BUTTON ---- */
.stop-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--red);
  background: var(--red-dim); color: var(--red); font-size: 14px;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
  animation: fadeIn 0.2s ease;
}

.stop-btn:hover { background: rgba(248, 113, 113, 0.3); }
.stop-btn.visible { display: flex; }

.stop-btn .stop-icon {
  width: 14px; height: 14px; background: var(--red);
  border-radius: 2px;
}

/* ---- OUTPUT PANE ---- */
.output-content { flex: 1; overflow: auto; position: relative; }

.output-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; text-align: center; padding: 32px; gap: 8px;
}

.output-empty-icon {
  font-size: 32px; color: var(--accent);
  opacity: 0.5;
  animation: emptyPulse 4s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.output-empty p {
  max-width: 280px; line-height: 1.5;
  color: var(--text-dim); font-size: 15px; font-weight: 500;
  margin: 0;
}

.output-empty .output-empty-hint {
  font-size: 13px; font-weight: 400;
  color: var(--text-muted); margin-top: 2px;
}

/* ---- AMBIENT GLOW (agent working) ---- */
.pane-output.pane-glow::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow:
    inset 0 0 60px rgba(16, 185, 129, 0.07),
    inset 0 0 120px rgba(16, 185, 129, 0.03);
  animation: ambientGlow 3s ease-in-out infinite;
  opacity: 1;
  transition: opacity 0.8s ease;
}
.pane-output.pane-glow-out::before {
  opacity: 0;
}
@keyframes ambientGlow {
  0%, 100% {
    box-shadow:
      inset 0 0 60px rgba(16, 185, 129, 0.07),
      inset 0 0 120px rgba(16, 185, 129, 0.03);
  }
  50% {
    box-shadow:
      inset 0 0 80px rgba(16, 185, 129, 0.12),
      inset 0 0 150px rgba(16, 185, 129, 0.05);
  }
}
[data-theme="dark"] .pane-output.pane-glow::before {
  box-shadow:
    inset 0 0 60px rgba(52, 211, 153, 0.08),
    inset 0 0 120px rgba(52, 211, 153, 0.04);
}

/* Document dimming while agent prepares */
.output-content.output-dimmed {
  opacity: 0.4;
  transition: opacity 0.4s ease;
}

.output-source {
  padding: 16px; font-size: 12px; font-family: var(--mono);
  line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text);
}

.output-preview { width: 100%; height: 100%; border: none; background: var(--preview-bg); }

/* ---- RENDERED MARKDOWN ---- */
.output-rendered {
  padding: 24px 28px; font-size: 14px; line-height: 1.7; color: var(--text);
  max-width: 800px; overflow-wrap: break-word;
}

.output-rendered h1 { font-size: 28px; font-weight: 700; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.output-rendered h2 { font-size: 22px; font-weight: 600; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.output-rendered h3 { font-size: 18px; font-weight: 600; margin: 24px 0 8px; }
.output-rendered h4 { font-size: 15px; font-weight: 600; margin: 20px 0 6px; }
.output-rendered h5 { font-size: 14px; font-weight: 600; margin: 16px 0 4px; color: var(--text-dim); }
.output-rendered h6 { font-size: 13px; font-weight: 600; margin: 16px 0 4px; color: var(--text-muted); }

.output-rendered p { margin: 0 0 12px; }
.output-rendered p:last-child { margin-bottom: 0; }

.output-rendered strong { font-weight: 600; }
.output-rendered em { font-style: italic; }

.output-rendered code {
  background: var(--surface3); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: var(--mono); color: var(--code-color);
}

.output-rendered pre {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 12px 0; overflow-x: auto; font-size: 12px;
  font-family: var(--mono); line-height: 1.6;
}

.output-rendered pre code {
  background: none; padding: 0; border-radius: 0; color: var(--text); font-size: inherit;
}

.output-rendered ul, .output-rendered ol { margin: 8px 0 12px 24px; }
.output-rendered li { margin-bottom: 4px; }
.output-rendered li > ul, .output-rendered li > ol { margin-top: 4px; margin-bottom: 4px; }

.output-rendered blockquote {
  border-left: 3px solid var(--accent); margin: 12px 0; padding: 8px 16px;
  background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}

.output-rendered blockquote p { margin-bottom: 6px; }
.output-rendered blockquote p:last-child { margin-bottom: 0; }

.output-rendered hr {
  border: none; border-top: 1px solid var(--border); margin: 24px 0;
}

.output-rendered a { color: var(--accent); text-decoration: none; }
.output-rendered a:hover { text-decoration: underline; }

.output-rendered table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.output-rendered th, .output-rendered td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px;
}
.output-rendered th { background: var(--surface); font-weight: 600; }
.output-rendered tr:nth-child(even) { background: var(--surface); }

.output-rendered img { max-width: 100%; border-radius: var(--radius-sm); }

.file-tabs-wrapper {
  display: flex; align-items: stretch; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative;
}

.file-tabs-arrow {
  display: none; align-items: center; justify-content: center;
  width: 24px; flex-shrink: 0; background: var(--surface);
  border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 0; z-index: 2;
  transition: color 0.1s, background 0.1s;
}
.file-tabs-arrow:hover { color: var(--text); background: var(--surface2); }
.file-tabs-arrow.visible { display: flex; }

.file-tabs {
  display: flex; gap: 0; overflow-x: auto; flex: 1; min-width: 0;
  scroll-behavior: smooth;
}

.file-tabs::-webkit-scrollbar { height: 0; }

.file-tab {
  padding: 8px 14px; font-size: 12px; font-family: var(--mono);
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); cursor: pointer; white-space: nowrap; transition: all 0.1s;
  max-width: 200px;
}

.file-tab { display: flex; align-items: center; gap: 6px; }
.file-tab span:first-child { overflow: hidden; text-overflow: ellipsis; }
.file-tab:hover { color: var(--text); background: var(--surface2); }
.file-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.file-tab-delete {
  opacity: 0; font-size: 14px; line-height: 1; color: var(--text-dim);
  cursor: pointer; padding: 0 2px; border-radius: 3px; transition: opacity 0.15s, color 0.15s;
}
.file-tab:hover .file-tab-delete { opacity: 0.6; }
.file-tab-delete:hover { opacity: 1 !important; color: var(--red); }

.close-btn {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  border: none; background: var(--surface2); color: var(--text-dim);
  cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center;
}

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

/* ---- HISTORY DRAWER ---- */
.history-drawer {
  position: fixed; top: 48px; left: 0; bottom: 0; width: 320px;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 50; transform: translateX(-100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}

.history-drawer.open { transform: translateX(0); }

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

.history-drawer .drawer-header h3 { font-size: 14px; font-weight: 600; }

.history-drawer .drawer-body { flex: 1; overflow-y: auto; padding: 8px; }

.history-item {
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.1s; margin-bottom: 2px;
}

.history-item:hover { background: var(--surface2); }

.history-item .hi-prompt {
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
}

.history-item .hi-meta {
  display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); font-family: var(--mono);
}

.history-item .hi-meta .hi-cost { color: var(--green); }

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

.history-actions button {
  flex: 1; padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-dim); font-size: 12px;
  cursor: pointer; transition: all 0.15s;
}

.history-actions button:hover { background: var(--surface3); color: var(--text); }
.history-actions button.danger { border-color: rgba(255,45,85,0.3); color: var(--red); }
.history-actions button.danger:hover { background: var(--red-dim); }

/* ---- NEW RUN BTN ---- */
.new-run-btn {
  padding: 6px 12px; background: var(--green-dim); border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius-sm); color: var(--green); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 5px;
}

.new-run-btn:hover { background: rgba(16,185,129,0.25); border-color: rgba(16,185,129,0.5); }

/* No-select during drag */
body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing iframe { pointer-events: none; }

/* ============================================================
   AUTH OVERLAY — Login screen
   ============================================================ */

/* ---- Auth: Split-panel login (mirrors Companio layout) ---- */

.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: row;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  background: #fff;
  padding: 24px;
  gap: 0;
}
.auth-overlay.visible { opacity: 1; pointer-events: auto; }
[data-theme="dark"] .auth-overlay { background: var(--bg); }

/* Left: Brand panel + form */
.auth-brand {
  width: 380px; min-width: 320px; max-width: 420px;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 24px 32px 32px;
  margin-right: 120px;
}

.auth-brand-content {
  display: flex; flex-direction: column; gap: 0;
}

.auth-brand-logo {
  width: 48px; height: 48px;
  margin-bottom: 0;
}

.auth-brand-text {
  margin-top: 48px;
}

.auth-brand-text h1 {
  font-size: 20px; font-weight: 500; line-height: 1.4;
  color: var(--text); margin: 0 0 8px;
}

.auth-tagline {
  font-size: 15px; color: var(--text-dim); line-height: 1.5;
}

/* Form in left panel (like Companio — form at bottom) */
#auth-form {
  display: flex; flex-direction: column;
  margin-top: auto;
  padding-bottom: 24px;
}

.auth-form-fields {
  display: flex; flex-direction: column; gap: 16px;
}

.auth-field {
  display: flex; flex-direction: column; gap: 6px;
}

#auth-form label {
  font-size: 12px; font-weight: 400;
  color: var(--text-dim);
}

#auth-form input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none; transition: border-color 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
#auth-form input:focus {
  border-color: #396AF7;
  box-shadow: 0 0 0 3px rgba(57,106,247,0.1);
}

#auth-form button[type="submit"] {
  padding: 8px 16px;
  background: #396AF7; color: #fff;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  margin-top: 20px;
  white-space: nowrap;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(30,41,59,0.12);
}
#auth-form button[type="submit"]:hover { background: #2f5ad4; }
#auth-form button[type="submit"]:active { transform: scale(0.98); }
#auth-form button[type="submit"]:disabled { opacity: 0.5; cursor: wait; }

.auth-error {
  color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px;
}

/* Right: Decorative panel (light gray with icons) */
.auth-decor {
  flex: 1; min-width: 0;
  background: #f8fafc;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 36px;
  overflow: hidden;
}
[data-theme="dark"] .auth-decor {
  background: #151822;
  border-color: #1e2230;
}

.auth-decor-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-end;
  align-items: flex-start;
  padding-top: 8px;
}

.auth-icon {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
  opacity: 0.85;
  transition: opacity 0.2s;
}
.auth-icon:hover { opacity: 1; }
[data-theme="dark"] .auth-icon { opacity: 0.7; }
[data-theme="dark"] .auth-icon:hover { opacity: 0.9; }

.auth-decor-footer {
  display: flex; gap: 8px; align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.auth-decor-footer a {
  font-size: 12px; color: var(--text-dim);
  text-decoration: none;
}
.auth-decor-footer a:hover {
  text-decoration: underline;
  text-decoration-color: #396AF7;
}
.auth-decor-footer span {
  font-size: 12px; color: var(--text-dim);
}

/* Responsive: stack on narrow screens */
@media (max-width: 768px) {
  .auth-overlay {
    flex-direction: column;
    padding: 16px;
  }
  .auth-brand {
    width: 100%; min-width: 0; max-width: none;
    margin-right: 0;
    padding: 16px 20px 24px;
  }
  .auth-brand-text { margin-top: 24px; }
  .auth-brand-text h1 { font-size: 18px; }
  .auth-brand-logo { width: 36px; height: 36px; }
  .auth-tagline { font-size: 13px; }
  .auth-decor { display: none; }
}

/* Logout button in sidebar */
.sidebar-logout-btn { color: var(--text-muted) !important; }
.sidebar-logout-btn:hover { color: var(--red) !important; background: var(--red-dim) !important; }
.sidebar-logout-btn svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
