:root,
[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elevated: #161a22;
  --bg-hover: #1c212b;
  --bg-tab: #12151c;
  --border: #2a303c;
  --text: #e6e9ef;
  --text-muted: #8b93a7;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --accent-soft: rgba(108, 140, 255, 0.15);
  --success: #3ecf8e;
  --danger: #f07178;
  --warning: #e0af68;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --sidebar-w: 280px;
  --ai-w: 360px;
  --topbar-h: 48px;
  --tabbar-h: 36px;
  --status-h: 28px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --bg-hover: #eef0f4;
  --bg-tab: #f0f2f5;
  --border: #d8dde6;
  --text: #1a1d26;
  --text-muted: #5c6578;
  --accent: #4c6ef5;
  --accent-hover: #3b5bdb;
  --accent-soft: rgba(76, 110, 245, 0.12);
  --success: #12b886;
  --danger: #e03131;
  --warning: #f08c00;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

[data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  flex-shrink: 0;
}

.brand-logo {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: block;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 4px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  z-index: 40;
  position: relative;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.02em;
  padding: 0 6px;
}

.topbar-center {
    flex: 1;
    text-align: start;
    overflow: hidden;
    min-width: 0;
    margin-left: 150px;
}

.current-file {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  white-space: nowrap;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.accent { background: var(--accent-soft); color: var(--accent); }
.btn.accent:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 11px; }

/* GitHub connect button */
.btn.github {
  background: #24292f;
  color: #fff;
}
.btn.github:hover { background: #32383f; color: #fff; }
[data-theme="light"] .btn.github {
  background: #24292f;
  color: #fff;
}
.btn.github.connected {
  background: var(--accent-soft);
  color: var(--accent);
}


.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Main layout */
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Backdrop (mobile drawers) */
.backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 22;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.backdrop.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar Ã¢ÂÂ desktop collapsible */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, margin 0.2s ease, opacity 0.15s;
  z-index: 25;
}

/* Collapsed on desktop */
.sidebar.collapsed {
  width: 0;
  border-right-width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  gap: 6px;
  min-width: 260px; /* prevent squash while animating */
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-close-btn {
  display: none; /* mobile only */
}

.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  min-width: 260px;
}

.view { display: none; }
.view.active { display: block; }

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.repo-item, .tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 12.5px;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.repo-item:hover, .tree-item:hover { background: var(--bg-hover); }
.repo-item.active, .tree-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.repo-item .icon, .tree-item .icon {
  flex-shrink: 0;
  opacity: 0.85;
  display: flex;
  align-items: center;
}
.repo-item .icon [data-lucide],
.tree-item .icon [data-lucide] {
  width: 15px;
  height: 15px;
}

.breadcrumb {
  padding: 6px 14px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.breadcrumb span { cursor: pointer; color: var(--accent); }
.breadcrumb span:hover { text-decoration: underline; }

/* Editor */
.editor-area {
  flex: 1;
  position: relative;
  min-width: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.tab-bar {
  height: var(--tabbar-h);
  background: var(--bg-tab);
  border-bottom: 1px solid var(--border);
  display: none;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.tab-bar.has-tabs { display: flex; }

.tabs-list {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  max-width: 180px;
  white-space: nowrap;
  background: transparent;
  border-top: 2px solid transparent;
  transition: background 0.1s, color 0.1s;
  user-select: none;
}
.editor-tab:hover { background: var(--bg-hover); color: var(--text); }
.editor-tab.active {
  background: var(--bg);
  color: var(--text);
  border-top-color: var(--accent);
}
.editor-tab .tab-name { overflow: hidden; text-overflow: ellipsis; }
.editor-tab .tab-close {
  opacity: 0.5;
  border-radius: 3px;
  padding: 2px;
  display: flex;
}
.editor-tab .tab-close:hover {
  opacity: 1;
  background: var(--bg-hover);
  color: var(--danger);
}
.editor-tab.dirty .tab-name::after {
  content: " Ã¢ÂÂ¢";
  color: var(--accent);
}

#editor-container {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: none;
}
#editor-container.visible { display: block; }

.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}
.welcome-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(108, 140, 255, 0.25));
}
.welcome h1 {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}
.welcome .tagline {
  font-size: 15px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 6px;
}
.welcome .sub { margin-bottom: 28px; font-size: 13px; }
.welcome ol {
  text-align: left;
  max-width: 400px;
  line-height: 1.8;
  font-size: 13px;
}
.welcome strong { color: var(--text); }

/* AI Panel Ã¢ÂÂ desktop collapsible */
.ai-panel {
  width: 0;
  background: var(--bg-elevated);
  border-left: 1px solid transparent;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, border-color 0.2s;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
}

.ai-panel.open {
  width: var(--ai-w);
  border-left-color: var(--border);
  opacity: 1;
  pointer-events: auto;
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  gap: 8px;
  min-width: 300px;
}
.ai-header span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-actions select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font);
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 300px;
}

.msg {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.55;
  max-width: 100%;
}
.msg.user {
  background: var(--accent-soft);
  align-self: flex-end;
  border: 1px solid rgba(108, 140, 255, 0.2);
}
.msg.assistant {
  background: var(--bg);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.msg.streaming::after {
  content: "Ã¢ÂÂ";
  animation: blink 0.8s infinite;
  color: var(--accent);
}
@keyframes blink { 50% { opacity: 0; } }

.msg pre {
  background: #0a0c10;
  border-radius: 0 0 6px 6px;
  padding: 10px;
  overflow-x: auto;
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
}
[data-theme="light"] .msg pre { background: #eef0f4; }
.msg code { font-family: var(--mono); font-size: 11.5px; }

/* Per code-block toolbar (Copy + Apply) */
.msg .code-block {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #0a0c10;
}
[data-theme="light"] .msg .code-block { background: #eef0f4; }
.msg .code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .msg .code-actions {
  background: rgba(0, 0, 0, 0.03);
}
.msg .code-lang {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-right: auto;
  font-family: var(--mono);
}
.msg .code-btn {
  font-size: 11px;
  padding: 2px 8px;
  height: auto;
  line-height: 1.4;
}
.msg .code-btn.copied {
  color: var(--accent);
}
.msg .apply-btn { margin-top: 8px; font-size: 11px; }

.ai-input-area {
  border-top: 1px solid var(--border);
  padding: 10px;
  min-width: 300px;
}
#ai-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 12.5px;
  resize: none;
  outline: none;
}
#ai-input:focus { border-color: var(--accent); }

.ai-input-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

/* Statusbar */
.statusbar {
  height: var(--status-h);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 40;
  position: relative;
}
#status-right {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  cursor: default;
  user-select: none;
}
#status-right.neuron-warn {
  color: var(--warning);
  font-weight: 500;
}

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

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.modal-content h2 {
  font-size: 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-content p {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.modal-content input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
.modal-content input:focus { border-color: var(--accent); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== Mobile / tablet ========== */
@media (max-width: 900px) {
  /* AI panel as full overlay */
  .ai-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(100%, 400px);
    max-width: 100%;
    height: 100%;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    opacity: 1;
    pointer-events: auto;
    z-index: 30;
  }
  .ai-panel.open {
    width: min(100%, 400px);
    transform: translateX(0);
  }

  .ai-header,
  .ai-messages,
  .ai-input-area {
    min-width: 0;
  }
}

@media (max-width: 768px) {
  /* Sidebar as full-height drawer */
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(85vw, 300px);
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    opacity: 1;
    pointer-events: auto;
    border-right: 1px solid var(--border);
    z-index: 30;
    box-shadow: none;
  }
  .sidebar.collapsed {
    width: min(85vw, 300px);
    opacity: 1;
    pointer-events: auto;
    /* still hidden via transform unless .open */
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }

  .sidebar-header,
  .sidebar-content {
    min-width: 0;
  }

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

  /* AI full screen on small phones */
  .ai-panel,
  .ai-panel.open {
    width: 100%;
    max-width: 100%;
    left: 0;
  }

  .topbar-center { display: none; }
  .brand-text { display: none; }
  .btn-label .label { display: none; }
  .btn-label { padding: 6px 8px; }

  /* Theme always visible Ã¢ÂÂ icon only is fine */
  #btn-theme { display: flex; }
}

@media (max-width: 400px) {
  .topbar-actions .btn.ghost { display: none; } /* hide Token text btn, keep via menu later if needed Ã¢ÂÂ actually keep token as icon */
  #btn-token .label { display: none; }
  #btn-token { padding: 6px 8px; }
}


/* Custom select (match UI) */
select, .ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
select:focus, .ui-select:focus {
  border-color: var(--accent);
}
select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Unified dialog */
#ui-dialog .ui-dialog-content {
  max-width: 400px;
}
#ui-dialog-message {
  white-space: pre-wrap;
  word-break: break-word;
}
#ui-dialog-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
#ui-dialog-input:focus { border-color: var(--accent); }
#ui-dialog-input.hidden,
#ui-dialog-cancel.hidden { display: none !important; }


/* Font Awesome icons */
.icon-btn i,
.btn i,
.tab i,
.brand i,
.ai-header i {
  font-size: 14px;
  line-height: 1;
}
.icon-btn i { font-size: 15px; }
.empty-state i { display: block; }

/* Screen-reader only native select (backed by custom UI) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  min-width: 130px;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger i { font-size: 10px; opacity: 0.7; }
.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  padding: 4px;
  margin: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.custom-select-menu.hidden { display: none; }
.custom-select-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.custom-select-menu li:hover { background: var(--bg-hover); }
.custom-select-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dialog icon */
.ui-dialog-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
}
.ui-dialog-icon:empty { display: none; }
.ui-dialog-content { text-align: center; }
.ui-dialog-content h2 { justify-content: center; }
.ui-dialog-content .modal-actions { justify-content: flex-end; }
.ui-dialog-content #ui-dialog-input { text-align: left; }

::-webkit-scrollbar { width: 8px; height: 8px; }

/* Custom select (match UI) */
select, .ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
select:focus, .ui-select:focus {
  border-color: var(--accent);
}
select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Unified dialog */
#ui-dialog .ui-dialog-content {
  max-width: 400px;
}
#ui-dialog-message {
  white-space: pre-wrap;
  word-break: break-word;
}
#ui-dialog-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
#ui-dialog-input:focus { border-color: var(--accent); }
#ui-dialog-input.hidden,
#ui-dialog-cancel.hidden { display: none !important; }


/* Font Awesome icons */
.icon-btn i,
.btn i,
.tab i,
.brand i,
.ai-header i {
  font-size: 14px;
  line-height: 1;
}
.icon-btn i { font-size: 15px; }
.empty-state i { display: block; }

/* Screen-reader only native select (backed by custom UI) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  min-width: 130px;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger i { font-size: 10px; opacity: 0.7; }
.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  padding: 4px;
  margin: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.custom-select-menu.hidden { display: none; }
.custom-select-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.custom-select-menu li:hover { background: var(--bg-hover); }
.custom-select-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dialog icon */
.ui-dialog-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
}
.ui-dialog-icon:empty { display: none; }
.ui-dialog-content { text-align: center; }
.ui-dialog-content h2 { justify-content: center; }
.ui-dialog-content .modal-actions { justify-content: flex-end; }
.ui-dialog-content #ui-dialog-input { text-align: left; }

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

/* Custom select (match UI) */
select, .ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
select:focus, .ui-select:focus {
  border-color: var(--accent);
}
select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Unified dialog */
#ui-dialog .ui-dialog-content {
  max-width: 400px;
}
#ui-dialog-message {
  white-space: pre-wrap;
  word-break: break-word;
}
#ui-dialog-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
#ui-dialog-input:focus { border-color: var(--accent); }
#ui-dialog-input.hidden,
#ui-dialog-cancel.hidden { display: none !important; }


/* Font Awesome icons */
.icon-btn i,
.btn i,
.tab i,
.brand i,
.ai-header i {
  font-size: 14px;
  line-height: 1;
}
.icon-btn i { font-size: 15px; }
.empty-state i { display: block; }

/* Screen-reader only native select (backed by custom UI) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  min-width: 130px;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger i { font-size: 10px; opacity: 0.7; }
.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  padding: 4px;
  margin: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.custom-select-menu.hidden { display: none; }
.custom-select-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.custom-select-menu li:hover { background: var(--bg-hover); }
.custom-select-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dialog icon */
.ui-dialog-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
}
.ui-dialog-icon:empty { display: none; }
.ui-dialog-content { text-align: center; }
.ui-dialog-content h2 { justify-content: center; }
.ui-dialog-content .modal-actions { justify-content: flex-end; }
.ui-dialog-content #ui-dialog-input { text-align: left; }

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

/* Custom select (match UI) */
select, .ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
select:focus, .ui-select:focus {
  border-color: var(--accent);
}
select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Unified dialog */
#ui-dialog .ui-dialog-content {
  max-width: 400px;
}
#ui-dialog-message {
  white-space: pre-wrap;
  word-break: break-word;
}
#ui-dialog-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
#ui-dialog-input:focus { border-color: var(--accent); }
#ui-dialog-input.hidden,
#ui-dialog-cancel.hidden { display: none !important; }


/* Font Awesome icons */
.icon-btn i,
.btn i,
.tab i,
.brand i,
.ai-header i {
  font-size: 14px;
  line-height: 1;
}
.icon-btn i { font-size: 15px; }
.empty-state i { display: block; }

/* Screen-reader only native select (backed by custom UI) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  min-width: 130px;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger i { font-size: 10px; opacity: 0.7; }
.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  padding: 4px;
  margin: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.custom-select-menu.hidden { display: none; }
.custom-select-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.custom-select-menu li:hover { background: var(--bg-hover); }
.custom-select-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dialog icon */
.ui-dialog-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
}
.ui-dialog-icon:empty { display: none; }
.ui-dialog-content { text-align: center; }
.ui-dialog-content h2 { justify-content: center; }
.ui-dialog-content .modal-actions { justify-content: flex-end; }
.ui-dialog-content #ui-dialog-input { text-align: left; }

::-webkit-scrollbar-thumb:hover { background: #3a4252; }
[data-theme="light"] 
/* Custom select (match UI) */
select, .ui-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
select:focus, .ui-select:focus {
  border-color: var(--accent);
}
select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Unified dialog */
#ui-dialog .ui-dialog-content {
  max-width: 400px;
}
#ui-dialog-message {
  white-space: pre-wrap;
  word-break: break-word;
}
#ui-dialog-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
}
#ui-dialog-input:focus { border-color: var(--accent); }
#ui-dialog-input.hidden,
#ui-dialog-cancel.hidden { display: none !important; }


/* Font Awesome icons */
.icon-btn i,
.btn i,
.tab i,
.brand i,
.ai-header i {
  font-size: 14px;
  line-height: 1;
}
.icon-btn i { font-size: 15px; }
.empty-state i { display: block; }

/* Screen-reader only native select (backed by custom UI) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  min-width: 130px;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
}
.custom-select-trigger:hover { border-color: var(--accent); }
.custom-select-trigger i { font-size: 10px; opacity: 0.7; }
.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  padding: 4px;
  margin: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.custom-select-menu.hidden { display: none; }
.custom-select-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.custom-select-menu li:hover { background: var(--bg-hover); }
.custom-select-menu li.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Dialog icon */
.ui-dialog-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
}
.ui-dialog-icon:empty { display: none; }
.ui-dialog-content { text-align: center; }
.ui-dialog-content h2 { justify-content: center; }
.ui-dialog-content .modal-actions { justify-content: flex-end; }
.ui-dialog-content #ui-dialog-input { text-align: left; }

::-webkit-scrollbar-thumb:hover { background: #b0b8c4; }


/* Neuron quota lock */
.quota-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
  padding: 24px;
}
.quota-lock.hidden { display: none !important; }
.quota-lock-card {
  max-width: 420px;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.quota-lock-icon {
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 12px;
}
.quota-lock-card h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 600;
}
.quota-lock-msg {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 20px;
}
.quota-countdown {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 8px;
}
.quota-lock-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 16px;
}
.quota-stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-family: var(--mono, monospace);
}
.quota-lock-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.8;
  margin: 0;
}
