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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2d3045;
  --accent: #3ecf8e;
  --accent-dim: #2a8f62;
  --text: #e2e8f0;
  --muted: #8892a4;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --font: 'Inter', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Layout */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
  overflow-y: auto;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.sb-logo-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  color: #0a0d14;
  font-size: 13px;
  font-weight: 800;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.sb-logo-text {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sb-nav { padding: 2px 10px; }

.sb-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 8px 4px;
  opacity: 0.6;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  text-decoration: none !important;
  border-left: 2px solid transparent;
  margin-bottom: 1px;
}
.sb-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.sb-link.active {
  background: rgba(62,207,142,0.08);
  color: var(--accent);
  border-left-color: var(--accent);
}

.sb-icon {
  width: 18px;
  flex-shrink: 0;
  font-size: 12px;
  text-align: center;
  opacity: 0.75;
}
.sb-link.active .sb-icon,
.sb-link:hover .sb-icon { opacity: 1; }

.sb-divider { height: 1px; background: var(--border); margin: 8px 10px; flex-shrink: 0; }

.sb-project-ctx {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 2px;
}
.sb-project-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.8;
}
.sb-project-name {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-spacer { flex: 1; }

.sb-bottom { padding: 4px 10px 14px; flex-shrink: 0; }

.sb-user-link { align-items: flex-start; gap: 10px; margin-bottom: 2px; }

.sb-avatar {
  width: 28px; height: 28px;
  background: rgba(62,207,142,0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(62,207,142,0.2);
  margin-top: 1px;
}
.sb-user-details { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sb-user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-sub { font-size: 10.5px; color: var(--muted); }

.sb-logout { color: var(--muted); font-size: 13px; }
.sb-logout:hover { color: var(--danger); }

.main { flex: 1; padding: 32px; overflow-y: auto; min-width: 0; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: center;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th { color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.badge-green { background: rgba(62,207,142,0.15); color: var(--accent); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(62,207,142,0.1); border: 1px solid rgba(62,207,142,0.3); color: var(--accent); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Auth pages */
.auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
  padding: 24px 16px;
}
.auth-box { width: 400px; max-width: 100%; }
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 6px; text-decoration: none;
}
.auth-mark {
  width: 44px; height: 44px; background: var(--accent); color: #fff;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; letter-spacing: -0.5px; flex-shrink: 0;
}
.auth-brand-name { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-sub { color: var(--text-muted); text-align: center; margin-bottom: 28px; margin-top: 4px; font-size: 13px; }
.auth-divider { text-align: center; color: var(--text-muted); font-size: 12px; margin: 16px 0; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 18px; }
.auth-forgot { display: block; text-align: right; font-size: 12px; margin-top: -8px; margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 8px 16px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Progress bar */
.progress-wrap { background: var(--border); border-radius: 999px; height: 6px; margin-top: 8px; }
.progress-bar { background: var(--accent); height: 6px; border-radius: 999px; width: 0; transition: width 0.2s; }

/* Utility */
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Add Column row */
.add-col-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.add-col-name  { flex: 1; min-width: 120px; }
.add-col-type  { flex: 0 0 auto; }
.add-col-nullable {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Top bar (always visible) ────────────────────────────────────── */
.sb-topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 200;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.sb-topbar.sb-topbar-hidden {
  transform: translateY(-100%);
}
.sb-topbar-brand {
  display: none;
  align-items: center;
  gap: 9px;
}
.sb-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-ai-topbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 15px;
  background: linear-gradient(135deg, #3ecf8e, #2a8f62);
  color: #0f1117;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sb-ai-topbar-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(62,207,142,0.4);
}

/* Hamburger button */
.sb-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 7px;
  background: none;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.sb-hamburger:hover { background: rgba(255,255,255,0.07); }
.sb-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--muted);
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.sb-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sb-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.sb-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Dark overlay behind the drawer */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sb-overlay.open { display: block; }

/* ── Desktop: hide hamburger, show brand in sidebar only ──────────── */
@media (min-width: 768px) {
  .sb-hamburger { display: none; }
  .sb-topbar { justify-content: flex-end; }
}

/* ── Mobile breakpoint: slide-in drawer ─────────────────────────── */
@media (max-width: 767px) {
  .layout { flex-direction: column; min-height: 0; }

  .sb-topbar { justify-content: flex-start; gap: 12px; }
  .sb-topbar-brand { display: flex; }
  .sb-topbar-right { margin-left: auto; }

  /* Sidebar hidden off-screen; slides in when .open is added */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100%;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s ease;
    border-right: 1px solid var(--border);
    /* reset desktop sticky behaviour */
    position: fixed;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.45);
  }

  .main { padding: 16px; }

  .page-header { gap: 8px; flex-wrap: wrap; }

  .modal { max-width: calc(100vw - 32px); margin: 16px; }

  .auth-box { width: 100%; }

  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Dropdown menu */
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 160px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--border); }
.dropdown-item-danger { color: var(--danger); }

/* Project cards grid */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.proj-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 14px; text-decoration: none; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s; position: relative;
}
.proj-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.proj-initial {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px;
  background: var(--accent); color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.proj-card-body { flex: 1; min-width: 0; }
.proj-card-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-card-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.proj-menu-wrap { position: relative; flex-shrink: 0; }
.proj-menu-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.proj-menu-btn:hover { background: var(--border); color: var(--text); }
.proj-menu-drop { position: absolute; top: calc(100% + 4px); right: 0; z-index: 60; }

/* File browser */
.fb-row:hover td { background: rgba(255,255,255,0.04); }
.fb-crumb { color: var(--accent); }
.fb-crumb:hover { text-decoration: underline; }
.fb-content {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  max-height: 60vh;
  overflow-y: auto;
  line-height: 1.6;
}
.fb-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  display: block;
  padding: 16px !important;
  overflow-x: auto;
}

/* ── API Reference ──────────────────────────────────────────────────────────── */

.method-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 56px;
  text-align: center;
  flex-shrink: 0;
}
.method-get    { background: #1e3a5f; color: #7dd3fc; }
.method-post   { background: #14532d; color: #86efac; }
.method-patch  { background: #451a03; color: #fcd34d; }
.method-delete { background: #450a0a; color: #fca5a5; }

.api-base-url {
  font-family: monospace;
  font-size: 0.78rem;
  background: var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 6px;
  display: inline-block;
  white-space: nowrap;
}

.api-table-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  background: var(--surface);
}
.api-table-title    { font-size: 1rem; font-weight: 600; }
.collaps-title      { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.collaps-title:hover { color: var(--accent); }
.collaps-chevron    { font-size: 0.85rem; color: var(--muted); transition: color 0.15s; }
.collaps-title:hover .collaps-chevron { color: var(--accent); }
.collaps-body       { margin-top: 12px; }
.api-table-physical { font-family: monospace; font-size: 0.73rem; color: var(--muted); margin-top: 2px; }

.endpoint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.endpoint-row:last-of-type { border-bottom: none; }
.endpoint-path { font-family: monospace; font-size: 0.82rem; }
.endpoint-desc { color: var(--muted); font-size: 0.8rem; }

.api-endpoint-detail { padding: 10px 0 4px; }

.api-tab-row { display: flex; gap: 4px; margin-bottom: 8px; }
.api-tab-btn {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.api-tab-btn.active {
  background: var(--border);
  color: var(--text);
}

.api-code-block {
  background: #0a0d14;
  color: #cbd5e1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: 7px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.68rem;
  padding: 2px 8px;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.8;
}
.copy-btn:hover { opacity: 1; }

/* Project Key rows */
.api-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.api-key-row:last-of-type { border-bottom: none; }
.api-key-label  { font-size: 0.78rem; color: var(--muted); min-width: 80px; }
.api-key-value  { font-family: monospace; font-size: 0.75rem; flex: 1; word-break: break-all; }
.api-key-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* PAT list */
.pat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.pat-row:last-of-type { border-bottom: none; }
.pat-name { font-size: 0.85rem; font-weight: 500; }
.pat-meta { font-size: 0.75rem; flex: 1; }

/* ─── AI FAB (replaced by topbar button) ─────────────────────────────────── */
.ai-fab {
  display: none !important;
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  background: linear-gradient(135deg, #3ecf8e, #2a8f62);
  color: #0f1117;
  border: none;
  border-radius: 28px;
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(62,207,142,0.35);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(62,207,142,0.45); }
.ai-fab-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ─── AI Panel ───────────────────────────────────────────────────────────── */
.ai-panel {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: 620px;
  height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  z-index: 999;
  display: none;
  overflow: hidden;
}
.ai-panel.ai-panel-open { display: flex; flex-direction: row; }

/* ─── Sessions sidebar ───────────────────────────────────────────────────── */
.ai-sessions {
  width: 172px;
  min-width: 172px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.ai-sessions-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.ai-sessions-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-new-session-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.ai-new-session-btn:hover { color: var(--accent); background: rgba(62,207,142,0.08); }
.ai-session-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.ai-session-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
  margin-bottom: 2px;
  position: relative;
}
.ai-session-item:hover { background: var(--surface); color: var(--text); }
.ai-session-item.active { background: var(--surface); color: var(--text); font-weight: 500; }
.ai-session-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ai-session-menu-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s;
}
.ai-session-item:hover .ai-session-menu-btn { opacity: 1; }
.ai-session-item.active .ai-session-menu-btn { opacity: 0.6; }
.ai-session-menu-btn:hover { background: var(--border); color: var(--text); opacity: 1 !important; }
.ai-session-menu-drop {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface-2, #1f2937);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 110px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  padding: 4px;
}
.ai-session-menu-drop.hidden { display: none; }
.ai-session-menu-item {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}
.ai-session-menu-item:hover { background: var(--border); }
.ai-session-menu-danger { color: var(--danger, #f87171); }
.ai-session-empty { font-size: 11px; color: var(--muted); padding: 10px; text-align: center; }

/* ─── Main area ──────────────────────────────────────────────────────────── */
.ai-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.ai-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
  position: relative;
}
.ai-header-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.ai-header-title { font-weight: 600; font-size: 13px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hamburger {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  display: none;
}
.ai-hamburger:hover { color: var(--text); }
.ai-header-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.ai-header-close:hover { color: var(--text); }
.ai-model-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.ai-model-btn:hover { border-color: var(--accent); color: var(--text); }
.ai-model-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 36px;
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 230px;
  z-index: 1100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.ai-model-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  gap: 8px;
}
.ai-model-option:hover { background: rgba(62,207,142,0.08); }
.ai-model-option.active { color: var(--accent); }
.ai-model-badge {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-welcome {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}
.ai-welcome-icon { font-size: 28px; color: var(--accent); margin-bottom: 8px; }
.ai-msg {
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 90%;
}
.ai-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #0f1117;
  font-weight: 500;
  max-width: 78%;
}
.ai-msg-ai {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  max-width: 100%;
}
.ai-msg-error { color: var(--danger); background: rgba(239,68,68,0.08); }
.ai-msg-thinking { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ai-thinking-dots { letter-spacing: 3px; animation: ai-thinking 1.2s infinite; display: inline-block; }
@keyframes ai-thinking { 0%,100% { opacity:1; } 50% { opacity:0.2; } }
.ai-thinking-label { font-size: 11px; color: var(--muted); min-height: 16px; }
.loader-ring {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loader-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }

/* ─── Live build progress card ───────────────────────────────────────────── */
.ai-progress-card { border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.ai-progress-title { font-weight: 600; font-size: 13px; color: var(--accent); margin-bottom: 8px; }
.ai-progress-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; }
.ai-progress-row--pending { opacity: 0.5; }
.ai-progress-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; border-radius: 50%; line-height: 1;
}
.ai-progress-icon--pending { color: var(--muted); border: 1px solid var(--border); }
.ai-progress-icon--done { color: #0f1117; background: var(--accent); font-weight: 700; }
.ai-progress-icon--error { color: #fff; background: var(--danger); font-weight: 700; }
.ai-progress-spin {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loader-spin 0.7s linear infinite;
}
.ai-progress-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ai-progress-label { font-size: 13px; color: var(--text); }
.ai-progress-row--pending .ai-progress-label { color: var(--muted); }
.ai-progress-detail { font-size: 11px; color: var(--muted); word-break: break-word; }
.ai-progress-error { margin-top: 8px; font-size: 12px; color: var(--danger); }

/* ─── Plan card ──────────────────────────────────────────────────────────── */
.ai-plan-card { border: 1px solid var(--border); }
.ai-plan-settled { opacity: 0.65; }
.ai-plan-title { font-weight: 600; margin-bottom: 8px; color: var(--accent); font-size: 13px; }
.ai-plan-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 3px;
}
.ai-plan-item { font-size: 12px; padding: 1px 0 1px 10px; color: var(--text); }
.ai-plan-row { font-size: 13px; margin-bottom: 3px; }
.ai-plan-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }

/* ─── Plan card — collapsible details ───────────────────────────────────── */
.ai-plan-details { margin-top: 8px; }
.ai-plan-details-summary {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-plan-details-summary::before { content: '▸'; font-size: 9px; }
details[open] > .ai-plan-details-summary::before { content: '▾'; }
.ai-plan-details-table { margin-top: 4px; }
.ai-plan-details-tname {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  padding: 2px 0 1px 8px;
}
.ai-plan-details-col {
  display: flex;
  gap: 8px;
  font-size: 11px;
  font-family: monospace;
  padding: 1px 0 1px 18px;
  color: var(--muted);
}
.ai-plan-details-colname { color: var(--text); min-width: 110px; }
.ai-plan-details-coltype { color: #7dd3fc; min-width: 90px; }
.ai-plan-details-colnull { font-size: 10px; }
.ai-plan-details-colnull.muted { color: var(--muted); }
.ai-plan-details-file {
  font-size: 11px;
  font-family: monospace;
  color: var(--muted);
  padding: 1px 0 1px 12px;
}
.ai-plan-details-file::before { content: '  '; }
.ai-plan-dl-btn {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-block;
  transition: color 0.15s, border-color 0.15s;
}
.ai-plan-dl-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ─── Result card ────────────────────────────────────────────────────────── */
.ai-result-card { border-left: 3px solid var(--accent); }
.ai-result-row { font-size: 13px; margin-bottom: 3px; }

/* ─── Diagnosis card ─────────────────────────────────────────────────────── */
.ai-diagnosis-card { border-left: 3px solid #f59e0b; }
.ai-diagnosis-text { font-size: 13px; line-height: 1.65; }

/* ─── Input bar ──────────────────────────────────────────────────────────── */
.ai-input-bar {
  padding: 10px 14px 16px;
  flex-shrink: 0;
}
.ai-input-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62,207,142,0.10);
}
.ai-textarea {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 13px 14px 6px;
  font-size: 14px;
  resize: none;
  min-height: 52px;
  max-height: 180px;
  line-height: 1.6;
  font-family: inherit;
  overflow-y: auto;
}
.ai-textarea:focus { outline: none; }
.ai-textarea::placeholder { color: var(--muted); }
.ai-input-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 8px 8px 10px;
  gap: 8px;
}
.ai-project-picker {
  flex: 1 1 120px;
  min-width: 110px;
  max-width: 200px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ai-project-picker:focus { outline: none; border-color: var(--accent); color: var(--text); }
.ai-send-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
  margin-left: auto;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}
.ai-send-btn:disabled {
  background: var(--border) !important;
  color: var(--muted) !important;
  cursor: not-allowed;
  opacity: 0.55;
}
.ai-send-btn:not(:disabled):hover { opacity: 0.85; }
.ai-send-btn:not(:disabled):active { transform: scale(0.9); }
.ai-send-btn--stop { color: var(--danger) !important; background: rgba(239, 68, 68, 0.1) !important; }
.ai-send-btn--stop::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  border-top-color: transparent;
  animation: ai-stop-spin 0.8s linear infinite;
  pointer-events: none;
}
@keyframes ai-stop-spin { to { transform: rotate(360deg); } }

/* ─── Review toggle ─────────────────────────────────────────────────────── */
.ai-review-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-review-toggle:hover { border-color: var(--accent); color: var(--text); }
.ai-review-toggle.active {
  background: rgba(62,207,142,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Intent card ───────────────────────────────────────────────────────── */
.ai-intent-card { padding: 14px 16px; }
.ai-intent-header {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.ai-intent-section-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
}
.ai-intent-divider { height: 1px; background: var(--border); margin: 12px 0; }
.ai-intent-actors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ai-actor-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(62,207,142,0.10);
  border: 1px solid rgba(62,207,142,0.28);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
}
.ai-actor-text { cursor: pointer; }
.ai-actor-text:hover { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.ai-actor-inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  outline: none;
  min-width: 40px;
  padding: 0;
}
.ai-story-inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  padding: 0;
  flex: 1;
}
.ai-chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 14px;
  opacity: 0.6;
}
.ai-chip-remove:hover { opacity: 1; }
.ai-intent-stories { display: flex; flex-direction: column; }
.ai-story-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ai-story-text { flex: 1; line-height: 1.5; cursor: pointer; }
.ai-story-text:hover { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.ai-story-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  margin-top: 0;
}
.ai-story-remove:hover { color: var(--danger, #f87171); }
.ai-story-add-row { margin-top: 8px; }
.ai-intent-add-input {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
}
.ai-intent-add-input:focus { border-color: var(--accent); color: var(--text); }
.ai-intent-actors .ai-intent-add-input { width: 90px; }
.ai-story-add-row .ai-intent-add-input { width: 100%; box-sizing: border-box; }
.ai-intent-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ─── Product requirements tree ─────────────────────────────────────────── */
.ai-req-tree { padding: 6px 0 2px; font-size: 12px; }
.ai-req-actor-block { margin-bottom: 10px; }
.ai-req-actor-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-weight: 600;
  color: var(--accent);
}
.ai-req-actor-name { cursor: pointer; flex: 1; }
.ai-req-actor-name:hover { text-decoration: underline dotted; }
.ai-req-tree-bullet { color: var(--muted); font-family: monospace; flex-shrink: 0; }
.ai-req-stories-wrap { padding-left: 16px; }
.ai-req-story-block { margin-bottom: 2px; }
.ai-req-story-block > summary { list-style: none; }
.ai-req-story-block > summary::-webkit-details-marker { display: none; }
.ai-req-story-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  cursor: pointer;
  color: var(--text);
}
.ai-req-tree-connector { color: var(--muted); font-family: monospace; flex-shrink: 0; }
.ai-req-story-title { flex: 1; cursor: pointer; }
.ai-req-story-title:hover { text-decoration: underline dotted; }
.ai-req-story-body { padding: 4px 0 4px 22px; }
.ai-req-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 5px 0 3px;
}
.ai-req-item {
  font-size: 11px;
  color: var(--text);
  padding: 1px 0;
  line-height: 1.5;
}
.ai-req-journey { color: var(--accent); }
.ai-req-nfr-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0 4px;
}
.ai-req-nfr-list { display: flex; flex-direction: column; gap: 2px; }
.ai-req-nfr-item { color: var(--muted); }
.ai-req-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  opacity: 0.5;
  flex-shrink: 0;
}
.ai-req-remove:hover { opacity: 1; }
.ai-story-inline-input {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
  font-size: 12px;
  padding: 1px 4px;
  outline: none;
}
.ai-intent-divider { border-top: 1px solid var(--border); margin: 8px 0 6px; }

/* ─── Intent summary (locked read-only after confirm) ────────────────────── */
.ai-intent-summary { padding: 10px 16px; }
.ai-intent-summary-header { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.ai-intent-summary-actors { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.ai-intent-summary-stories { display: flex; flex-direction: column; gap: 2px; }
.ai-intent-summary-story { font-size: 12px; color: var(--muted); cursor: pointer; }
.ai-intent-summary-section { margin: 2px 0; }
.ai-intent-summary-section > summary { list-style: none; }
.ai-intent-summary-section > summary::-webkit-details-marker { display: none; }
.ai-intent-summary-section[open] > summary .ai-intent-summary-story,
.ai-intent-summary-section > summary:hover { color: var(--text); }

/* ─── Edit review card ───────────────────────────────────────────────────── */
.ai-edit-review-card { padding: 14px 16px; }
.ai-edit-review-list { display: flex; flex-direction: column; margin-bottom: 4px; }
.ai-edit-review-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ai-edit-review-check { margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.ai-edit-review-text { flex: 1; min-width: 0; }
.ai-edit-review-label {
  display: block;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}
.ai-edit-review-label:hover { color: var(--accent); }
.ai-edit-review-desc { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.ai-edit-review-inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  padding: 0;
}

/* ─── Recovery card ──────────────────────────────────────────────────────── */
.ai-recovery-card { padding: 14px 16px; border-left: 3px solid #f87171; }
.ai-recovery-header { font-size: 13px; font-weight: 600; color: #f87171; margin-bottom: 8px; }
.ai-recovery-diagnosis { font-size: 13px; color: var(--text); margin-bottom: 12px; line-height: 1.5; }
.ai-recovery-options-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.ai-recovery-options { display: flex; flex-direction: column; gap: 6px; }
.ai-recovery-option {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.ai-recovery-option:hover:not(:disabled) { border-color: var(--accent); background: rgba(62,207,142,0.06); }
.ai-recovery-option:disabled { cursor: not-allowed; }
.ai-recovery-option-label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.ai-recovery-option-desc { font-size: 12px; color: var(--muted); }

/* ─── Mobile sidebar drawer ──────────────────────────────────────────────── */
.ai-sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9;
}
.ai-sidebar-overlay.ai-sidebar-overlay-visible { display: block; }

@media (max-width: 767px) {
  .ai-fab { bottom: 20px; right: 16px; padding: 11px 18px; }

  .ai-panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 998;
    animation: ai-backdrop-in 0.2s ease;
  }
  .ai-panel-backdrop.active { display: block; }
  @keyframes ai-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

  .ai-panel {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
    position: fixed;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  .ai-panel.ai-panel-open {
    transform: translateY(0);
  }

  .ai-hamburger { display: block; }

  .ai-sessions {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-radius: 0;
  }
  .ai-sessions.ai-sidebar-visible { transform: translateX(0); }
}

/* ── Token usage & toast ───────────────────────────────────────────────────── */
.ai-token-usage {
  font-size: 10px;
  color: var(--muted, #666);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
  letter-spacing: 0.02em;
}

.ai-toast {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--surface-2, #1a1d27);
  border: 1px solid var(--accent, #3ecf8e);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
  pointer-events: none;
  max-width: calc(100% - 32px);
  white-space: normal;
  text-align: center;
}
.ai-toast.ai-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── AI Job Indicator ───────────────────────────────────────────────────── */
.ai-job-indicator {
  position: fixed;
  bottom: 80px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2, #1a1d27);
  border: 1px solid var(--accent, #3ecf8e);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1100;
}
.ai-job-indicator-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.ai-job-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #3ecf8e);
  flex-shrink: 0;
  animation: ai-job-pulse 1.4s ease-in-out infinite;
}
@keyframes ai-job-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
.ai-job-indicator-label { flex: 1; }
.ai-job-indicator-view {
  background: transparent;
  border: 1px solid var(--accent, #3ecf8e);
  color: var(--accent, #3ecf8e);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ai-job-indicator-view:hover { background: rgba(62,207,142,0.1); }

/* Inline plan name edit */
.ai-plan-project-name {
  cursor: pointer;
  border-bottom: 1px dashed #555;
  padding-bottom: 1px;
}
.ai-plan-project-name:hover { border-bottom-color: #aaa; }
.ai-plan-name-input {
  font-size: 13px;
  padding: 1px 4px;
  background: var(--bg2, #1e2130);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  width: 160px;
  outline: none;
}
.ai-plan-error-notice {
  color: #f87171;
  font-size: 12px;
  margin: 4px 0 2px;
  width: 100%;
}

/* Session trace card */
.ai-trace-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  font-size: 12px;
  overflow: visible;
}
.ai-trace-top-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-trace-top-summary::before { content: '▸ '; font-size: 10px; }
details[open] > .ai-trace-top-summary::before { content: '▾ '; }
.ai-trace-dl-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  padding: 1px 7px;
  cursor: pointer;
  line-height: 1.6;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.ai-trace-dl-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.ai-trace-row {
  border-top: 1px solid var(--border);
}
.ai-trace-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  user-select: none;
  list-style: none;
  gap: 8px;
}
.ai-trace-summary::before { content: '▸ '; font-size: 9px; color: var(--muted); }
details[open] > .ai-trace-summary::before { content: '▾ '; }
.ai-trace-call { font-family: monospace; color: var(--text); }
.ai-trace-meta { color: var(--muted); white-space: nowrap; }
.ai-trace-sub {
  border-top: 1px solid var(--border);
}
.ai-trace-sub > summary {
  cursor: pointer;
  padding: 4px 16px;
  color: var(--muted);
  font-size: 11px;
  user-select: none;
  list-style: none;
}
.ai-trace-sub > summary::before { content: '▸ '; font-size: 9px; }
details[open] > .ai-trace-sub > summary::before { content: '▾ '; }
.ai-trace-json {
  background: var(--bg, #0f1117);
  color: #7dd3fc;
  font-family: monospace;
  font-size: 11px;
  padding: 8px 16px;
  overflow: auto;
  max-height: 260px;
  white-space: pre;
}

/* AI-internal call breakdown within a trace row */
.ai-trace-ai-section {
  border-top: 1px solid var(--border);
  padding: 8px 0 0 0;
}
.ai-trace-ai-header {
  padding: 4px 12px 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-trace-ai-entry {
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  font-size: 12px;
}
.ai-trace-ai-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 20px;
  user-select: none;
  list-style: none;
}
.ai-trace-ai-summary::before { content: '▸ '; font-size: 9px; color: var(--muted); }
details[open] > .ai-trace-ai-summary::before { content: '▾ '; }
.ai-trace-ai-stage { color: var(--text); font-family: monospace; }
.ai-trace-retry-badge {
  background: rgba(251,146,60,0.2);
  color: #fb923c;
  border: 1px solid rgba(251,146,60,0.4);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  white-space: nowrap;
}
.ai-trace-error-notice {
  padding: 4px 12px 4px 20px;
  font-size: 11px;
  color: #f87171;
  font-style: italic;
}
.ai-trace-tokens {
  padding: 4px 12px 6px 20px;
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}
.ai-trace-prompt { white-space: pre-wrap; word-break: break-word; }

/* FAB badge — green dot when session has activity */
.ai-fab { position: relative; }
.ai-fab-active::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: fab-badge-pulse 2s ease-in-out infinite;
}
@keyframes fab-badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* Mode toggle button (Chat / Build) */
.ai-mode-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.ai-mode-btn.active {
  background: rgba(62,207,142,0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.ai-mode-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Deploy confirm card */
.ai-deploy-confirm-card { border: 1px solid var(--border); }

/* Error retry/dismiss actions */
.ai-error-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ai-error-checkpoint { font-size: 12px; color: var(--accent); margin-top: 6px; }

/* Live trace indicator dot */
.ai-trace-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  animation: fab-badge-pulse 1.2s ease-in-out infinite;
}
