/* Oakfinance palettes mapped to Oaktrack's shared component tokens. */
:root {
  --bg-subtle: var(--surface);
  --accent-dim: var(--accent-glow);
  --accent-border: color-mix(in srgb, var(--accent) 30%, transparent);
}

:root[data-theme="evergreen-dark"] {
  color-scheme: dark;
}

:root[data-theme="cobalt-dark"] {
  --surface: #0e0f11;
  --surface-2: #16181c;
  --text: #f2f3f5;
  --text-secondary: #9ba1ab;
  --muted: #9ba1ab;
  --control-border: #697382;
  --accent: #5e9bff;
  --accent-hover: #7fb0ff;
  --accent-glow: rgba(94, 155, 255, .14);
  --accent-subtle: rgba(94, 155, 255, .07);
  --on-accent: #06132b;
}

:root[data-theme="brass-dark"] {
  --surface: #100e0b;
  --surface-2: #1a1712;
  --text: #f5f3ef;
  --text-secondary: #a8a39a;
  --muted: #a8a39a;
  --control-border: #7a7265;
  --accent: #d9a441;
  --accent-hover: #eabc6a;
  --accent-glow: rgba(217, 164, 65, .13);
  --accent-subtle: rgba(217, 164, 65, .06);
  --on-accent: #241a04;
}

:root[data-theme="slate-dark"] {
  --surface: #101010;
  --surface-2: #191919;
  --border: rgba(255, 255, 255, .09);
  --divider: rgba(255, 255, 255, .055);
  --text: #f4f4f4;
  --text-secondary: #a3a3a3;
  --muted: #a3a3a3;
  --control-border: #737373;
  --accent: #e5e5e5;
  --accent-hover: #ffffff;
  --accent-glow: rgba(255, 255, 255, .1);
  --accent-subtle: rgba(255, 255, 255, .05);
  --on-accent: #111111;
}

:root[data-theme$="-light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface-hover: rgba(0, 0, 0, .04);
  --border: rgba(0, 0, 0, .1);
  --divider: rgba(0, 0, 0, .06);
  --border-strong: rgba(0, 0, 0, .16);
  --control-border: #7a817c;
  --muted: var(--text-secondary);
  --on-accent: #ffffff;
  --shadow: 0 16px 64px rgba(0, 0, 0, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .08);
  /* Endpoint health retains its meaning across every accent palette. */
  --success: #0c7547;
  --success-bg: rgba(12, 117, 71, .1);
  --warning: #80580a;
  --warning-bg: rgba(148, 105, 15, .12);
  --error: #b23430;
  --error-bg: rgba(194, 67, 60, .1);
  --chart-grid: rgba(0, 0, 0, .1);
}

:root[data-theme="evergreen-light"] {
  --surface: #f5f6f5;
  --surface-2: #ebeeed;
  --text: #191b19;
  --text-secondary: #5d635e;
  --accent: #0c7347;
  --accent-hover: #0c6a41;
  --accent-glow: rgba(16, 128, 79, .1);
  --accent-subtle: rgba(16, 128, 79, .05);
}

:root[data-theme="cobalt-light"] {
  --surface: #f3f4f6;
  --surface-2: #e8eaee;
  --text: #181a1e;
  --text-secondary: #585e68;
  --control-border: #777e89;
  --accent: #225bd3;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, .1);
  --accent-subtle: rgba(37, 99, 235, .05);
}

:root[data-theme="brass-light"] {
  --bg: #fffdf9;
  --surface: #f8f4ec;
  --surface-2: #efe8da;
  --text: #23201a;
  --text-secondary: #6d675c;
  --control-border: #837b6c;
  --accent: #865d14;
  --accent-hover: #86600f;
  --accent-glow: rgba(162, 116, 28, .12);
  --accent-subtle: rgba(162, 116, 28, .06);
}

:root[data-theme="slate-light"] {
  --surface: #f4f4f4;
  --surface-2: #e8e8e8;
  --border: rgba(0, 0, 0, .11);
  --divider: rgba(0, 0, 0, .07);
  --text: #171717;
  --text-secondary: #5f5f5f;
  --control-border: #7a7a7a;
  --accent: #171717;
  --accent-hover: #000000;
  --accent-glow: rgba(0, 0, 0, .08);
  --accent-subtle: rgba(0, 0, 0, .04);
}

/* Replace evergreen-only decoration while preserving semantic status colors. */
.mode-guidance,
.mode-content,
.selector-tester,
.category-chip--active,
.message-info,
.message-debug {
  border-color: var(--accent-border);
}

.selector-tester-inline-hint {
  background: var(--accent-subtle);
}

:root[data-theme$="-light"] .uptime-heartbeat-cell--success { background: var(--success); }
:root[data-theme$="-light"] .uptime-heartbeat-cell--warning { background: var(--warning); }
:root[data-theme$="-light"] .uptime-heartbeat-cell--danger { background: var(--error); }

.theme-picker-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-picker-fieldset legend {
  padding: 0;
  color: var(--text);
  font-size: .875rem;
  font-weight: 600;
}

.theme-picker-help {
  margin: .4rem 0 1rem;
  color: var(--text-secondary);
}

.theme-save-status:not(:empty) { margin-top: 1rem; }

.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .875rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
  padding: .5rem;
  overflow: hidden;
  border: 1px solid var(--control-border);
  background: var(--surface);
  text-align: left;
}

.theme-option:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.theme-option[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: var(--accent-subtle);
}

.theme-preview {
  display: flex;
  gap: .6rem;
  height: 88px;
  padding: .65rem;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 5px;
  background: var(--preview-background);
  --preview-line: rgba(255, 255, 255, .18);
}

.theme-preview--light {
  border-color: rgba(0, 0, 0, .14);
  --preview-line: rgba(0, 0, 0, .18);
}

.theme-preview-sidebar {
  display: grid;
  align-content: start;
  gap: .45rem;
  width: 18%;
  padding-top: .15rem;
}

.theme-preview-sidebar i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--preview-line);
}

.theme-preview-sidebar i:first-child {
  background: var(--preview-accent);
}

.theme-preview-content {
  display: grid;
  flex: 1;
  gap: .4rem;
  min-width: 0;
}

.theme-preview-content > i {
  width: 60%;
  height: 4px;
  border-radius: 2px;
  background: var(--preview-line);
}

.theme-preview-content > span {
  display: flex;
  gap: .35rem;
}

.theme-preview-content > span i {
  flex: 1;
  border: 1px solid var(--preview-line);
  border-radius: 3px;
  background: var(--preview-surface);
}

.theme-preview-content > b {
  width: 45%;
  height: 7px;
  border-radius: 2px;
  background: var(--preview-accent);
}

.theme-option-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  padding: .7rem .25rem .2rem;
}

.theme-option-caption strong {
  display: block;
  color: var(--text);
  font-size: .8125rem;
  font-weight: 600;
}

.theme-option-mode {
  display: block;
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 400;
}

.theme-option-indicator {
  display: grid;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--control-border);
  border-radius: 50%;
  font-size: .75rem;
}

.theme-option[aria-pressed="true"] .theme-option-indicator {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.theme-option-status {
  padding: .2rem .25rem .1rem;
  color: var(--text-secondary);
  font-size: .6875rem;
  font-weight: 400;
}

.theme-option[aria-pressed="true"] .theme-option-status {
  color: var(--accent);
}

@media (max-width: 720px) {
  .theme-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .theme-option { transition: none; }
  .theme-option:active { transform: none; }
}
