:root {
    /* Core theme colors */
    --bg: #111;
    --fg: #eee;
    --accent: #ff8c00;

    /* Additional UI variables */
    --card-bg: #111;
    --border: var(--accent);
    --button-bg: transparent;
    --button-text: var(--accent);
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #000;

    --input-bg: black;
    --input-text: var(--fg);
    --input-border: var(--accent);

    --status-on: #00b33c;
    --status-off: #b30000;

    --bar-bg: #111;
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(to right, #ac0707, #3c9f05);

    --glow-strength: 0;
    --scanline-opacity: 0;
    --grain-opacity: 0;
}

.theme-dark {
    --bg: #111;
    --fg: #eee;
    --accent: #b66b13;

    --card-bg: #181818;
    --border: var(--accent);

    --button-text: var(--accent);
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #000;

    --input-bg: #000;
    --input-text: var(--accent);
    --input-border: var(--accent);

    --status-on: #16d95f;
    --status-off: #d92b2b;

    --bar-bg: #111;
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(to right, #8a0000, #4caf50);
}

body.theme-dark {
    --glow-strength: 0.15;
}

body.theme-dark * {
    text-shadow: 0 0 4px rgba(182, 107, 19, var(--glow-strength));
}

body.theme-dark {
    background-image:
            radial-gradient(circle at top, rgba(255,255,255,0.03), transparent 40%);
}

.theme-light {
    --bg: #f4f4f4;
    --fg: #111;
    --accent: #0077ff;

    --card-bg: #fff;
    --border: #0077ff;

    --button-text: #0077ff;
    --button-border: #0077ff;
    --button-hover-bg: #0077ff;
    --button-hover-text: white;

    --input-bg: #fff;
    --input-text: #003366;
    --input-border: #0077ff;

    --status-on: #00b33c;
    --status-off: #cc0000;

    --bar-bg: #fff;
    --bar-border: #0077ff;
    --bar-gradient: linear-gradient(to right, #ff6666, #66cc66);
}

body.theme-light {
    background-image:
            linear-gradient(
                    rgba(0,0,0,0.02),
                    rgba(0,0,0,0.02)
            );
}

.theme-solar {
    --bg: #002b36;
    --fg: #eee8d5;
    --accent: #b58900;

    --card-bg: #073642;
    --border: #b58900;

    --button-text: #b58900;
    --button-border: #b58900;
    --button-hover-bg: #b58900;
    --button-hover-text: #002b36;

    --input-bg: #073642;
    --input-text: #eee8d5;
    --input-border: #b58900;

    --status-on: #859900;
    --status-off: #dc322f;

    --bar-bg: #073642;
    --bar-border: #b58900;
    --bar-gradient: linear-gradient(to right, #dc322f, #859900);
}

.theme-neon {
    --bg: #000000;
    --fg: #39ff14;
    --accent: #ff009d;

    --card-bg: #0d0d0d;
    --border: #ff009d;

    --button-text: #ff009d;
    --button-border: #ff009d;
    --button-hover-bg: #ff009d;
    --button-hover-text: black;

    --input-bg: #000000;
    --input-text: #39ff14;
    --input-border: #ff009d;

    --status-on: #39ff14;
    --status-off: #ff0048;

    --bar-bg: #000;
    --bar-border: #ff009d;
    --bar-gradient: linear-gradient(to right, #ff0048, #39ff14);
}

body.theme-neon * {
    text-shadow:
            0 0 6px currentColor,
            0 0 12px currentColor,
            0 0 24px rgba(255, 0, 157, 0.6);
}

body.theme-neon {
    background-image:
            radial-gradient(circle at center, rgba(255,0,157,0.1), transparent 60%);
}

.theme-terminal {
    --bg: #001100;
    --fg: #00ff6a;
    --accent: #00ff6a;

    --card-bg: #002200;
    --border: #00ff6a;

    --button-text: #00ff6a;
    --button-border: #00ff6a;
    --button-hover-bg: #00ff6a;
    --button-hover-text: #001100;

    --input-bg: #000;
    --input-text: #00ff6a;
    --input-border: #00ff6a;

    --status-on: #00ff6a;
    --status-off: #993333;

    --bar-bg: #002200;
    --bar-border: #00ff6a;
    --bar-gradient: linear-gradient(to right, #993333, #00ff6a);
}

body.theme-terminal * {
    text-shadow: 0 0 5px rgba(0, 255, 106, 0.5);
}

body.theme-terminal {
    animation: terminal-flicker 6s infinite;
}

@keyframes terminal-flicker {
    0%, 100% { filter: brightness(1); }
    98% { filter: brightness(0.98); }
}

.theme-midnight {
    --bg: #0e001a;
    --fg: #d9b3ff;
    --accent: #9b4dff;

    --card-bg: #1a0033;
    --border: #9b4dff;

    --button-text: #d9b3ff;
    --button-border: #9b4dff;
    --button-hover-bg: #9b4dff;
    --button-hover-text: #0e001a;

    --input-bg: #150026;
    --input-text: #d9b3ff;
    --input-border: #9b4dff;

    --status-on: #5cffc1;
    --status-off: #ff4da6;

    --bar-bg: #1a0033;
    --bar-border: #9b4dff;
    --bar-gradient: linear-gradient(to right, #ff4da6, #5cffc1);
}

body.theme-midnight * {
    text-shadow:
            0 0 6px rgba(155, 77, 255, 0.4),
            0 0 12px rgba(155, 77, 255, 0.2);
}

body.theme-midnight {
    background-image:
            radial-gradient(circle at 20% 10%, rgba(155,77,255,0.08), transparent 50%),
            radial-gradient(circle at 80% 90%, rgba(92,255,193,0.05), transparent 50%);
}

.theme-trans {
    --bg: #55CDFC;
    --fg: #FFFFFF;
    --accent: #D98CA0;

    /* Slightly darkened versions for usability */
    --bg-dark: #3AAED3;      /* darker blue for cards */
    --pink-dark: #D98CA0;    /* darker pink, better for borders */

    /* UI Variables */
    --card-bg: var(--accent);
    --border: var(--fg);

    /* Buttons */
    --button-bg: var(--pink-dark);
    --button-text: var(--fg);
    --button-border: var(--fg);
    --button-hover-bg: var(--fg);
    --button-hover-text: var(--bg);

    /* Inputs */
    --input-bg: #ffffff;
    --input-text: #333;
    --input-border: var(--pink-dark);

    /* Status Lights */
    --status-on: #2ecc71;     /* Balanced green */
    --status-off: #e74c3c;

    /* Loading bar */
    --bar-bg: var(--bg-dark);
    --bar-border: var(--pink-dark);
    --bar-gradient: linear-gradient(
            to right,
            #55CDFC, #F7A8B8, #ffffff, #F7A8B8, #55CDFC
    );
}

.theme-ace {
    /* Primary flag-inspired palette */
    --bg: #800080;        /* Purple background */
    --fg: #FFFFFF;        /* Main text */
    --accent: #A3A3A3;    /* Gray accent */

    /* Additional derived values */
    --bg-dark: #5A005A;   /* Darker purple for cards */
    --gray-dark: #7A7A7A; /* Stronger gray for borders */

    /* UI Variables */
    --card-bg: var(--bg-dark);
    --border: var(--gray-dark);

    /* Buttons */
    --button-bg: var(--accent);
    --button-text: #000000;     /* You requested black text */
    --button-border: #000000;
    --button-hover-bg: #000000;
    --button-hover-text: var(--accent);

    /* Inputs */
    --input-bg: #ffffff;
    --input-text: #000;
    --input-border: var(--accent);

    /* Status Lights */
    --status-on: #3bd95f;   /* soft green looks good on purple */
    --status-off: #c0392b;

    /* Loading bar — full ace flag sweep */
    --bar-bg: var(--bg-dark);
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #000000, #A3A3A3, #FFFFFF, #800080,
            #000000, #A3A3A3, #FFFFFF, #800080
    );
}

.theme-bi {
    /* Base flag-inspired palette */
    --bg: #D60270;        /* Pink overall background */
    --fg: #FFFFFF;        /* White text to contrast pink */
    --accent: #9B4F96;    /* Purple accent */

    /* Darker panel + accent variations */
    --blue-bg: #0038A8;      /* Bi blue for cards */
    --blue-dark: #002E86;    /* Slightly darker blue */
    --purple-dark: #7F3A7A;  /* Slightly muted purple */

    /* Core UI */
    --card-bg: var(--blue-bg);
    --border: var(--accent);      /* Purple borders */

    /* Buttons */
    --button-bg: var(--blue-dark);       /* Purple */
    --button-text: #FFFFFF;
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #FFFFFF;

    /* Inputs */
    --input-bg: #ffffff;
    --input-text: #000;
    --input-border: var(--accent);

    /* Status Lights */
    --status-on: #2ecc71;
    --status-off: #e74c3c;

    /* Bi flag gradient loading bar */
    --bar-bg: var(--blue-dark);
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #D60270,
            #9B4F96,
            #0038A8,
            #9B4F96,
            #D60270
    );
}

.theme-lesbian {
    /* Base flag-inspired palette */
    --bg: #D52D00;        /* Dark orange overall background */
    --fg: #FFFFFF;        /* White text for maximum contrast */
    --accent: #A30262;    /* Dark rose accent */

    /* Layered panel colors from the flag */
    --orange-panel: #EF7627;       /* Orange (panels) */
    --light-orange-panel: #FF9A56; /* Light orange (cards) */
    --pink-panel: #D162A4;         /* Pink (inputs/buttons) */

    /* Darker/muted variations for usability */
    --orange-dark: #B64000;        /* Darkened orange */
    --pink-dark: #B55690;          /* Dusty pink */
    --rose-dark: #7A014A;          /* Deepened dark rose */

    /* Core UI */
    --card-bg: var(--light-orange-panel);
    --border: var(--accent);       /* Dark rose borders */

    /* Buttons */
    --button-bg: var(--pink-dark);
    --button-text: #FFFFFF;
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #FFFFFF;

    /* Inputs */
    --input-bg: var(--pink-panel);
    --input-text: #FFFFFF;
    --input-border: var(--accent);

    /* Status Lights */
    --status-on: #2ecc71;
    --status-off: #e74c3c;

    /* Lesbian flag gradient loading bar */
    --bar-bg: var(--orange-dark);
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #D52D00,
            #EF7627,
            #FF9A56,
            #FFFFFF,
            #D162A4,
            #B55690,
            #A30262
    );
}

.theme-ocean {
    --bg: #041f2e;
    --fg: #e6f7ff;
    --accent: #1ccad8;

    --card-bg: #06344f;
    --border: var(--accent);

    --button-text: var(--accent);
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #041f2e;

    --input-bg: #041f2e;
    --input-text: #e6f7ff;
    --input-border: var(--accent);

    --status-on: #2ecc71;
    --status-off: #e74c3c;

    --bar-bg: #06344f;
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #0a3d62,
            #1ccad8,
            #6fffe9
    );

}

body.theme-ocean {
    background:
            linear-gradient(
                    120deg,
                    #041f2e,
                    #06344f,
                    #0a3d62,
                    #1ccad8,
                    #06344f,
                    #041f2e
            );
    background-size: 300% 300%;
    animation: ocean-drift 45s ease-in-out infinite;
}

@keyframes ocean-drift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body.theme-ocean::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
            circle at 20% 30%,
            rgba(28, 202, 216, 0.12),
            transparent 55%
    ),
    radial-gradient(
            circle at 80% 70%,
            rgba(10, 61, 98, 0.18),
            transparent 60%
    );
    animation: ocean-glow 60s ease-in-out infinite alternate;
    z-index: -1;
}
@keyframes ocean-glow {
    from {
        transform: translateY(0) translateX(0);
    }
    to {
        transform: translateY(-40px) translateX(30px);
    }
}

.theme-sunset {
    --bg: #2b0f1e;
    --fg: #fff1e6;
    --accent: #ff6b35;

    --card-bg: #3d142b;
    --border: var(--accent);

    --button-text: var(--accent);
    --button-border: var(--accent);
    --button-hover-bg: var(--accent);
    --button-hover-text: #2b0f1e;

    --input-bg: #2b0f1e;
    --input-text: #fff1e6;
    --input-border: var(--accent);

    --status-on: #f7c948;
    --status-off: #e63946;

    --bar-bg: #3d142b;
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #ff4500,
            #ff6b35,
            #f7c948
    );

}

.theme-sunset #page {
    background-color: var(--bg);
    background-image:
            radial-gradient(circle at bottom,
            rgba(255,107,53,0.15),
            transparent 60%);
    background-repeat: no-repeat;
    background-size: cover;
}

.theme-cyberpunk {
    --bg: #0b0014;
    --fg: #f8f7ff;
    --accent: #ff2bdc;

    --card-bg: #160026;
    --border: #00fff0;

    --button-text: #ff2bdc;
    --button-border: #00fff0;
    --button-hover-bg: #00fff0;
    --button-hover-text: #0b0014;

    --input-bg: #0b0014;
    --input-text: #f8f7ff;
    --input-border: #ff2bdc;

    --status-on: #00fff0;
    --status-off: #ff3864;

    --bar-bg: #160026;
    --bar-border: #ff2bdc;
    --bar-gradient: linear-gradient(
            to right,
            #ff3864,
            #ff2bdc,
            #00fff0
    );
}

.theme-storm {
    /* Core storm palette */
    --bg: #05070d;
    --fg: #e8ecff;
    --accent: #7aa2ff;   /* lightning blue */

    /* Panels */
    --card-bg: #0b1020;
    --border: #7aa2ff;

    /* Buttons */
    --button-text: #7aa2ff;
    --button-border: #7aa2ff;
    --button-hover-bg: #7aa2ff;
    --button-hover-text: #05070d;

    /* Inputs */
    --input-bg: #05070d;
    --input-text: #e8ecff;
    --input-border: #7aa2ff;

    /* Status lights */
    --status-on: #5cffd1;
    --status-off: #ff4d6d;

    /* Loading bar */
    --bar-bg: #0b1020;
    --bar-border: #7aa2ff;
    --bar-gradient: linear-gradient(
            to right,
            #3a4ca8,
            #7aa2ff,
            #cdd9ff
    );
}

body.theme-storm {
    background:
            linear-gradient(
                    130deg,
                    #05070d,
                    #0b1020,
                    #141b33,
                    #0b1020,
                    #05070d
            );
    background-size: 400% 400%;
    animation: storm-clouds 70s ease-in-out infinite;
}

@keyframes storm-clouds {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body.theme-storm::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
            circle at 60% 20%,
            rgba(200, 220, 255, 0.35),
            transparent 55%
    );
    opacity: 0;
    animation: lightning-flash 18s infinite;
    z-index: 9998;
}

@keyframes lightning-flash {
    0%   { opacity: 0; }
    82%  { opacity: 0; }
    83%  { opacity: 1; }
    84%  { opacity: 0.2; }
    85%  { opacity: 0.9; }
    86%  { opacity: 0; }
    100% { opacity: 0; }
}

body.theme-storm::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
            110deg,
            rgba(255, 255, 255, 0.02),
            rgba(255, 255, 255, 0.02) 1px,
            transparent 1px,
            transparent 6px
    );
    animation: storm-rain 1.8s linear infinite;
    opacity: 0.25;
    z-index: 9997;
}

@keyframes storm-rain {
    from {
        background-position: 0 0;
    }
    to {
        background-position: -40px 120px;
    }
}

.theme-storm * {
    text-shadow:
            0 0 2px rgba(122, 162, 255, 0.3),
            0 0 6px rgba(122, 162, 255, 0.15);
}

.theme-cube {
    --bg: #2b0f1e;
    --fg: #fff1e6;
    --accent: #ff6b35;

    --card-bg: #2b0f1e;
    --border: var(--accent);

    --button-text: var(--fg);
    --button-border: var(--accent);
    --button-bg: var(--bg);
    --button-hover-bg: var(--accent);
    --button-hover-text: #2b0f1e;

    --input-bg: #2b0f1e;
    --input-text: #fff1e6;
    --input-border: var(--accent);

    --status-on: #f7c948;
    --status-off: #e63946;

    --bar-bg: #3d142b;
    --bar-border: var(--accent);
    --bar-gradient: linear-gradient(
            to right,
            #ff4500,
            #ff6b35,
            #f7c948
    );

}

.theme-matrix {
    --bg: #001100;
    --fg: #00ff6a;
    --accent: #00ff6a;

    --card-bg: #002200;
    --border: #00ff6a;

    --button-text: #00ff6a;
    --button-border: #00ff6a;
    --button-hover-bg: #00ff6a;
    --button-hover-text: #001100;

    --input-bg: #000;
    --input-text: #00ff6a;
    --input-border: #00ff6a;

    --status-on: #00ff6a;
    --status-off: #993333;

    --bar-bg: #002200;
    --bar-border: #00ff6a;
    --bar-gradient: linear-gradient(to right, #993333, #00ff6a);
}

/* CRT overlay effects, now independent */
.crt-mode::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.15),
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 3px
    );
    z-index: 9999;
}

.crt-mode #page::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
            to bottom,
            rgba(255,191,94,0.04),
            rgba(255,191,94,0.04) 1px,
            transparent 1px,
            transparent 4px
    );
    z-index: 0;
    animation: crt-scanline-move 2s linear infinite;
}

@keyframes crt-scanline-move {
    0% { background-position-y: 0; }
    100% { background-position-y: 5px; }
}

.crt-mode::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    z-index: 9998;
}

.crt-mode * {
    text-shadow:
            0 0 2px rgba(255, 191, 94, 0.6),
            0 0 6px rgba(255, 159, 28, 0.3);
}