// ========== THEME PICKER + THEME BUILDER ========== (function () { var themeBeforeBuilder = null; var editingSlug = null; var advancedOverrides = {}; // tracks which advanced fields user manually changed // Display names for built-in themes var THEME_LABELS = { dark: 'Dark', light: 'Light', blue: 'Blue', black: 'Black', nord: 'Nord', dracula: 'Dracula', 'solarized-dark': 'Solarized Dark', 'solarized-light': 'Solarized Light', taxi: 'Taxi', ocean: 'Ocean', }; // Color picker field definitions: [css-prop, label, section] var FIELDS = [ ['bg', 'Background', 'base'], ['card-base', 'Card', 'base'], ['fg', 'Text', 'base'], ['muted', 'Muted Text', 'base'], ['border', 'Border', 'base'], ['accent', 'Accent', 'accent'], ['accent-strong', 'Accent Strong', 'accent'], ['ok-bg', 'OK Background', 'status'], ['ok-fg', 'OK Text', 'status'], ['bad-bg', 'Error Bg', 'status'], ['bad-fg', 'Error Text', 'status'], ['dot-ok', 'Dot OK', 'status'], ['dot-bad', 'Dot Error', 'status'], ['uptime', 'Uptime Bar', 'status'], ['hover', 'Hover', 'advanced'], ['card-hover', 'Card Hover', 'advanced'], ['base', 'Tags/Badges', 'advanced'], ['fg-muted', 'Dim Text', 'advanced'], ['success', 'Success', 'advanced'], ['error', 'Error', 'advanced'], ['warning', 'Warning', 'advanced'], ]; // ─── Theme Cycle Button ─────────────────────────────── var themeBtn = document.getElementById('theme'); if (!themeBtn) return; var themeLabel = document.getElementById('theme-label'); function getLabelFor(t) { if (THEME_LABELS[t]) return THEME_LABELS[t]; var userThemes = safeGetJSON(window.USER_THEMES_KEY, {}); if (userThemes[t]) return userThemes[t].name || t; return t; } function updateLabel() { if (themeLabel) themeLabel.textContent = getLabelFor(window.getActiveTheme()); } themeBtn.addEventListener('click', function () { var list = window.THEMES.slice(); var current = window.getActiveTheme(); var idx = list.indexOf(current); var next = list[(idx + 1) % list.length]; window.applyTheme(next); updateLabel(); }); updateLabel(); // ─── Theme Builder Modal ─────────────────────────────── function buildFieldsHTML() { var sections = { base: 'Base Colors', accent: 'Accent', status: 'Status', advanced: 'Advanced (auto-derived)' }; var grouped = {}; FIELDS.forEach(function (f) { if (!grouped[f[2]]) grouped[f[2]] = []; grouped[f[2]].push(f); }); var html = ''; Object.keys(sections).forEach(function (key) { if (key === 'advanced') { html += '
Show advanced colors ▼
'; html += '