:root {
    /* Core Color Definitions */

    /* === Neutrals (Dark Mode) === */
    --obsidian                    : rgb(8, 8, 14);
    --deep-charcoal               : rgb(16, 16, 24);
    --slate-midnight              : rgb(22, 22, 32);
    --pewter-mute                 : rgb(180, 180, 200);

    /* === Neutrals (Light Mode) === */
    --ivory-soft                  : rgb(250, 250, 252);
    --silver-mist                 : rgb(242, 242, 248);
    --graphite                    : rgb(44, 44, 56);
    --pewter-light                : rgb(108, 108, 126);

    /* === Accents === */
    --electric-violet             : rgb(114, 9, 183);
    --azure-vivid                 : rgb(65, 105, 225);
    --azure-bright                : rgb(100, 149, 237);
    --indigo-royal                : rgb(75, 0, 130);
    --sapphire-deep               : rgb(54, 98, 206);
    --violet-amethyst             : rgb(58, 12, 163);
    --cyan-electric               : rgb(0, 200, 220);
    --unknown-green1              : rgb(187, 247, 208);
    --unknown-pink                : rgb(254, 226, 226);
    --unknown-pink2               : rgb(254, 202, 202);

    /* === Semantic Colors === */
    --emerald-bright              : rgb(0, 210, 211);
    --crimson-vivid               : rgb(255, 71, 87);

    /* === Transparency Variants === */
    --deep-ink-80                 : rgba(10, 10, 20, 0.80);
    --deep-ink-75                 : rgba(10, 10, 20, 0.75);
    --deep-ink-70                 : rgba(10, 10, 20, 0.70);
    --shadow-overlay-85           : rgba(0, 0, 0, 0.85);
    --glass-white-85              : rgba(255, 255, 255, 0.85);
    --glass-white-90              : rgba(255, 255, 255, 0.90);
    --cloud-white-95              : rgba(250, 250, 252, 0.95);

    /* === Border & Input Accents === */
    --azure-mist-20               : rgba(100, 149, 237, 0.20);
    --azure-mist-35               : rgba(100, 149, 237, 0.35);
    --blue-ghost-12               : rgba(70, 100, 150, 0.12);
    --blue-ghost-06               : rgba(70, 100, 150, 0.06);
    --blue-whisper-15             : rgba(180, 190, 220, 0.15);
    --blue-whisper-08             : rgba(180, 190, 220, 0.08);

    /* === Grid & Background Patterns === */
    --grid-accent-subtle          : rgba(70, 100, 150, 0.08);
    --grid-line-subtle            : rgba(70, 100, 150, 0.04);

    /* === Glow Effects === */
    --glow-cyan                   : rgb(72, 199, 253);
    --glow-cyan-muted             : rgba(72, 199, 253, 0.6);

    /* ============================================
        Dark Mode Variables (Default)
        ============================================ */

    --bg-primary: var(--obsidian);
    --bg-secondary: var(--deep-charcoal);
    --bg-tertiary: var(--slate-midnight);
    --container-bg: var(--deep-ink-75);
    --surface-elevated: var(--deep-ink-80);

    --text-primary: var(--pewter-mute);
    --text-secondary: rgba(180, 180, 200, 0.75);
    --text-muted: rgba(180, 180, 200, 0.55);

    --input-bg: var(--deep-ink-70);
    --input-border: var(--azure-mist-20);
    --input-focus: var(--azure-bright);

    --glow-color: var(--glow-cyan);
    --glow-effect: var(--glow-cyan-muted);

    --button-bg: var(--sapphire-deep);
    --button-bg-hover: var(--violet-amethyst);
    --button-text: var(----silver-mist);
    --button-text-hover: var(----ivory-soft);

    --toggle-bg: var(--silver-mist);
    --toggle-circle: var(--obsidian);
    --toggle-active: var(--pewter-mute);

    --grid-color: var(--blue-ghost-12);
    --grid-line: var(--blue-ghost-06);

    --error-color: var(--crimson-vivid);
    --success-color: var(--emerald-bright);

    --modal-overlay: var(--shadow-overlay-85);
    --modal-bg: var(--deep-ink-75);

    --transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================
    Light Mode Variables
    ============================================ */

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: var(--ivory-soft);
        --bg-secondary: var(--silver-mist);
        --bg-tertiary: rgba(230, 230, 242, 0.60);
        --container-bg: var(--glass-white-85);
        --surface-elevated: var(--glass-white-90);

        --text-primary: var(--graphite);
        --text-secondary: var(--pewter-light);
        --text-muted: rgba(108, 108, 126, 0.75);

        --input-bg: var(--cloud-white-95);
        --input-border: var(--azure-mist-35);
        --input-focus: var(--sapphire-deep);

        --glow-color: var(--sapphire-deep);
        --glow-effect: rgba(54, 98, 206, 0.5);

        --button-bg: var(--violet-amethyst);
        --button-bg-hover: var(--indigo-royal);
        --button-text: var(--ivory-soft);
        --button-text-hover: var(--deep-charcoal);

        --toggle-bg: var(--silver-mist);
        --toggle-circle: var(--obsidian);
        --toggle-active: var(--pewter-mute);

        --grid-color: var(--blue-whisper-15);
        --grid-line: var(--blue-whisper-08);

        --error-color: var(--crimson-vivid);
        --success-color: var(--emerald-bright);

        --modal-overlay: var(--pewter-light);
        --modal-bg: var(--ivory-soft);
    }
}

/* User Override for Light Mode */
.light-mode {
    --bg-primary: var(--ivory-soft);
    --bg-secondary: var(--silver-mist);
    --bg-tertiary: rgba(230, 230, 242, 0.60);
    --container-bg: var(--glass-white-85);
    --surface-elevated: var(--glass-white-90);

    --text-primary: var(--graphite);
    --text-secondary: var(--pewter-light);
    --text-muted: rgba(108, 108, 126, 0.75);

    --input-bg: var(--cloud-white-95);
    --input-border: var(--azure-mist-35);
    --input-focus: var(--sapphire-deep);

    --glow-color: var(--sapphire-deep);
    --glow-effect: rgba(54, 98, 206, 0.5);

    --button-bg: var(--violet-amethyst);
    --button-bg-hover: var(--indigo-royal);
    --button-text: var(--ivory-soft);
    --button-text-hover: var(--deep-charcoal);

    --toggle-bg: var(--graphite);
    --toggle-circle: var(--ivory-soft);
    --toggle-active: var(--silver-mist);

    --grid-color: var(--blue-whisper-15);
    --grid-line: var(--blue-whisper-08);

    --error-color: var(--crimson-vivid);
    --success-color: var(--emerald-bright);

    --modal-overlay: var(--pewter-light);
    --modal-bg: var(--ivory-soft);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    line-height: 1.6;
    transition: var(--transition);
}

/* Grid Background */
.grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background:
        linear-gradient(0deg, var(--grid-line), transparent 1px),
        linear-gradient(90deg, var(--grid-line), transparent 1px);
    background-size: 40px 40px;
}

/* Animated Gradient Background */
.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(
        125deg,
        var(--bg-primary),
        var(--bg-secondary),
        var(--bg-primary),
        var(--bg-secondary)
    );
    background-size: 400% 400%;
    animation: gradientBG 18s ease infinite;
    opacity: 0.95;
}

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

/* Container with Glassmorphism */
.container {
    width: 100%;
    max-width: 420px;
    padding: 50px 40px 40px;
    background: var(--container-bg);
    border-radius: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--input-border);
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.2),
        0 0 60px rgba(76, 201, 240, 0.15);
    position: relative;
    overflow: hidden;
    z-index: 1;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s ease forwards 0.3s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glare Effect */
.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0) 70%
    );
    transform: rotate(30deg);
    animation: glare 8s infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes glare {
    0% { transform: translate(-40%, -40%) rotate(30deg); }
    50% { transform: translate(40%, 40%) rotate(30deg); }
    100% { transform: translate(-40%, -40%) rotate(30deg); }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.logo {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--glow-color), var(--electric-violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 15px rgba(76, 201, 240, 0.3);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Form Styles */
.login-form {
    position: relative;
}

.input-group {
    position: relative;
    margin-bottom: 30px;
}

input {
    width: 100%;
    padding: 12px 0 10px;
    font-size: 1.1rem;
    color: var(--text-primary);
    border: none;
    border-bottom: 1px solid var(--input-border);
    outline: none;
    background: transparent;
    transition: var(--transition);
    font-family: inherit;
}

input:focus {
    border-bottom: 1px solid var(--glow-color);
}

input:focus + label,
input:valid + label {
    transform: translateY(-22px);
    font-size: 0.85rem;
    color: var(--glow-color);
    text-shadow: 0 0 8px rgba(76, 201, 240, 0.4);
}

input.invalid {
    border-bottom: 1px solid var(--error-color);
}

input.valid {
    border-bottom: 1px solid var(--success-color);
}

label {
    position: absolute;
    top: 12px;
    left: 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
    pointer-events: none;
    transition: 0.4s;
}

.error-msg {
    position: absolute;
    bottom: -22px;
    left: 0;
    font-size: 0.85rem;
    color: var(--error-color);
    height: 18px;
    opacity: 0;
    transition: opacity 0.3s;
}

.error-msg.active {
    opacity: 1;
}

/* Button Styles */
.btn {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--button-text);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
    margin-bottom: 20px;
}

.btn:hover {
    background: var(--button-hover);
    color: var(--button-text-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.6);
}

.btn:active {
    transform: translateY(0);
}

.btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20px;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(30deg);
    transition: 0.5s;
}

.btn:hover::after {
    left: 120%;
}

/* Theme Toggle - FIXED SECTION */
.theme-toggle {
    position: fixed;
    top: 25px;
    left: 25px;
    width: 58px;
    height:32px;
    opacity: 0;
    z-index: 100;
    cursor: pointer;
}

.toggle-label {
    position: absolute;
    top: 50px;
    left: 25px;
    width: 58px;
    height: 32px;
    background: var(--toggle-bg);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    z-index: 100;
    display: block;
}

.toggle-label::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    background: var(--toggle-circle);
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle:checked + .toggle-label::before {
    transform: translateX(26px);
}

.toggle-icon {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-toggle:checked + .toggle-label .toggle-icon {
    opacity: 0;
    transform: translateX(5px);
}

/* Footer Styles */
.footer {
    width: 100%;
    max-width: 420px;
    padding: 0 40px;
    margin-top: 10px;
    z-index: 2;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    padding-bottom: 3px;
}

.footer-link:hover {
    color: var(--glow-color);
}

.footer-link:hover::after {
    width: 100%;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--glow-color);
    transition: var(--transition);
}

.footer-text {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.success-message {
    background:     ;
    color: var(--success);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    margin-bottom: 24px;
    border: 1px solid var(--unknown-green1);
}

.usercode {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.error-message {
    background: var(--unknown-pink);
    color: var(--error);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 24px;
    border: 1px solid var(--unknown-pink2);
    font-size: 0.875rem;
}

.error-message ul {
    margin-top: 8px;
    padding-left: 20px;
}

.error-message li {
    margin-bottom: 4px;
}


.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content */
.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--modal-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--input-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.5rem;
    color: var(--glow-color);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--error-color);
    background: rgba(255, 255, 255, 0.05);
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
    line-height: 1.7;
}

.modal-body h2 {
    color: var(--glow-color);
    margin: 25px 0 15px;
    font-size: 1.3rem;
}

.modal-body h3 {
    color: var(--text-primary);
    margin: 20px 0 10px;
    font-size: 1.1rem;
}

.modal-body p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.modal-body ul, .modal-body ol {
    margin: 15px 0 15px 25px;
}

.modal-body li {
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 15px 30px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--input-border);
    text-align: right;
}

.modal-accept {
    background: var(--button-bg);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.modal-accept:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        border-radius: 16px;
        padding: 40px 30px;
        margin: 20px;
    }

    .footer {
        max-width: 100%;
        padding: 0 30px;
    }

    .logo {
        font-size: 2.3rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    input {
        font-size: 1rem;
    }

    label {
        font-size: 1rem;
    }

    .btn {
        padding: 12px;
        font-size: 1rem;
    }

    .toggle-label {
        width: 50px;
        height: 28px;
    }

    .toggle-label::before {
        width: 22px;
        height: 22px;
    }

    .theme-toggle:checked + .toggle-label::before {
        transform: translateX(22px);
    }

    .modal-body {
        padding: 20px;
    }

    .modal-header {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 35px 25px;
        border-radius: 12px;
    }

    .footer {
        padding: 0 25px;
    }

    .logo {
        font-size: 2rem;
    }

    .input-group {
        margin-bottom: 25px;
    }

    .btn {
        font-size: 0.95rem;
        letter-spacing: 0.5px;
    }

    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .modal-title {
        font-size: 1.3rem;
    }
}

/* Animation for system theme change */
@media (prefers-color-scheme: light) {
    .container {
        animation: fadeInUp 0.8s ease forwards 0.3s;
    }
}
