/* Theme switch: light preserves the existing design; dark uses explicit surfaces. */
.theme-toggle { display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:38px;white-space:nowrap; }
.theme-toggle svg { flex-shrink:0; }
.login-theme-toggle { position:fixed;right:20px;top:20px;z-index:10; }
html[data-theme="light"] { color-scheme:light; }
html[data-theme="dark"] {
  color-scheme:dark;
  --bg:#101015;--white:#171b20;--ink:#ececf5;--muted:#a4acbd;
  --line:#30383f;--blue:#a78bfa;--blue-dark:#c4b5fd;--navy:#d9dfef;
  --green:#7bdfb3;--green-bg:#163b33;--amber:#f5ce83;--amber-bg:#40341e;
  --red:#ffaaa6;--red-bg:#42252d;--shadow:0 5px 22px rgba(0,0,0,.16);
  background:var(--bg);color:var(--ink);
}
html[data-theme="dark"] body { background:var(--bg);color:var(--ink); }
html[data-theme="dark"] :is(.sidebar,.topbar) { background:#111217;border-color:var(--line); }
html[data-theme="dark"] :is(.panel,.login-card,.compose-workspace,.compose-preview,.proxy-form,.settings-list,.page-card,.batch-card,.batch-page-row,.preview-card,.picker-modal-box,.page-picker-menu,.page-row-menu,.table-wrap) { background:#171b20;border-color:var(--line);color:var(--ink); }
html[data-theme="dark"] :is(.page-picker-toggle,.media-box,.customize-panel,.batch-preview,.batch-details,.settings-connection,.auto-posttype-note,.batch-progress,.preview-comment,.customize-tab) { background:#1b2227;border-color:var(--line);color:#c5cfd9; }
html[data-theme="dark"] :is(h1,h2,h3,h4,.panel h2,.intro h1,.compose-workspace h2,.page-name,.preview-page strong,.login-card .brand strong,.form-section-heading strong,.proxy-form>strong,.batch-page-option strong,.batch-details-heading,.connection-summary strong) { color:#f5f3ff; }
html[data-theme="dark"] :is(.subtitle,.eyebrow,.user-label,.stat-label,.empty,.form-hint,.panel-footer,.login-note,.login-card .login-note,.login-card .brand span,.connection-summary-label,.timezone-note,.toolbar .timezone-note,.form-section-heading span,.proxy-form>.form-hint,.fanpage-count,.preview-page small,.preview-heading small,.preview-card>p,.preview-empty,.preview-actions,.settings-list small,.page-meta,.batch-details small,.auto-posttype-note) { color:#a9b0c3; }
html[data-theme="dark"] :is(label,.shared-fields>label,.shared-media-comment label,.customize-panel label,.schedule-controls label,.form-grid>label,.toolbar>label,.time-12h label) { color:#c3c9d8; }
html[data-theme="dark"] :is(.nav-item,.tab,.view-tab,.compose-tab) { color:#bbc1d3; }
html[data-theme="dark"] :is(.nav-item:hover,.nav-item.active,.tab.active,.view-tab.active,.compose-tab.active,.customize-tab.active,.batch-page-option.selected,.batch-page-option:hover,.batch-page-row.selected) { background:#293036;color:#83e8d1;border-color:#4a6362; }
html[data-theme="dark"] .nav-item.active svg { color:#bc9dff; }
html[data-theme="dark"] .stat { background:linear-gradient(115deg,#20252d,#171b20);border-color:#344447; }
html[data-theme="dark"] :is(.stat-value,.intro-note strong,.schedule-preview) { color:#f2f0fb; }
html[data-theme="dark"] :is(.intro-note,[data-section-panel="settings"] .connection-summary) { background:linear-gradient(110deg,#1c2629,#171d21);border-color:#344447; }
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),textarea,select) { background-color:#111518;color:#ececf5;border-color:#3b474d; }
html[data-theme="dark"] :is(input,textarea)::placeholder { color:#929bab; }
html[data-theme="dark"] :is(input,textarea,select):focus { border-color:#8b5cf6;box-shadow:0 0 0 3px rgba(139,92,246,.22);outline:none; }
html[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"]) { accent-color:#a78bfa; }
html[data-theme="dark"] input[type="file"] { color:#c3c9d8; }
html[data-theme="dark"] input[type="file"]::file-selector-button { background:#243337;color:#beeddf;border-color:#4a6362; }
html[data-theme="dark"] :is(.button.secondary,.mini-button,.row-action,.page-picker-toggle) { background:#20272c;border-color:#3b4c50;color:#e0e5ed; }
html[data-theme="dark"] :is(.button.secondary:hover,.mini-button:hover,.row-action:hover,.page-picker-toggle:hover,.page-row-menu button:hover) { background:#2c3b3e;border-color:#61817b; }
html[data-theme="dark"] .button.primary { background:#7c3aed;color:#fff;box-shadow:none; }
html[data-theme="dark"] .button.primary:hover { background:#8544ef; }
html[data-theme="dark"] :is(.link-button,.preview-heading,.page-row-menu button) { color:#83e8d1; }
html[data-theme="dark"] table { background:#171b20;color:var(--ink); }
html[data-theme="dark"] :is(th,.page-table th) { background:#20262d;color:#aeb6c8;border-color:var(--line); }
html[data-theme="dark"] td { color:#e1e4ee;border-color:#293238; }
html[data-theme="dark"] tbody tr:nth-child(even) { background:#1a2025; }
html[data-theme="dark"] tbody tr:hover { background:#253035; }
/* Page names stay dark in light mode and become readable in dark mode. */
html[data-theme="dark"] .page-table :is(.page-row-name,a.page-row-name:visited,a.page-row-name:hover) { color:#f5f3ff!important; }
html[data-theme="dark"] :is(.page-avatar,.page-avatar-img) { background:#2a373b;color:#d2e8e0; }
html[data-theme="dark"] :is(.tag.success,.notice.success) { background:#163b33;color:#8ce7bd;border-color:#2c6655; }
html[data-theme="dark"] :is(.tag.pending,.notice.warning) { background:#40341e;color:#f5ce83;border-color:#72562c; }
html[data-theme="dark"] :is(.tag.error,.notice.error,.button.danger,.mini-button.danger) { background:#42252d;color:#ffaaa6;border-color:#79414a; }
html[data-theme="dark"] :is(.button.danger:hover,.mini-button.danger:hover,.page-row-menu button.danger:hover) { background:#59303a;color:#ffc0bc; }
html[data-theme="dark"] :is(.tag.muted,.status-pill.muted) { background:#2a3036;color:#c0c6d4; }
html[data-theme="dark"] :is(.notice.info,.page-status) { background:#1f3557;color:#a3e9dc;border-color:#3e5756; }
html[data-theme="dark"] :is(.error-text,.page-row-menu button.danger) { color:#ffaaa6; }
html[data-theme="dark"] .picker-modal { background:rgba(0,0,0,.65); }
html[data-theme="dark"] .login-page { background:linear-gradient(140deg,#101015,#17141f); }
html[data-theme="dark"] :is(.login-card .login-note,.preview-actions,.preview-heading,.customize-area,.batch-details,.settings-list>div) { border-color:var(--line); }
/* Analytics retains its own hierarchy and status palette. */
html[data-theme="dark"] .analytics-scope { background:#171b20;color:#ececf5;border-color:var(--line); }
html[data-theme="dark"] .analytics-scope .analytics-heading h2 { color:#f5f3ff; }
html[data-theme="dark"] .analytics-scope :is(.analytics-toolbar label,.analytics-cache,.analytics-connection .subtitle,.analytics-unassigned,.analytics-pagination) { color:#a5b3c3; }
html[data-theme="dark"] .analytics-scope .analytics-connection .button { color:#e0e5ed;background:#20272c;border-color:#3b4c50; }
html[data-theme="dark"] .analytics-scope .analytics-toolbar :is(input,select) { background:#111518;color:#ececf5;border-color:#3b474d; }
html[data-theme="dark"] .analytics-scope .analytics-summary { background:linear-gradient(110deg,#1b2b2c,#171d21);border-color:#35504c; }
html[data-theme="dark"] .analytics-scope :is(.analytics-summary-main>span,.analytics-summary-meta small) { color:#a5bfc0; }
html[data-theme="dark"] .analytics-scope .analytics-summary-main>strong { color:#5de0bd; }
html[data-theme="dark"] .analytics-scope .analytics-summary-meta { color:#d4e5e2; }
html[data-theme="dark"] .analytics-scope .analytics-data-badge { background:#163b33;color:#8ce7bd; }
html[data-theme="dark"] .analytics-scope .analytics-data-badge.incomplete { background:#40341e;color:#f5ce83; }
html[data-theme="dark"] .analytics-scope :is([data-analytics-table],table.analytics-table,.analytics-kpi,.analytics-chart) { background:#171b20;color:#ececf5;border-color:var(--line); }
html[data-theme="dark"] .analytics-scope table.analytics-table th { background:#20262d;color:#afb9c9;border-color:var(--line); }
html[data-theme="dark"] .analytics-scope table.analytics-table td { color:#ececf5;border-color:#293238; }
html[data-theme="dark"] .analytics-scope table.analytics-table tbody tr:nth-child(even) { background:#1a2025; }
html[data-theme="dark"] .analytics-scope table.analytics-table tbody tr:hover { background:#253035; }
html[data-theme="dark"] .analytics-scope .analytics-views { color:#f5f3ff; }
html[data-theme="dark"] .analytics-scope .analytics-code { background:#163b36;border-color:#3a655b;color:#8eecd3; }
html[data-theme="dark"] .analytics-scope .analytics-code:hover { background:#215047; }
html[data-theme="dark"] .analytics-scope .analytics-rank { color:#abb9c9; }
html[data-theme="dark"] .analytics-scope .analytics-rank-1 { background:#59451e;color:#ffe1a1; }
html[data-theme="dark"] .analytics-scope .analytics-rank-2 { background:#3a414a;color:#e2e6ee; }
html[data-theme="dark"] .analytics-scope .analytics-rank-3 { background:#55392b;color:#ffd0b1; }
html[data-theme="dark"] .analytics-scope .analytics-notice { background:#223031;color:#dae7e2; }
html[data-theme="dark"] .analytics-scope .analytics-notice.error { background:#42252d;color:#ffaaa6; }
html[data-theme="dark"] .analytics-scope .analytics-notice.mock { background:#40341e;color:#f5ce83; }
@media(max-width:650px) {
  .theme-toggle { min-width:38px;padding:8px; }
  .login-theme-toggle { top:12px;right:12px; }
}

/* Charcoal, mint and violet accents from the supplied reference. */
html[data-theme="dark"] body {
  background:radial-gradient(ellipse at 12% 0%,rgba(20,184,166,.045),transparent 42%),radial-gradient(ellipse at 90% 0%,rgba(124,58,237,.045),transparent 45%),#101015;
}
html[data-theme="dark"] .brand-mark { background:linear-gradient(140deg,#a855f7,#6d28d9);box-shadow:0 0 14px rgba(139,92,246,.17); }
html[data-theme="dark"] .nav-item.active { background:linear-gradient(100deg,#223432,#27242e);color:#f5f3ff;box-shadow:inset 3px 0 #9b6bff; }
html[data-theme="dark"] .nav-item.active svg { color:#bf9aff; }
html[data-theme="dark"] .stat { position:relative;overflow:hidden;background:linear-gradient(145deg,#1f2930,#15131e 70%);border-color:#354044; }
html[data-theme="dark"] .stat::before { content:"";position:absolute;inset:0 0 auto;height:2px;background:linear-gradient(90deg,#10bfa2,#8b5cf6); }
html[data-theme="dark"] .stat:nth-child(2)::before { background:#06b6d4; }
html[data-theme="dark"] .stat:nth-child(3)::before { background:#10b981; }
html[data-theme="dark"] .stat:nth-child(4)::before { background:#f59e0b; }
html[data-theme="dark"] .stat-value { color:#f5f3ff; }
html[data-theme="dark"] :is(.panel,.proxy-form,.settings-list,.compose-workspace,.compose-preview) { box-shadow:0 4px 18px rgba(0,0,0,.12); }
html[data-theme="dark"] .analytics-scope .analytics-summary { background:linear-gradient(110deg,#1b302d,#191923);border-color:#35514a; }
html[data-theme="dark"] .analytics-scope .analytics-summary-main>strong { color:#72e4c3; }
html[data-theme="dark"] :is(.intro-note strong,.schedule-preview) { color:#76e1c6; }
html[data-theme="dark"] .page-picker-toggle:hover { color:#e0e5ed; }

/* Sliding switch: keep the same thumb node so CSS can animate both directions. */
.button.theme-toggle {
  position:relative;display:inline-block;flex:0 0 64px;width:64px;height:34px;
  min-height:34px;min-width:64px;padding:0;border:1px solid #c7d3e6;
  border-radius:999px;background:#e3eaf4;vertical-align:middle;
  box-shadow:inset 0 1px 3px rgba(15,23,42,.08);
  transition:background .22s ease,border-color .22s ease;
}
.button.theme-toggle:hover { background:#d8e3f4;border-color:#a5b9db; }
.button.theme-toggle .theme-switch-thumb {
  position:absolute;display:block;left:3px;top:3px;width:26px;height:26px;
  border-radius:50%;background:#fff;box-shadow:0 1px 4px rgba(15,23,42,.2);
  transform:translateX(0);transition:transform .22s ease,background .22s ease;
  pointer-events:none;
}
.button.theme-toggle .theme-switch-thumb svg {
  position:absolute;left:4.5px;top:4.5px;transition:opacity .18s ease;
}
.button.theme-toggle .theme-switch-sun { color:#9a6500;opacity:1; }
.button.theme-toggle .theme-switch-moon { color:#f1e8ff;opacity:0; }
html[data-theme="dark"] .button.theme-toggle { background:linear-gradient(100deg,#254d48,#67459a);border-color:#79659e; }
html[data-theme="dark"] .button.theme-toggle:hover { border-color:#b799e7; }
html[data-theme="dark"] .button.theme-toggle .theme-switch-thumb { transform:translateX(30px);background:#332243; }
html[data-theme="dark"] .button.theme-toggle .theme-switch-sun { opacity:0; }
html[data-theme="dark"] .button.theme-toggle .theme-switch-moon { opacity:1; }
.button.theme-toggle:focus-visible { outline:2px solid #8b5cf6;outline-offset:3px; }
@media(prefers-reduced-motion:reduce) {
  .button.theme-toggle,.button.theme-toggle .theme-switch-thumb,.button.theme-toggle .theme-switch-thumb svg { transition:none; }
}
.button.login-theme-toggle { position:fixed;right:20px;top:20px; }
@media(max-width:650px) { .button.login-theme-toggle { right:12px;top:12px; } }
