:root {
  color-scheme: dark;

  /* ── Theme channel ─────────────────────────────────────────── */
  --overlay-rgb: 255, 255, 255;

  /* ── Surfaces ──────────────────────────────────────────────── */
  --app-page-bg: #0f0f11;
  --surface-ground: #0b0b0d;
  --surface-sunken: #040404;
  --surface-raised: #161718;
  --surface-inset: color(srgb 0.1177 0.1177 0.1177);
  --panel-bg: var(--surface-inset);
  --surface-code: color(srgb 0.09 0.09 0.09);
  --surface-diff-bg: color(srgb 0.1339 0.1703 0.225);
  --surface-editor-active: color(srgb 0.3254 0.3254 0.3255);
  --surface-editor-hover: color(srgb 0.3754 0.3754 0.3755);
  --surface-editor-gutter: color(srgb 0.1451 0.1451 0.1494);
  --surface-ring: #0f0f11;
  --surface-modal: linear-gradient(180deg, rgba(22, 24, 30, 0.98) 0%, rgba(18, 19, 24, 0.98) 100%);
  --surface-popover: linear-gradient(180deg, rgba(29, 32, 37, 0.985), rgba(19, 21, 26, 0.985));
  --surface-elevated-solid: rgba(16, 16, 16, 0.98);
  --surface-tooltip: rgba(8, 10, 12, 0.92);
  --surface-chat-pane: rgba(20, 20, 22, 0.82);
  --surface-chat-sidebar: rgba(10, 11, 14, 0.92);
  --surface-chat-sidebar-header: rgba(24, 26, 32, 0.96);
  --surface-action-card: rgba(14, 11, 6, 0.88);
  --surface-action-card-gradient: linear-gradient(180deg, rgba(110, 82, 24, 0.22), rgba(54, 38, 10, 0.14));
  --surface-composer-bar: rgba(18, 22, 30, 0.96);
  --surface-composer-context: rgba(9, 12, 18, 0.42);
  --surface-composer-context-hover: rgba(9, 12, 18, 0.64);
  --surface-composer-confirm: rgba(24, 56, 41, 0.82);
  --surface-reply-opt: rgba(10, 11, 14, 0.92);
  --surface-reply-opt-header: rgba(18, 20, 24, 0.96);
  --surface-queue-editor: rgba(37, 37, 38, 1);
  --surface-queue-panel: rgba(10, 11, 14, 0.96);
  --surface-queue-panel-gradient: linear-gradient(180deg, rgba(14, 15, 19, 0.98), rgba(10, 11, 14, 0.98));
  --surface-run-output: rgba(5, 6, 8, 0.98);
  --surface-run-output-header: rgba(12, 14, 18, 0.98);
  --surface-run-sidebar: rgba(11, 13, 18, 0.92);
  --surface-terminal-surface: rgba(5, 6, 8, 0.98);
  --surface-terminal-toolbar: rgba(9, 11, 14, 0.92);
  --surface-session-tabbar: rgba(8, 10, 18, 0.92);
  --surface-diff-toolbar: rgba(8, 10, 18, 0.92);
  --surface-spinner-track: rgba(16, 17, 20, 0.2);
  --surface-spinner-head: rgba(16, 17, 20, 0.95);
  --surface-danger: rgba(35, 16, 16, 0.96);
  --surface-danger-gradient: linear-gradient(180deg, rgba(22, 24, 29, 0.98), rgba(12, 14, 17, 0.98));
  --surface-pr-detail-gradient: linear-gradient(180deg, rgba(19, 20, 23, 0.92) 0%, rgba(19, 20, 23, 0.98) 100%);
  --surface-tab-island: rgba(20, 18, 28, 0.98);
  --surface-error-toast: rgba(12, 13, 16, 0.96);
  --surface-error-toast-danger: rgba(42, 12, 16, 0.96);
  --surface-diff-hunk: rgba(58, 92, 148, 0.24);
  --surface-warning-badge: rgba(64, 42, 16, 0.34);
  --surface-error-bg: rgba(64, 18, 22, 0.58);
  --sidebar-top-gradient: rgba(0, 0, 0, 0.38);
  --text-strong: #fff;
  --surface-chat-bubble: rgb(43, 45, 49);
  --composer-shadow: rgba(0, 0, 0, 0.35);

  /* ── Layout ────────────────────────────────────────────────── */
  --app-header-height: 40px;
  --sidebar-width: 260px;
  --sidebar-resizer-width: 4px;
  --details-sidebar-width: 316px;
  --radius: 3px;
  --radius-circle: 999px;

  /* ── Semantic aliases ──────────────────────────────────────── */
  --panel-border: rgba(var(--overlay-rgb), 0.08);
  --panel-border-soft: rgba(var(--overlay-rgb), 0.05);
  --text: rgba(var(--overlay-rgb), 0.95);
  --muted: rgba(var(--overlay-rgb), 0.68);
  --muted-soft: rgba(var(--overlay-rgb), 0.48);
  --header-gray: #1d4ed8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* ── Sidebar icon accents ───────────────────────────────────── */
  --icon-red: #ff6b6b;
  --icon-green: #7ee0a5;
  --icon-purple: #c29bff;
  --icon-blue: #4db2ff;

  /* ── Status / accent colors ──────────────────────────────────── */
  --status-success: #58c57d;
  --status-warning: #e6bf22;
  --status-error: #de605a;
  --status-info: #5e9bff;
  --text-on-accent: #fff;
  --text-danger: #ffb0b0;
  --text-danger-accent: #ff8f8f;
  --toast-success-color: #dcffe4;
  --toast-warning-color: #fff1bf;
  --toast-danger-color: #ffd8d8;
  --toast-info-color: #dbe8ff;
  --error-header-color: rgb(255, 169, 169);
  --error-header-icon-color: rgb(255, 132, 132);
  --error-text-color: rgba(255, 232, 232, 0.97);
  --error-link-color: rgb(255, 196, 196);
  --tool-event-color: rgb(255, 118, 175);

  /* ── Status badge (danger / warning / success) ─────────────── */
  --badge-danger-border: rgba(214, 96, 90, 0.22);
  --badge-danger-bg: rgba(101, 24, 23, 0.22);
  --badge-danger-color: rgba(255, 224, 223, 0.9);
  --badge-warning-border: rgba(232, 190, 72, 0.22);
  --badge-warning-bg: rgba(102, 74, 13, 0.22);
  --badge-warning-color: rgba(255, 241, 208, 0.92);
  --badge-success-border: rgba(88, 197, 125, 0.28);
  --badge-success-bg: rgba(24, 87, 43, 0.24);
  --badge-success-color: rgba(214, 255, 225, 0.92);
  --badge-info-border: rgba(94, 155, 255, 0.26);
  --badge-info-bg: rgba(22, 48, 89, 0.24);
  --badge-info-color: rgba(221, 233, 255, 0.92);

  /* ── Alert / inline error ──────────────────────────────────── */
  --alert-error-border: rgba(255, 107, 107, 0.32);
  --alert-error-bg: rgba(255, 107, 107, 0.12);
  --alert-error-color: rgba(255, 224, 224, 0.96);
  --alert-error-dismiss: rgba(255, 235, 235, 0.82);

  /* ── Sidebar ──────────────────────────────────────────────────── */
  --sidebar-bg: linear-gradient(180deg, #040404 0%, #060607 100%);
  --sidebar-top-overlay: rgba(0, 0, 0, 0.38);

  /* ── Dashboard heatmap ─────────────────────────────────────── */
  --heatmap-level-1-bg: #163922;
  --heatmap-level-1-border: rgba(41, 111, 63, 0.52);
  --heatmap-level-2-bg: #1f6f37;
  --heatmap-level-2-border: rgba(51, 147, 80, 0.68);
  --heatmap-level-3-bg: #23984a;
  --heatmap-level-3-border: rgba(73, 181, 108, 0.78);
  --heatmap-level-4-bg: #4cd46b;
  --heatmap-level-4-border: rgba(121, 233, 149, 0.9);
  --heatmap-total-bg: rgba(27, 74, 42, 0.24);
  --heatmap-total-border: rgba(76, 168, 104, 0.28);
  --heatmap-total-color: rgba(214, 255, 225, 0.9);

  /* ── Blazor error UI ───────────────────────────────────────── */
  --blazor-error-border: rgba(255, 107, 107, 0.24);
  --blazor-error-bg: rgba(35, 16, 16, 0.96);
  --blazor-error-color: rgba(255, 230, 230, 0.96);

  /* ── Select dropdown (Windows) ─────────────────────────────── */
  --select-option-bg: #0f111a;
  --select-option-hover-bg: #1b2433;

  /* ── Context badge (purple accent) ─────────────────────────── */
  --context-badge-border: rgba(144, 122, 178, 0.34);
  --context-badge-bg: rgba(110, 84, 148, 0.2);
  --context-badge-color: rgba(242, 236, 255, 0.94);
  --context-badge-icon: rgba(222, 206, 246, 0.88);

  /* ── Context ring ──────────────────────────────────────────── */
  --context-ring-center: rgb(34, 34, 34);
  --context-ring-fill: #fff;
}

/* ── Light theme ───────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;
  --overlay-rgb: 0, 0, 0;
  --app-page-bg: #f5f6f8;
  --surface-ground: #edeef2;
  --surface-sunken: #e4e5ea;
  --surface-raised: #e8e9ed;
  --surface-inset: #f0f1f3;
  --panel-bg: var(--surface-inset);
  --surface-code: #f7f8fa;
  --surface-diff-bg: #e8eef8;
  --surface-editor-active: #d4d5d8;
  --surface-editor-hover: #c8c9cc;
  --surface-editor-gutter: #eaebef;
  --surface-ring: #f5f6f8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.08);
  --surface-modal: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 251, 0.98) 100%);
  --surface-popover: linear-gradient(180deg, #ffffff, #f8f9fb);
  --surface-elevated-solid: rgba(255, 255, 255, 0.98);
  --surface-tooltip: rgba(255, 255, 255, 0.96);
  --surface-chat-pane: rgba(255, 255, 255, 0.92);
  --surface-chat-sidebar: rgba(248, 249, 252, 0.96);
  --surface-chat-sidebar-header: rgba(242, 243, 247, 0.98);
  --surface-action-card: rgba(255, 248, 230, 0.92);
  --surface-action-card-gradient: linear-gradient(180deg, rgba(255, 220, 120, 0.16), rgba(255, 200, 80, 0.08));
  --surface-composer-bar: rgba(242, 244, 249, 0.98);
  --surface-composer-context: rgba(226, 232, 244, 0.52);
  --surface-composer-context-hover: rgba(216, 224, 240, 0.72);
  --surface-composer-confirm: rgba(220, 252, 235, 0.82);
  --surface-reply-opt: rgba(248, 249, 252, 0.96);
  --surface-reply-opt-header: rgba(240, 242, 246, 0.98);
  --surface-queue-editor: rgba(245, 246, 248, 1);
  --surface-queue-panel: rgba(248, 249, 252, 0.98);
  --surface-queue-panel-gradient: linear-gradient(180deg, rgba(245, 246, 250, 0.98), rgba(248, 249, 252, 0.98));
  --surface-run-output: rgba(250, 251, 253, 0.98);
  --surface-run-output-header: rgba(244, 245, 249, 0.98);
  --surface-run-sidebar: rgba(246, 247, 250, 0.96);
  --surface-terminal-surface: rgba(250, 251, 253, 0.98);
  --surface-terminal-toolbar: rgba(242, 243, 247, 0.96);
  --surface-session-tabbar: rgba(240, 242, 246, 0.96);
  --surface-diff-toolbar: rgba(240, 242, 246, 0.96);
  --surface-spinner-track: rgba(0, 0, 0, 0.08);
  --surface-spinner-head: rgba(0, 0, 0, 0.7);
  --surface-danger: rgba(254, 242, 242, 0.96);
  --surface-danger-gradient: linear-gradient(180deg, rgba(255, 248, 248, 0.98), rgba(254, 242, 242, 0.98));
  --surface-pr-detail-gradient: linear-gradient(180deg, rgba(250, 251, 253, 0.96) 0%, rgba(250, 251, 253, 0.99) 100%);
  --surface-tab-island: rgba(245, 242, 255, 0.98);
  --surface-error-toast: rgba(250, 250, 252, 0.98);
  --surface-error-toast-danger: rgba(254, 242, 242, 0.98);
  --surface-diff-hunk: rgba(191, 219, 254, 0.32);
  --surface-warning-badge: rgba(255, 220, 140, 0.3);
  --surface-error-bg: rgba(254, 226, 226, 0.5);
  --text-strong: rgba(0, 0, 0, 0.92);
  --surface-chat-bubble: #e8eaef;
  --composer-shadow: rgba(0, 0, 0, 0.08);
  --sidebar-top-gradient: rgba(0, 0, 0, 0.06);
  --icon-red: #c93030;
  --icon-green: #1a8a3a;
  --icon-purple: #7c3aed;
  --icon-blue: #1a6dbd;
  --status-success: #1a8a3a;
  --status-warning: #a16207;
  --status-error: #b91c1c;
  --status-info: #1d4ed8;
  --text-on-accent: #fff;
  --text-danger: #991b1b;
  --text-danger-accent: #b91c1c;
  --toast-success-color: #166534;
  --toast-warning-color: #854d0e;
  --toast-danger-color: #991b1b;
  --toast-info-color: #1e40af;
  --error-header-color: #991b1b;
  --error-header-icon-color: #b91c1c;
  --error-text-color: rgba(127, 29, 29, 0.92);
  --error-link-color: #991b1b;
  --tool-event-color: #be185d;
  --badge-danger-border: rgba(239, 68, 68, 0.2);
  --badge-danger-bg: rgba(254, 226, 226, 0.5);
  --badge-danger-color: #991b1b;
  --badge-warning-border: rgba(234, 179, 8, 0.2);
  --badge-warning-bg: rgba(254, 249, 195, 0.5);
  --badge-warning-color: #854d0e;
  --badge-success-border: rgba(34, 197, 94, 0.2);
  --badge-success-bg: rgba(220, 252, 231, 0.5);
  --badge-success-color: #166534;
  --badge-info-border: rgba(59, 130, 246, 0.2);
  --badge-info-bg: rgba(219, 234, 254, 0.5);
  --badge-info-color: #1e40af;
  --alert-error-border: rgba(239, 68, 68, 0.24);
  --alert-error-bg: rgba(254, 226, 226, 0.4);
  --alert-error-color: #991b1b;
  --alert-error-dismiss: #b91c1c;
  --sidebar-bg: linear-gradient(180deg, #eaebef 0%, #e4e5ea 100%);
  --sidebar-top-overlay: rgba(0, 0, 0, 0.04);
  --heatmap-level-1-bg: #d1fae5;
  --heatmap-level-1-border: rgba(167, 243, 208, 0.6);
  --heatmap-level-2-bg: #6ee7b7;
  --heatmap-level-2-border: rgba(52, 211, 153, 0.6);
  --heatmap-level-3-bg: #34d399;
  --heatmap-level-3-border: rgba(16, 185, 129, 0.6);
  --heatmap-level-4-bg: #10b981;
  --heatmap-level-4-border: rgba(5, 150, 105, 0.7);
  --heatmap-total-bg: rgba(209, 250, 229, 0.6);
  --heatmap-total-border: rgba(16, 185, 129, 0.3);
  --heatmap-total-color: #065f46;
  --blazor-error-border: rgba(239, 68, 68, 0.3);
  --blazor-error-bg: rgba(254, 242, 242, 0.98);
  --blazor-error-color: #991b1b;
  --select-option-bg: #ffffff;
  --select-option-hover-bg: #f0f1f5;
  --context-badge-border: rgba(124, 58, 237, 0.22);
  --context-badge-bg: rgba(139, 92, 246, 0.08);
  --context-badge-color: #6d28d9;
  --context-badge-icon: #7c3aed;
  --context-ring-center: var(--panel-bg);
  --context-ring-fill: rgba(0, 0, 0, 0.86);
}

[data-theme="light"] .app-header {
  --overlay-rgb: 255, 255, 255;
}

[data-theme="light"] .app-header-user-menu,
[data-theme="light"] .workspace-menu-panel {
  --overlay-rgb: 0, 0, 0;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  background: var(--app-page-bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  border: 0;
  outline: 0;
  color: inherit;
}

textarea {
  resize: none;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
pre {
  font-family: var(--font-mono);
}

.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.workspace-surface-view {
  min-height: 0;
  flex: 1;
  overflow: auto;
  background: var(--app-page-bg);
}

.workspace-empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 280px;
  padding: 32px 24px;
  text-align: center;
}

.workspace-empty-state h2,
.workspace-empty-state p {
  margin: 0;
}

.workspace-empty-state h2 {
  color: rgba(var(--overlay-rgb), 0.88);
  font-size: 19px;
  font-weight: 600;
}

.workspace-empty-state p {
  max-width: 420px;
  color: rgba(var(--overlay-rgb), 0.58);
  font-size: 14px;
  line-height: 1.5;
}

.workspace-empty-state-error p {
  color: var(--badge-info-color);
}

.workspace-empty-state-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: #1d4ed8;
  color: var(--text-on-accent);
  font-size: 13px;
  font-weight: 600;
}

.workspace-loading-state {
  display: flex !important;
  flex: 1 1 auto;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 14px !important;
  width: 100%;
  min-height: max(100%, 280px);
  text-align: center !important;
  align-self: stretch;
  justify-self: stretch;
}

.workspace-loading-state::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 2px solid rgba(var(--overlay-rgb), 0.14);
  border-top-color: rgba(var(--overlay-rgb), 0.92);
  border-right-color: rgba(var(--overlay-rgb), 0.42);
  border-radius: var(--radius-circle);
  animation: workspace-loading-spin 0.8s linear infinite;
}

.workspace-loading-state p {
  max-width: 420px;
}

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

@media (max-width: 900px) {
  body {
    overflow: auto;
  }
}

:root {
  --qodex-app-bg: var(--app-page-bg);
  --qodex-topbar-height: var(--app-header-height);
  --qodex-ink: var(--text);
  --qodex-ink-muted: var(--muted);
  --qodex-blue-700: #60a5fa;
  --qodex-sky-700: #7dd3fc;
  --qodex-link-color: #93c5fd;
  --qodex-shadow: var(--shadow);
}
