/* AI CS theme palettes: classic (default warm paper), dark, white.
   Loaded after style.css. Only colour/contrast is touched; layout stays identical. */

:root {
  --theme-switch-bg: var(--paper);
  --theme-switch-line: var(--line);
}

html[data-theme="classic"] {
  color-scheme: light;
}

/* ---------------- dark ---------------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141513;
  --bg-deep: #0e0f0d;
  --paper: #1c1e1a;
  --paper-2: #232621;
  --ink: #ecebe2;
  --ink-2: #c9c6ba;
  --muted: #b2afa3;
  --faint: #9a978c;
  --line: #3b3f36;
  --line-strong: #4e5449;
  --pine: #93c9b2;
  --pine-deep: #b3ddca;
  --pine-soft: #22312b;
  --amber: #dcae6e;
  --amber-soft: #32281a;
  --danger: #e08d80;
  --danger-soft: #3a2520;
}

html[data-theme="dark"] ::selection {
  background: #2f4a3f;
}

html[data-theme="dark"] * {
  scrollbar-color: #4a4f47 transparent;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: #4a4f47;
}

html[data-theme="dark"] .health.is-ok,
html[data-theme="dark"] .alert-ok,
html[data-theme="dark"] .badge-pine,
html[data-theme="dark"] .badge-ok,
html[data-theme="dark"] .ref-counts,
html[data-theme="dark"] .test-msg.tone-ok {
  border-color: #3c5648;
}

html[data-theme="dark"] .health.is-warn,
html[data-theme="dark"] .alert-warn,
html[data-theme="dark"] .notice-inline,
html[data-theme="dark"] .badge-warn,
html[data-theme="dark"] .tag-immutable,
html[data-theme="dark"] .limit-strip {
  border-color: #6b5228;
}

html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .badge-danger,
html[data-theme="dark"] .job-fail,
html[data-theme="dark"] .job-strip.job-failed,
html[data-theme="dark"] .test-msg.tone-danger,
html[data-theme="dark"] .btn-danger {
  border-color: #6d3f36;
}

html[data-theme="dark"] .inspector {
  background: #1a1c18;
}

html[data-theme="dark"] .btn,
html[data-theme="dark"] .upload-btn,
html[data-theme="dark"] .msg-assistant {
  background: #232621;
  border-color: #3d423a;
}

html[data-theme="dark"] .btn:hover:not(:disabled) {
  background: #2b2f29;
  border-color: #565d50;
}

html[data-theme="dark"] .badge-ink {
  background: #2a2d26;
  border-color: #454a40;
}

html[data-theme="dark"] .badge-pine,
html[data-theme="dark"] .badge-ok {
  background: #22302a;
}

html[data-theme="dark"] .badge-warn {
  background: #332817;
}

html[data-theme="dark"] .badge-danger {
  background: #38231f;
}

html[data-theme="dark"] .badge-busy,
html[data-theme="dark"] .msg-user,
html[data-theme="dark"] .job-strip.job-running,
html[data-theme="dark"] .job-strip.job-queued {
  background: #232b25;
  border-color: #3f4a40;
}

html[data-theme="dark"] .badge-muted,
html[data-theme="dark"] .msg-system {
  background: #24261f;
}

html[data-theme="dark"] .msg-tool,
html[data-theme="dark"] .stage {
  background: #23261f;
}

html[data-theme="dark"] .input,
html[data-theme="dark"] .composer-input {
  background: #1b1d19;
  border-color: #3b4036;
}

html[data-theme="dark"] .input:disabled,
html[data-theme="dark"] .composer-input:disabled {
  background: #22241f;
}

html[data-theme="dark"] .ref-bar {
  background: #1f221d;
}

html[data-theme="dark"] .ref-tile img,
html[data-theme="dark"] .sku-media,
html[data-theme="dark"] .tile-preview,
html[data-theme="dark"] .lightbox-img {
  background: #2a2d27;
}

html[data-theme="dark"] .lightbox-body {
  border-color: #4a463d;
}

/* The business-AI launcher is authored with light pill colours. */
html[data-theme="dark"] .bai-launcher {
  background: #22251f;
  border-color: #3d4238;
  color: var(--ink);
}

html[data-theme="dark"] .bai-launcher:hover {
  background: #2a2e27;
  border-color: #4c5347;
}

/* ---------------- white ---------------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-deep: #f5f6f8;
  --paper: #ffffff;
  --paper-2: #fafbfc;
  --ink: #17191c;
  --ink-2: #3d4249;
  --muted: #5c6470;
  --faint: #6f7783;
  --line: #dfe3e8;
  --line-strong: #c6ccd4;
  --pine: #256b57;
  --pine-deep: #1d5545;
  --pine-soft: #eaf3ef;
  --amber: #a15c12;
  --amber-soft: #fdf3e3;
  --danger: #a33a2c;
  --danger-soft: #fdecea;
}

html[data-theme="light"] ::selection {
  background: #dbe7f3;
}

html[data-theme="light"] * {
  scrollbar-color: #c9ced6 transparent;
}

html[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: #c9ced6;
}

html[data-theme="light"] .health.is-ok,
html[data-theme="light"] .alert-ok,
html[data-theme="light"] .badge-pine,
html[data-theme="light"] .badge-ok,
html[data-theme="light"] .ref-counts,
html[data-theme="light"] .test-msg.tone-ok {
  border-color: #cfe3d8;
}

html[data-theme="light"] .health.is-warn,
html[data-theme="light"] .alert-warn,
html[data-theme="light"] .notice-inline,
html[data-theme="light"] .badge-warn,
html[data-theme="light"] .tag-immutable,
html[data-theme="light"] .limit-strip {
  border-color: #ecd6b3;
}

html[data-theme="light"] .alert-danger,
html[data-theme="light"] .badge-danger,
html[data-theme="light"] .job-fail,
html[data-theme="light"] .job-strip.job-failed,
html[data-theme="light"] .test-msg.tone-danger,
html[data-theme="light"] .btn-danger {
  border-color: #f0c9c2;
}

html[data-theme="light"] .inspector {
  background: #ffffff;
}

html[data-theme="light"] .btn,
html[data-theme="light"] .upload-btn,
html[data-theme="light"] .msg-assistant {
  background: #ffffff;
  border-color: #d9dde2;
}

html[data-theme="light"] .btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #c3c9d1;
}

html[data-theme="light"] .badge-ink {
  background: #f1f3f5;
  border-color: #d5dae0;
}

html[data-theme="light"] .badge-pine,
html[data-theme="light"] .badge-ok {
  background: #ecf5f1;
}

html[data-theme="light"] .badge-warn {
  background: #fdf4e5;
}

html[data-theme="light"] .badge-danger {
  background: #fdeeec;
}

html[data-theme="light"] .badge-busy,
html[data-theme="light"] .msg-user,
html[data-theme="light"] .job-strip.job-running,
html[data-theme="light"] .job-strip.job-queued {
  background: #eef4f1;
  border-color: #d3e2da;
}

html[data-theme="light"] .badge-muted,
html[data-theme="light"] .msg-system {
  background: #f3f4f6;
}

html[data-theme="light"] .msg-tool,
html[data-theme="light"] .stage {
  background: #f7f8f9;
}

html[data-theme="light"] .input,
html[data-theme="light"] .composer-input {
  background: #ffffff;
  border-color: #d9dde2;
}

html[data-theme="light"] .input:disabled,
html[data-theme="light"] .composer-input:disabled {
  background: #f3f4f6;
}

html[data-theme="light"] .ref-bar {
  background: #f8f9fa;
}

html[data-theme="light"] .ref-tile img,
html[data-theme="light"] .sku-media,
html[data-theme="light"] .tile-preview,
html[data-theme="light"] .lightbox-img {
  background: #eef0f2;
}


/* Panels authored with light hexes: dark equivalents for their main surfaces. */
html[data-theme="dark"] .bai-root,
html[data-theme="dark"] .ops-root {
  color: var(--ink);
}

html[data-theme="dark"] .bai-main,
html[data-theme="dark"] .bai-side,
html[data-theme="dark"] .bai-steps,
html[data-theme="dark"] .bai-section,
html[data-theme="dark"] .bai-side-block,
html[data-theme="dark"] .bai-side-empty,
html[data-theme="dark"] .bai-side-job,
html[data-theme="dark"] .bai-tool-nav,
html[data-theme="dark"] .bai-banner,
html[data-theme="dark"] .bai-busy,
html[data-theme="dark"] .bai-kv,
html[data-theme="dark"] .bai-empty,
html[data-theme="dark"] .bai-global-banner {
  background: #1d201b;
  border-color: #343a30;
}

html[data-theme="dark"] .bai-step,
html[data-theme="dark"] .bai-btn,
html[data-theme="dark"] .bai-input {
  background: #232621;
  border-color: #3d4238;
  color: var(--ink);
}

html[data-theme="dark"] .ops-config,
html[data-theme="dark"] .ops-report,
html[data-theme="dark"] .ops-incident,
html[data-theme="dark"] .ops-job,
html[data-theme="dark"] .ops-repair,
html[data-theme="dark"] .ops-diff,
html[data-theme="dark"] .ops-verification,
html[data-theme="dark"] .ops-message,
html[data-theme="dark"] .ops-foot,
html[data-theme="dark"] .ops-incident-message,
html[data-theme="dark"] .ops-chip {
  background: #1d201b;
  border-color: #343a30;
  color: var(--ink);
}


html[data-theme="dark"] .bai-tool-nav-item {
  color: var(--ink-2);
  background: transparent;
}

html[data-theme="dark"] .bai-tool-nav-item:hover {
  background: #262a24;
}

html[data-theme="dark"] .bai-tool-nav-item.is-active {
  background: #2a3129;
  color: var(--ink);
}

html[data-theme="dark"] .bai-tool-nav-item.is-active .bai-tool-index {
  color: var(--pine);
}

html[data-theme="dark"] .bai-badge,
html[data-theme="dark"] .bai-global-banner {
  color: var(--ink-2);
}

/* ---------------- switcher ---------------- */
/* Inside the workspace sidebar footer the pill joins the normal flow. */
.rail-foot .theme-switch {
  position: static;
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  box-shadow: none;
}

.theme-switch {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--theme-switch-line);
  border-radius: 999px;
  background: var(--theme-switch-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-family: var(--sans);
}

.theme-switch-label {
  padding: 0 6px 0 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  user-select: none;
}

.theme-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  padding: 3px 10px;
  font-size: 12px;
  line-height: 1.5;
}

.theme-btn:hover {
  background: var(--paper-2);
}

.theme-btn[aria-pressed="true"] {
  background: var(--pine-soft);
  border-color: var(--pine);
  color: var(--pine-deep);
  font-weight: 600;
}

.theme-btn:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 1px;
}

@media (max-width: 640px) {
  .theme-switch {
    top: 8px;
    right: 8px;
  }
  .theme-switch-label {
    display: none;
  }
}
