:root {
    --radius: 0.75rem;
    --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;

    /* VaultMail light palette */
    --background: 220 30% 97%;
    --foreground: 222 47% 11%;
    --card: 0 0% 100%;
    --card-foreground: 222 47% 11%;
    --popover: 0 0% 100%;
    --popover-foreground: 222 47% 11%;
    --primary: 262 83% 58%;
    --primary-foreground: 0 0% 100%;
    --secondary: 220 25% 94%;
    --secondary-foreground: 222 47% 11%;
    --muted: 220 20% 94%;
    --muted-foreground: 220 10% 46%;
    --accent: 174 72% 40%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 20% 90%;
    --input: 220 20% 90%;
    --ring: 262 83% 58%;

    --gradient-brand: linear-gradient(135deg, hsl(262 83% 58%), hsl(280 70% 55%));
    --gradient-cta: linear-gradient(135deg, hsl(239 84% 67%), hsl(262 83% 58%));
    --shadow-card: 0 4px 24px rgb(99 102 241 / 0.08);

    --brand-indigo: 262 83% 58%;
    --brand-teal: 174 72% 40%;
    --brand-violet: 280 70% 55%;
    --brand-amber: 38 92% 50%;
}

.dark {
    --background: 222 25% 12%;
    --foreground: 210 40% 98%;
    --card: 222 22% 16%;
    --card-foreground: 210 40% 98%;
    --popover: 222 22% 16%;
    --popover-foreground: 210 40% 98%;
    --primary: 262 80% 65%;
    --primary-foreground: 0 0% 100%;
    --secondary: 222 20% 20%;
    --secondary-foreground: 210 40% 98%;
    --muted: 222 18% 22%;
    --muted-foreground: 220 15% 65%;
    --accent: 174 55% 45%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 62% 50%;
    --destructive-foreground: 210 40% 98%;
    --border: 222 18% 24%;
    --input: 222 18% 24%;
    --ring: 262 80% 65%;

    --shadow-card: 0 4px 24px rgb(0 0 0 / 0.28);
}

* {
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: var(--font-sans);
    font-feature-settings: "rlig" 1, "calt" 1;
}

/* —— Login —— */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    background-color: hsl(var(--background));
}

.login-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 55% at 15% 35%, hsl(var(--brand-indigo) / 0.2), transparent 55%),
        radial-gradient(ellipse 65% 45% at 85% 15%, hsl(var(--brand-violet) / 0.16), transparent 50%),
        radial-gradient(ellipse 55% 65% at 75% 85%, hsl(var(--brand-teal) / 0.14), transparent 55%);
    pointer-events: none;
}

.dark .login-page::before {
    background:
        radial-gradient(ellipse 80% 55% at 15% 35%, hsl(var(--brand-indigo) / 0.25), transparent 55%),
        radial-gradient(ellipse 65% 45% at 85% 15%, hsl(var(--brand-violet) / 0.2), transparent 50%),
        radial-gradient(ellipse 55% 65% at 75% 85%, hsl(var(--brand-teal) / 0.15), transparent 55%);
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 32rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border) / 0.65);
    background: hsl(var(--card) / 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    padding: 2rem 1.75rem;
}

.dark .login-card {
    background: hsl(var(--card) / 0.82);
    border-color: hsl(var(--border) / 0.55);
}

.login-card-header {
    position: relative;
    min-height: 2rem;
    margin-bottom: 1.25rem;
}

.login-lang-pill {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.125rem;
    border-radius: 9999px;
    border: 1px solid hsl(var(--border) / 0.75);
    background: hsl(var(--muted) / 0.55);
}

.login-lang-pill__btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: hsl(var(--muted-foreground));
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.login-lang-pill__btn:hover:not(:disabled) {
    color: hsl(var(--foreground));
}

.login-lang-pill__btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.login-lang-pill__btn.bg-background {
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 4px hsl(var(--brand-indigo) / 0.14);
}

.login-lang-pill__btn--inactive {
    color: hsl(var(--muted-foreground));
}

.login-brand {
    margin-bottom: 1.75rem;
    text-align: center;
}

.login-brand__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.login-brand__tagline {
    max-width: 18rem;
    margin-left: auto;
    margin-right: auto;
}

.login-page-head {
    margin-bottom: 1.75rem;
    text-align: center;
}

/* —— Brand —— */

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--gradient-brand);
    box-shadow: 0 2px 12px hsl(var(--brand-indigo) / 0.35);
}

.brand-logo img,
.brand-logo svg {
    width: 1.375rem;
    height: 1.375rem;
    color: white;
}

.brand-wordmark {
    font-family: var(--font-sans);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* —— Header —— */

.header-brand-bar {
    position: relative;
}

.header-brand-bar::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-brand);
    opacity: 0.55;
}

/* —— CTA —— */

.btn-gradient {
    background: var(--gradient-cta);
    color: hsl(var(--primary-foreground));
    border: none;
    box-shadow: 0 4px 14px hsl(var(--brand-indigo) / 0.35);
    transition: opacity 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn-gradient:hover {
    opacity: 0.92;
    box-shadow: 0 6px 20px hsl(var(--brand-indigo) / 0.42);
}

.btn-gradient:active {
    transform: translateY(1px);
}

.btn-gradient:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* —— Sidebar folders —— */

.folder-btn {
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.folder-btn.active {
    background-color: hsl(var(--primary) / 0.12) !important;
    color: hsl(var(--foreground)) !important;
    border-left-color: hsl(var(--primary));
    font-weight: 500;
}

.dark .folder-btn.active {
    background-color: hsl(var(--primary) / 0.18) !important;
}

.folder-btn.active .unread-count {
    background-color: hsl(var(--primary) / 0.2);
    color: hsl(var(--primary));
}

/* —— Email list —— */

.email-item.selected {
    background-color: hsl(var(--primary) / 0.08);
}

.dark .email-item.selected {
    background-color: hsl(var(--primary) / 0.14);
}

.email-item.unread,
.email-item--unread {
    background-color: hsl(var(--brand-indigo) / 0.06);
}

.dark .email-item.unread,
.dark .email-item--unread {
    background-color: hsl(var(--brand-indigo) / 0.12);
}

.email-item.unread:hover,
.email-item--unread:hover {
    background-color: hsl(var(--brand-indigo) / 0.1);
}

.dark .email-item.unread:hover,
.dark .email-item--unread:hover {
    background-color: hsl(var(--brand-indigo) / 0.16);
}

/* —— Webmail —— */

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    color: hsl(var(--primary-foreground));
    background: var(--gradient-brand);
    box-shadow: 0 2px 8px hsl(var(--brand-indigo) / 0.3);
}

.welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 1.5rem;
    border-radius: 9999px;
    background: var(--gradient-brand);
    box-shadow: 0 8px 24px hsl(var(--brand-indigo) / 0.28);
}

.welcome-icon i {
    color: hsl(var(--primary-foreground));
    font-size: 1.75rem;
}

.btn-premium {
    border: 1px solid hsl(var(--brand-amber) / 0.55);
    color: hsl(32 95% 32%);
    background: hsl(var(--brand-amber) / 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-premium:hover {
    background: hsl(var(--brand-amber) / 0.12);
    border-color: hsl(var(--brand-amber) / 0.7);
}

.dark .btn-premium {
    color: hsl(38 92% 72%);
    background: hsl(var(--brand-amber) / 0.1);
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: calc(var(--radius) - 4px);
    border: 1px solid hsl(var(--border) / 0.8);
    background: hsl(var(--muted) / 0.45);
    color: hsl(var(--muted-foreground));
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

.theme-toggle-btn:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--muted));
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* —— Settings —— */

.settings-page {
    min-height: 100vh;
    background-color: hsl(var(--background));
}

.settings-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    box-shadow: 0 1px 0 hsl(var(--brand-indigo) / 0.08);
}

.settings-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-brand);
    opacity: 0.5;
}

.settings-card {
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
}

.settings-card__title {
    position: relative;
    padding-left: 0.875rem;
    margin-bottom: 0.5rem;
}

.settings-card__title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.2em;
    bottom: 0.2em;
    width: 3px;
    border-radius: 9999px;
    background: var(--gradient-brand);
}

.settings-tab-nav .tab-button.active {
    border-bottom-color: hsl(var(--primary));
    color: hsl(var(--foreground));
}

.settings-tab-nav .tab-button:not(.active) {
    border-bottom-color: transparent;
}

/* —— Toasts —— */

#webmail-toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(24rem, calc(100vw - 2rem));
    pointer-events: none;
}

.webmail-toast {
    pointer-events: auto;
    padding: 0.75rem 1rem;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: var(--shadow-card);
    font-size: 0.875rem;
    line-height: 1.4;
    animation: webmail-toast-in 0.2s ease-out;
}

.webmail-toast--warning {
    border-color: hsl(var(--brand-amber) / 0.45);
    background: hsl(var(--brand-amber) / 0.1);
    color: hsl(32 95% 30%);
}

.dark .webmail-toast--warning {
    color: hsl(38 92% 75%);
}

.webmail-toast--error {
    border-color: hsl(var(--destructive) / 0.45);
    background: hsl(var(--destructive) / 0.1);
}

.webmail-toast--success {
    border-color: hsl(var(--brand-teal) / 0.45);
    background: hsl(var(--brand-teal) / 0.1);
    color: hsl(174 72% 28%);
}

.dark .webmail-toast--success {
    color: hsl(174 55% 72%);
}

@keyframes webmail-toast-in {
    from {
        opacity: 0;
        transform: translateX(0.5rem);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
