diff --git a/app/templates/base.html b/app/templates/base.html
index 01b5e51..2ce1902 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -1001,12 +1001,12 @@
}, 300);
});
- // Apply saved theme on page load
- (function() {
+ // Apply saved theme on page load (AND on bfcache restore)
+ function applySavedTheme() {
var saved = localStorage.getItem('fd_theme') || 'dark';
+ var h = document.documentElement;
+ h.setAttribute('data-theme', saved);
if (saved === 'light') {
- var h = document.documentElement;
- h.setAttribute('data-theme', 'light');
h.style.setProperty('--bg-primary', '#FFFFFF');
h.style.setProperty('--bg-secondary', '#F7F6F3');
h.style.setProperty('--bg-tertiary', '#EDECE9');
@@ -1015,8 +1015,18 @@
h.style.setProperty('--text-dim', '#9B9A97');
h.style.setProperty('--border', '#E0DFDC');
h.style.setProperty('--border-strong', '#CCCBC8');
+ } else {
+ // Remove light overrides, use CSS defaults
+ ['bg-primary','bg-secondary','bg-tertiary','text','text-secondary','text-dim','border','border-strong'].forEach(function(v) {
+ h.style.removeProperty('--'+v);
+ });
}
- })();
+ }
+ applySavedTheme();
+ // Re-apply when page is restored from bfcache (e.g. browser back button)
+ window.addEventListener('pageshow', function(e) {
+ if (e.persisted) applySavedTheme();
+ });
{% block scripts %}{% endblock %}