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

/* Removed global smooth scrolling to reduce perceived lag */

:root {
    --primary: #08A4D5;
    --primary-light: #33B9E1;
    --primary-dark: #068DB7;
    --secondary: #33B9E1;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #f7fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef2f7;
    --surface: #ffffff;
    --surface-light: #f3f7fb;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border: #dbe3ea;
    --shadow: rgba(0, 0, 0, 0.08);
    --glow: rgba(8, 164, 213, 0.25);
}

/* Theme-aware color-scheme for native controls (select dropdowns, etc.) */
html {
    color-scheme: light;
}

[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .ui-language-flag-row,
[dir="rtl"] .ui-lang-flag,
[dir="rtl"] .version-badge,
[dir="rtl"] code,
[dir="rtl"] .kbd,
[dir="rtl"] .pill,
[dir="rtl"] .badge {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
}

[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
}

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="true-dark"] {
    color-scheme: dark;
}

/* Dark mode color scheme */
[data-theme="dark"] {
    --primary: #08A4D5;
    --primary-light: #33B9E1;
    --primary-dark: #068DB7;
    --secondary: #33B9E1;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #0A0E27;
    --bg-secondary: #141931;
    --bg-tertiary: #1a1f3a;
    --surface: #141931;
    --surface-light: #1E2539;
    --text-primary: #E8EAED;
    --text-secondary: #9AA0A6;
    --border: #2A3247;
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(8, 164, 213, 0.35);
}

/* True Dark mode (Blackhole) color scheme */
[data-theme="true-dark"] {
    --primary: #08A4D5;
    --primary-light: #33B9E1;
    --primary-dark: #068DB7;
    --secondary: #33B9E1;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #111111;
    --surface: #0a0a0a;
    --surface-light: #151515;
    --text-primary: #E8EAED;
    --text-secondary: #8A8A8A;
    --border: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.8);
    --glow: rgba(8, 164, 213, 0.45);
}

/* Ship emoji/flag font so desktop renders regional indicators as flags */
@font-face {
    font-family: 'Twemoji';
    src: url('../fonts/Twemoji.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Dark mode specific overrides */
[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 60%, var(--bg-primary) 100%);
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(circle at 20% 50%, rgba(8, 164, 213, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(51, 185, 225, 0.15) 0%, transparent 50%);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .card {
    background: rgba(20, 25, 49, 0.85);
}

/* Dark mode modal + components tuning */
[data-theme="dark"] .modal {
    background:
        linear-gradient(180deg, rgba(20, 25, 49, 0.92) 0%, rgba(20, 25, 49, 0.86) 100%),
        var(--surface);
    border-color: var(--border);
    box-shadow: 0 24px 72px var(--shadow), 0 0 0 1px rgba(8, 164, 213, 0.12);
}

[data-theme="dark"] .modal-header {
    background: linear-gradient(135deg, rgba(8, 164, 213, 0.06) 0%, rgba(51, 185, 225, 0.06) 100%);
    border-bottom-color: var(--border);
}

[data-theme="dark"] .modal-footer {
    background: var(--surface);
    border-top-color: var(--border);
}

[data-theme="dark"] .reset-bar {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 8px 24px var(--shadow);
}

[data-theme="dark"] .alert-info {
    background: rgba(8, 164, 213, 0.16);
    border-color: var(--primary);
    color: var(--primary-light);
}

[data-theme="dark"] input[type="text"]::placeholder,
[data-theme="dark"] input[type="password"]::placeholder {
    color: #64748b;
}

/* Dark mode keyboard hint contrast fix */
[data-theme="dark"] .keyboard-hint {
    background: rgba(20, 25, 49, 0.9);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Fix radio button label backgrounds in dark mode */
/* Unselected options should be darker */
[data-theme="dark"] label:has(input[type="radio"]:not(:checked))[style*="background: white"] {
    background: var(--bg-secondary) !important;
}

/* Selected option should be lighter/brighter */
[data-theme="dark"] label:has(input[type="radio"]:checked)[style*="background: white"] {
    background: var(--surface-light) !important;
    border-color: var(--primary) !important;
}

/* True Dark mode (Blackhole) specific overrides */
[data-theme="true-dark"] body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 60%, var(--bg-primary) 100%);
}

[data-theme="true-dark"] body::before {
    background:
        radial-gradient(circle at 20% 50%, rgba(8, 164, 213, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(51, 185, 225, 0.08) 0%, transparent 50%);
}

[data-theme="true-dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.9);
}

[data-theme="true-dark"] .card {
    background: rgba(10, 10, 10, 0.95);
}

/* True Dark mode modal + components tuning */
[data-theme="true-dark"] .modal {
    background:
        linear-gradient(180deg, rgba(10, 10, 10, 0.92) 0%, rgba(10, 10, 10, 0.86) 100%),
        var(--surface);
    border-color: var(--border);
    box-shadow: 0 28px 84px var(--shadow), 0 0 0 1px rgba(8, 164, 213, 0.14);
}

[data-theme="true-dark"] .modal-header {
    background: linear-gradient(135deg, rgba(8, 164, 213, 0.05) 0%, rgba(51, 185, 225, 0.05) 100%);
    border-bottom-color: var(--border);
}

[data-theme="true-dark"] .modal-footer {
    background: var(--surface);
    border-top-color: var(--border);
}

[data-theme="true-dark"] .reset-bar {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 10px 28px var(--shadow);
}

[data-theme="true-dark"] .alert-info {
    background: rgba(8, 164, 213, 0.18);
    border-color: var(--primary);
    color: #d6f3ff;
}

[data-theme="true-dark"] input[type="text"]::placeholder,
[data-theme="true-dark"] input[type="password"]::placeholder {
    color: #4a4a4a;
}

[data-theme="true-dark"] .keyboard-hint {
    background: rgba(10, 10, 10, 0.95);
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="true-dark"] label:has(input[type="radio"]:not(:checked))[style*="background: white"] {
    background: var(--bg-secondary) !important;
}

[data-theme="true-dark"] label:has(input[type="radio"]:checked)[style*="background: white"] {
    background: var(--surface-light) !important;
    border-color: var(--primary) !important;
}

[data-theme="true-dark"] .theme-toggle {
    background: rgba(10, 10, 10, 0.95);
    border-color: var(--border);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #ffffff 60%, var(--bg-primary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Reserve scrollbar space to prevent layout shift when modals lock/unlock scroll */
    scrollbar-gutter: stable both-edges;
}

/* Page scrollbar styling to match modal */
html,
body {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--surface-light);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 10px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: var(--surface-light);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 8px;
    border: 2px solid var(--surface-light);
}

/* Lock background scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Removed heavy fixed gradient layer to avoid full-viewport repaints on scroll */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 20%;
    position: relative;
    z-index: 1;
}

.ui-language-dock {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 28px var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9985;
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    isolation: isolate;
    cursor: pointer;
}

.ui-language-dock::after {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -1px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
    opacity: 0.9;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .ui-language-dock,
html[data-theme="true-dark"] .ui-language-dock {
    background: rgba(12, 17, 36, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 14px 30px var(--shadow), 0 0 0 1px rgba(8, 164, 213, 0.16);
}

html[data-theme="true-dark"] .ui-language-dock {
    background: rgba(4, 6, 10, 0.94);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(8, 164, 213, 0.2);
}

.ui-language-dock:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 36px var(--shadow), 0 0 0 1px rgba(8, 164, 213, 0.25);
}

.ui-language-dock:focus-within {
    border-color: rgba(8, 164, 213, 0.7);
    box-shadow: 0 16px 38px var(--shadow), 0 0 0 2px rgba(8, 164, 213, 0.25);
}

.ui-language-glow {
    position: absolute;
    inset: -30%;
    background: radial-gradient(circle at 30% 50%, rgba(8, 164, 213, 0.25), transparent 50%),
        radial-gradient(circle at 80% 40%, rgba(51, 185, 225, 0.2), transparent 55%);
    filter: blur(18px);
    opacity: 0.8;
    pointer-events: none;
}

.ui-language-flag-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    z-index: 1;
}

.ui-language-dock.expanded {
    align-items: flex-start;
}

.ui-language-dock.expanded .ui-language-flag-row {
    flex-direction: column;
}

.ui-language-flag-row.collapsed .ui-lang-flag:not(.active) {
    display: none;
}

.ui-lang-flag {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    /* Force emoji-capable fonts so regional indicators render as flags on desktop too */
    font-family: 'Twemoji', 'Twemoji Color', 'Twemoji Mozilla', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Noto Emoji', 'Segoe UI Symbol', 'Inter', sans-serif;
    font-variant-emoji: emoji;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7)),
        linear-gradient(145deg, rgba(8, 164, 213, 0.14), rgba(51, 185, 225, 0.12));
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 20px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

html[data-theme="dark"] .ui-lang-flag {
    color: #e5f6ff;
    background:
        linear-gradient(150deg, rgba(8, 164, 213, 0.24), rgba(51, 185, 225, 0.16)),
        linear-gradient(180deg, rgba(10, 15, 32, 0.95), rgba(13, 20, 38, 0.92));
    border-color: rgba(8, 164, 213, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 20px rgba(0, 0, 0, 0.45);
}

html[data-theme="true-dark"] .ui-lang-flag {
    color: #dff5ff;
    background:
        linear-gradient(155deg, rgba(8, 164, 213, 0.22), rgba(51, 185, 225, 0.1)),
        linear-gradient(180deg, rgba(4, 6, 10, 0.96), rgba(8, 10, 14, 0.92));
    border-color: rgba(8, 164, 213, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 22px rgba(0, 0, 0, 0.65);
}

.ui-lang-flag:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(8, 164, 213, 0.18);
}

.ui-lang-flag:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.ui-lang-flag.active {
    border-color: var(--primary);
    box-shadow: 0 14px 30px rgba(8, 164, 213, 0.28), 0 0 0 1px rgba(8, 164, 213, 0.35);
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.78)),
        linear-gradient(145deg, rgba(8, 164, 213, 0.25), rgba(51, 185, 225, 0.2));
}

html[data-theme="dark"] .ui-lang-flag.active {
    color: #eaf6ff;
    background:
        linear-gradient(150deg, rgba(8, 164, 213, 0.32), rgba(51, 185, 225, 0.26)),
        linear-gradient(180deg, rgba(10, 17, 35, 0.96), rgba(8, 13, 26, 0.96));
    border-color: rgba(8, 164, 213, 0.6);
    box-shadow: 0 14px 30px rgba(8, 164, 213, 0.32), 0 0 0 1px rgba(8, 164, 213, 0.45);
}

html[data-theme="true-dark"] .ui-lang-flag.active {
    color: #e8f7ff;
    background:
        linear-gradient(155deg, rgba(8, 164, 213, 0.36), rgba(51, 185, 225, 0.22)),
        linear-gradient(180deg, rgba(5, 7, 12, 0.96), rgba(2, 4, 8, 0.96));
    border-color: rgba(8, 164, 213, 0.65);
    box-shadow: 0 14px 30px rgba(8, 164, 213, 0.38), 0 0 0 1px rgba(8, 164, 213, 0.5);
}

@media (max-width: 1024px) {
    .ui-language-dock {
        left: 0.75rem;
        top: 0.75rem;
    }
}

@media (max-width: 640px) {
    .ui-language-dock {
        left: 0.75rem;
        top: 0.75rem;
        right: auto;
        bottom: auto;
        transform: none;
        min-width: unset;
    }

    .ui-lang-flag {
        width: 34px;
        height: 34px;
        font-size: 1.05rem;
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 60px var(--glow);
    animation: float 3s ease-in-out infinite;
    /* Hint compositing to keep animation smooth */
    will-change: transform;
    transform: translateZ(0);
    position: relative;
    border: 2px solid var(--border);
    /* add depth without changing color */
    border-radius: 24px;
    /* emboss edges similar to block (neutral tones only) */
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 6px 0 rgba(0, 0, 0, 0.12),
        0 20px 60px var(--glow);
}

.logo::before {
    content: '';
    position: absolute;
    inset: -2px;
    /* Replace heavy blur with a radial glow and soft halo */
    background: radial-gradient(closest-side, var(--primary) 0%, rgba(8, 164, 213, 0.45) 35%, transparent 70%);
    border-radius: 24px;
    z-index: -1;
    opacity: 0.6;
    box-shadow: 0 0 60px rgba(8, 164, 213, 0.25);
}

.logo img {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin: 0 auto 0.5rem auto;
    letter-spacing: -0.02em;
    position: relative;
    padding: 0.75rem 2rem;
    border-radius: 16px;
    border: 3px solid rgba(0, 0, 0, 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(0, 0, 0, 0.08) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    /* 3D beveled effect matching buttons */
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.45),
        inset 0 -4px 0 rgba(0, 0, 0, 0.3),
        0 8px 0 rgba(0, 0, 0, 0.25),
        0 12px 40px var(--glow),
        0 0 60px rgba(8, 164, 213, 0.3);
    color: white;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 -1px 2px rgba(255, 255, 255, 0.3);
    transform-style: preserve-3d;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: titlePulse 3s ease-in-out infinite;
    width: fit-content;
    overflow: hidden;
}

/* Epic animated shimmer overlay */
h1::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
            transparent 0%,
            transparent 40%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 60%,
            transparent 100%);
    border-radius: 16px;
    opacity: 0;
    animation: shimmer 4s ease-in-out infinite;
    pointer-events: none;
    overflow: hidden;
}


/* Hover effect for interactivity */
h1:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.5),
        inset 0 -4px 0 rgba(0, 0, 0, 0.3),
        0 10px 0 rgba(0, 0, 0, 0.25),
        0 16px 48px var(--glow),
        0 0 80px rgba(8, 164, 213, 0.5);
}

/* Pulsing glow animation */
@keyframes titlePulse {

    0%,
    100% {
        box-shadow:
            inset 0 3px 0 rgba(255, 255, 255, 0.45),
            inset 0 -4px 0 rgba(0, 0, 0, 0.3),
            0 8px 0 rgba(0, 0, 0, 0.25),
            0 12px 40px var(--glow),
            0 0 60px rgba(8, 164, 213, 0.3);
    }

    50% {
        box-shadow:
            inset 0 3px 0 rgba(255, 255, 255, 0.45),
            inset 0 -4px 0 rgba(0, 0, 0, 0.3),
            0 8px 0 rgba(0, 0, 0, 0.25),
            0 12px 40px var(--glow),
            0 0 80px rgba(8, 164, 213, 0.5);
    }
}

/* Shimmer animation */
@keyframes shimmer {
    0% {
        transform: translateX(-100%) skewX(-15deg);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translateX(200%) skewX(-15deg);
        opacity: 0;
    }
}

/* Dark mode adjustments for h1 */
[data-theme="dark"] h1 {
    border-color: rgba(0, 0, 0, 0.4);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(0, 0, 0, 0.15) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.35),
        inset 0 -4px 0 rgba(0, 0, 0, 0.5),
        0 8px 0 rgba(0, 0, 0, 0.5),
        0 12px 40px var(--glow),
        0 0 60px rgba(8, 164, 213, 0.4);
}

[data-theme="dark"] h1:hover {
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.4),
        inset 0 -4px 0 rgba(0, 0, 0, 0.5),
        0 10px 0 rgba(0, 0, 0, 0.5),
        0 16px 48px var(--glow),
        0 0 90px rgba(8, 164, 213, 0.6);
}

/* Blackhole mode - MAXIMUM DRAMA */
[data-theme="true-dark"] h1 {
    border-color: rgba(8, 164, 213, 0.3);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.4) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.25),
        inset 0 -4px 0 rgba(0, 0, 0, 0.8),
        0 8px 0 rgba(0, 0, 0, 0.9),
        0 12px 40px var(--glow),
        0 0 80px rgba(8, 164, 213, 0.6),
        0 0 120px rgba(51, 185, 225, 0.3);
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 12px rgba(8, 164, 213, 0.4),
        0 -1px 2px rgba(255, 255, 255, 0.2);
}

[data-theme="true-dark"] h1:hover {
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.8),
        0 10px 0 rgba(0, 0, 0, 0.9),
        0 16px 48px var(--glow),
        0 0 100px rgba(8, 164, 213, 0.8),
        0 0 150px rgba(51, 185, 225, 0.4);
}

[data-theme="true-dark"] h1::before {
    background: linear-gradient(135deg,
            transparent 0%,
            transparent 40%,
            rgba(8, 164, 213, 0.6) 50%,
            transparent 60%,
            transparent 100%);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 600;
    display: inline-block;
    padding: 0.45rem 0.85rem;
    margin: 0;
    border: 2px solid var(--border);
    border-radius: 12px;
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.03) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 4px 0 rgba(0, 0, 0, 0.10);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Config sections */
.section-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 0 0 2rem;
    box-shadow: 0 8px 28px var(--shadow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    cursor: pointer;
}

.section-header * {
    cursor: inherit;
}

.section-icon {
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    flex: 0 0 56px;
    min-width: 56px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(0, 0, 0, 0.08) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: 3px solid rgba(0, 0, 0, 0.22);
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    line-height: 1;
    vertical-align: middle;
    font-size: 1.5rem;
    color: #fff;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.4),
        0 -1px 2px rgba(255, 255, 255, 0.3);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.45),
        inset 0 -4px 0 rgba(0, 0, 0, 0.3),
        0 8px 0 rgba(0, 0, 0, 0.25),
        0 12px 32px var(--glow),
        0 0 50px rgba(8, 164, 213, 0.35);
    position: relative;
    overflow: hidden;
    animation: titlePulse 3s ease-in-out infinite;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-emoji,
.language-emoji {
    font-size: 1.7rem;
    line-height: 1;
    color: #fff;
    font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-emoji {
    font-size: 2.15rem;
}

.section-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
            transparent 0%,
            transparent 40%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 60%,
            transparent 100%);
    opacity: 0;
    animation: shimmer 4s ease-in-out infinite;
    pointer-events: none;
}

.section-icon:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.5),
        inset 0 -4px 0 rgba(0, 0, 0, 0.3),
        0 10px 0 rgba(0, 0, 0, 0.25),
        0 16px 40px var(--glow),
        0 0 70px rgba(8, 164, 213, 0.45);
}

[data-theme="dark"] .section-icon {
    border-color: rgba(0, 0, 0, 0.4);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(0, 0, 0, 0.15) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.35),
        inset 0 -4px 0 rgba(0, 0, 0, 0.5),
        0 8px 0 rgba(0, 0, 0, 0.5),
        0 12px 32px var(--glow),
        0 0 60px rgba(8, 164, 213, 0.4);
}

[data-theme="dark"] .section-icon:hover {
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.4),
        inset 0 -4px 0 rgba(0, 0, 0, 0.5),
        0 10px 0 rgba(0, 0, 0, 0.5),
        0 16px 40px var(--glow),
        0 0 90px rgba(8, 164, 213, 0.55);
}

[data-theme="true-dark"] .section-icon {
    border-color: rgba(8, 164, 213, 0.3);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.4) 100%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.25),
        inset 0 -4px 0 rgba(0, 0, 0, 0.8),
        0 8px 0 rgba(0, 0, 0, 0.9),
        0 12px 32px var(--glow),
        0 0 80px rgba(8, 164, 213, 0.6),
        0 0 120px rgba(51, 185, 225, 0.3);
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 12px rgba(8, 164, 213, 0.35),
        0 -1px 2px rgba(255, 255, 255, 0.2);
}

[data-theme="true-dark"] .section-icon:hover {
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.8),
        0 10px 0 rgba(0, 0, 0, 0.9),
        0 16px 40px var(--glow),
        0 0 100px rgba(8, 164, 213, 0.8),
        0 0 140px rgba(51, 185, 225, 0.4);
}

[data-theme="true-dark"] .section-icon::before {
    background: linear-gradient(135deg,
            transparent 0%,
            transparent 40%,
            rgba(8, 164, 213, 0.6) 50%,
            transparent 60%,
            transparent 100%);
}

.section-title {
    margin: 0;
    font-size: 1.28rem;
    letter-spacing: -0.02em;
}

.section-description {
    margin: 0.15rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.section-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
    /* Creates breathing room between section description and first card */
}

.section-footer {
    display: flex;
    justify-content: center;
    margin-top: 0.25rem;
}

.section-close-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px dashed var(--border);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.7));
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    transition: all 0.2s ease;
}

[data-theme="dark"] .section-close-link {
    background: linear-gradient(135deg, rgba(26, 26, 38, 0.9), rgba(26, 26, 38, 0.6));
}

[data-theme="true-dark"] .section-close-link {
    background: linear-gradient(135deg, rgba(12, 12, 18, 0.94), rgba(26, 26, 32, 0.78));
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.9);
}

.section-close-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 8px 20px var(--glow);
    transform: translateY(-1px);
}

.section-close-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.section-close-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 12px var(--glow);
    font-size: 0.85rem;
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-block.collapsed .section-grid {
    display: none;
}

.section-block.collapsed .section-header {
    margin-bottom: 0;
}

.section-collapse-btn {
    margin-left: auto;
}

.section-grid .card {
    margin-bottom: 0;
}

/* Card System */
.card {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px var(--shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 48px var(--glow);
    transform: translateY(-2px);
}

.card.collapsed .card-content {
    display: none;
}

.card.collapsed {
    padding: 1.5rem 2rem;
    cursor: pointer;
    /* Make entire collapsed card clickable */
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: relative;
    z-index: 1;
}

.card-header * {
    cursor: inherit;
}

.card-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.card-icon {
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    background: linear-gradient(180deg, #f7d13e 0%, #e6b526 60%, #d49c1d 100%);
    border-radius: 12px;
    border: none;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    font-size: 1.5rem;
    color: #3b2a00;
    text-shadow: none;
    box-shadow:
        inset 0 2px 0 #fff3b0,
        inset 0 -3px 0 #b47a11,
        0 6px 0 #7a4d00,
        0 10px 16px rgba(0, 0, 0, 0.25);
}

.card-icon svg {
    width: 34px;
    height: 34px;
    display: block;
}

.card-icon .card-icon-symbol {
    font-size: 1.6rem;
    line-height: 1;
    transform: translateY(0.5px);
}

.card-header:hover .card-icon {
    transform: translateY(-1px);
}

[data-theme="dark"] .card-icon {
    background: linear-gradient(180deg, #4c6fff 0%, #2f4ed1 60%, #1e2f8a 100%);
    color: #0f1a4a;
    border: none;
    box-shadow:
        inset 0 2px 0 #b3c4ff,
        inset 0 -3px 0 #213a9a,
        0 6px 0 #16246a,
        0 10px 16px rgba(20, 25, 49, 0.35);
}

[data-theme="true-dark"] .card-icon {
    background: linear-gradient(180deg, #1b1029 0%, #110b1a 60%, #0b0711 100%);
    color: #bdb4ff;
    border: none;
    box-shadow:
        inset 0 2px 0 #6b65ff33,
        inset 0 -3px 0 #2b2044,
        0 6px 0 #2a1e43,
        0 0 18px rgba(107, 101, 255, 0.25);
}

.card-title {
    font-size: 1.23rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.card-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: 14px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-left: 0.5rem;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.collapse-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
    margin-left: 0.5rem;
}

/* Keep section-level collapse control pinned to the far right */
.section-header .section-collapse-btn {
    margin-left: auto;
}

.collapse-btn:hover {
    background: rgba(8, 164, 213, 0.1);
    border-color: var(--primary);
}

.collapse-btn.collapsed::before {
    content: '▼';
}

.collapse-btn:not(.collapsed)::before {
    content: '▲';
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 56px;
    height: 32px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-light);
    border-radius: 32px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 2px solid var(--border);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    left: 2px;
    top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(24px);
    background: white;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.label-description {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 0.25rem;
    white-space: pre-line;
}

.subtoolbox-instructions {
    margin-left: 0.35rem;
    font-weight: 500;
}

.subtoolbox-tools-note {
    font-size: 0.82rem;
}

/* Enhanced label styling for select dropdowns */
.form-label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.label-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-label .label-description {
    margin-top: 0;
    line-height: 1.5;
}

/* Enhanced select dropdown styling */
select.styled-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 20px) calc(1em + 2px),
        calc(100% - 15px) calc(1em + 2px);
    background-size: 5px 5px,
        5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.5rem;
    /* cursor: pointer removed - native select cursor is more appropriate */
    font-weight: 500;
}

select.styled-select:hover {
    border-color: var(--primary);
    background-color: var(--surface-hover, var(--surface));
}

select.styled-select:focus {
    background-image: linear-gradient(45deg, transparent 50%, var(--primary) 50%),
        linear-gradient(135deg, var(--primary) 50%, transparent 50%);
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

/* Smooth transitions only for border and shadow, NOT background */
input[type="text"],
input[type="password"],
textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--glow);
}

input.invalid,
select.invalid {
    border-color: var(--danger);
    animation: shake 0.3s ease;
}

input.valid,
select.valid {
    border-color: var(--success);
}

.field-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
    animation: fadeInUp 0.3s ease;
}

.field-error.show {
    display: block;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* Password Toggle Eye Icon */
.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field-wrapper input[type="password"],
.password-field-wrapper input[type="text"] {
    padding-right: 3rem;
}

/* Mask sensitive inputs without triggering browser password managers */
.sensitive-input.masked {
    -webkit-text-security: disc;
    text-security: disc;
}

.password-toggle-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    user-select: none;
    z-index: 10;
}

.password-toggle-icon:hover {
    color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

/* Language Selector - Modern Chips */
.language-search {
    position: relative;
    margin-bottom: 1rem;
}

.language-search input {
    padding-left: 2.5rem;
}

.language-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.selected-languages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 42px;
    padding: 0.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.selected-languages:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--glow);
}

.selected-languages.empty::before {
    content: 'Click languages below to add...';
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    height: 26px;
}

.language-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: chipIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.language-chip:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--glow);
}

.language-chip .remove {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.language-chip .remove:hover {
    background: rgba(255, 255, 255, 0.3);
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--surface);
    border-radius: 12px;
    border: 2px solid var(--border);
}

.language-grid::-webkit-scrollbar {
    width: 8px;
}

.language-grid::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

.language-grid::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.language-item {
    padding: 0.75rem 1rem;
    background: var(--surface-light);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    user-select: none;
}

.language-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--glow);
}

.language-item.selected {
    background: linear-gradient(135deg, rgba(8, 164, 213, 0.18) 0%, rgba(51, 185, 225, 0.18) 100%);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.language-item.hidden {
    display: none;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: rgba(8, 164, 213, 0.1);
}

/* Buttons */
.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover::before {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: 2px solid rgba(0, 0, 0, 0.22);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -3px 0 rgba(0, 0, 0, 0.22),
        0 6px 0 rgba(0, 0, 0, 0.22),
        0 8px 24px var(--glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px var(--glow);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 2px solid var(--border);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 6px 0 rgba(0, 0, 0, 0.12);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: rgba(8, 164, 213, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Subtle rivets to echo the Mario block feel (do not change colors) */
.btn::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.18);
    box-shadow:
        calc(100% - 12px) 0 0 rgba(0, 0, 0, 0.18),
        0 calc(100% - 12px) 0 rgba(255, 255, 255, 0.35),
        calc(100% - 12px) calc(100% - 12px) 0 rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

/* Reduce prominence for secondary to keep its neutral color */
.btn-secondary::after {
    background: rgba(0, 0, 0, 0.12);
    box-shadow:
        calc(100% - 12px) 0 0 rgba(0, 0, 0, 0.12),
        0 calc(100% - 12px) 0 rgba(255, 255, 255, 0.25),
        calc(100% - 12px) calc(100% - 12px) 0 rgba(0, 0, 0, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.18);
    box-shadow: 0 10px 28px rgba(239, 68, 68, 0.25);
}

.btn-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* Alert System */
.alert {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 500px;
    z-index: 9999;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 12px 48px var(--shadow);
}

.alert-success {
    background: rgba(16, 185, 129, 0.2);
    border: 2px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.2);
    border: 2px solid var(--warning);
    color: var(--warning);
}

.alert-info {
    background: rgba(8, 164, 213, 0.12);
    border: 2px solid var(--primary);
    color: var(--primary-dark);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Model Fetching Status */
.model-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.model-status.fetching {
    color: var(--primary-light);
}

.model-status.success {
    color: var(--success);
}

.model-status.error {
    color: var(--danger);
}

.model-status .spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Keyboard shortcuts hint */
.keyboard-hint {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.keyboard-hint.show {
    opacity: 1;
}

.kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--primary-light);
    margin: 0 0.25rem;
}

/* Install URL Display */
.install-url-box {
    margin-top: 1.5rem;
    display: none;
}

.install-url-box.show {
    display: block;
}

.install-url-box label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.install-url-box input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: monospace;
    cursor: text;
}

.install-url-box input:focus {
    outline: none;
    box-shadow: 0 0 0 4px var(--glow);
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.footer-heart {
    color: var(--danger);
    animation: heartPulse 3s ease-in-out infinite;
    display: inline-block;
    text-shadow: 0 0 0 transparent;
    transition: all 0.3s ease;
}

.footer p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--primary);
}

@keyframes heartPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.9;
        text-shadow: 0 0 0 transparent;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
        text-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

    .card.collapsed {
        padding: 1rem 1.5rem;
    }

    .language-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        max-height: 300px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .alert {
        right: 1rem;
        left: 1rem;
        min-width: auto;
    }

    .keyboard-hint {
        display: none;
    }

    .selected-languages {
        max-height: 150px;
        overflow-y: auto;
    }

    /* Gemini API Key Rotation - Mobile Responsive */
    /* Keep the additional key rows inline but with proper wrapping */
    .gemini-key-row {
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .gemini-key-row .password-field-wrapper {
        flex: 1 1 auto;
        min-width: 80px;
    }

    /* Override the general .btn { width: 100% } for these specific buttons */
    .gemini-key-row .validate-api-btn,
    .gemini-key-row .btn-danger {
        width: auto !important;
        flex-shrink: 0;
    }

    /* Additional API keys container adjustments for mobile */
    #geminiApiKeysContainer {
        padding: 0.5rem;
    }

    /* Primary Gemini key wrapper - keep inline on mobile but allow wrapping if needed */
    .gemini-key-input-wrapper {
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .gemini-key-input-wrapper .password-field-wrapper {
        flex: 1 1 auto;
        min-width: 80px;
    }

    /* Override for the primary test button */
    .gemini-key-input-wrapper .validate-api-btn {
        width: auto !important;
        margin-top: 0;
    }
}

/* Reset bar */
.reset-bar {
    margin: 0;
    padding: 1rem 1.25rem;
    border: 2px dashed var(--border);
    border-radius: 14px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.reset-bar .reset-text {
    color: var(--text-secondary);
    font-weight: 600;
}

.reset-btn {
    appearance: none;
    border: 2px solid var(--danger);
    background: transparent;
    color: var(--danger);
    padding: 0.625rem 1rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.reset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px var(--shadow);
    background: rgba(239, 68, 68, 0.08);
}

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

/* (JS positions reset bar vertically in the gap) */

/* Disabled Sub Toolbox option */
#subToolboxEnabled:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#subToolboxEnabled:disabled+span {
    color: var(--text-secondary);
}

label:has(#subToolboxEnabled:disabled) {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Stagger animations */
.card:nth-child(1) {
    animation-delay: 0.1s;
}

.card:nth-child(2) {
    animation-delay: 0.2s;
}

.card:nth-child(3) {
    animation-delay: 0.3s;
}

.card:nth-child(4) {
    animation-delay: 0.4s;
}

.card:nth-child(5) {
    animation-delay: 0.5s;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
    display: flex;
}

.modal-overlay.peek {
    inset: auto;
    bottom: 1rem;
    left: 1rem;
    right: auto;
    top: auto;
    width: min(520px, 96vw);
    max-height: 72vh;
    align-items: flex-end;
    justify-content: flex-start;
    background: none;
    animation: none;
}

.modal-overlay.peek .modal {
    width: 100%;
    max-width: 100%;
    box-shadow: 0 16px 44px var(--shadow);
    animation: peekIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Fly-out animation for instructions modal */
.modal-overlay.fly-out {
    animation: fadeOut 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
}

.modal-overlay.fly-out .modal {
    animation: flyToCorner 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-origin: center center;
}

.modal {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.75) 100%),
        var(--bg-secondary);
    border-radius: 20px;
    max-width: 640px;
    width: 92%;
    max-height: 85vh;
    /* Clip scrollbars within rounded corners */
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 72px var(--shadow), 0 0 0 1px rgba(8, 164, 213, 0.14);
    animation: modalSlideIn 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(8, 164, 213, 0.08) 0%, rgba(51, 185, 225, 0.08) 100%);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Legacy instructions-fab removed; map show/hide to .help-button */
.help-button {
    opacity: 1;
}

.help-button.show {
    opacity: 1;
}

/* Animations for overlay fade and fly trajectory */
@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes peekIn {
    from {
        transform: translateY(8px);
        opacity: 0;
    }

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

@keyframes flyToCorner {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    60% {
        transform: translate(calc(28vw - 28px), calc(26vh)) scale(0.55);
        opacity: 0.98;
    }

    100% {
        transform: translate(calc(40vw - 40px), calc(40vh)) scale(0.2);
        opacity: 0.95;
    }
}

/* Removed pulsing shadow animation for smoother scrolling */

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* (modal-header emboss reverted to original) */

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 36px;
    height: 36px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-content {
    padding: 1.5rem;
    text-align: center;
    /* Make only content area scrollable */
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    /* Keep layout centered even when scrollbar appears */
    scrollbar-gutter: stable both-edges;
}

.modal-content h3 {
    color: var(--primary-light);
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.modal-content h3:first-child {
    margin-top: 0;
}

.modal-content ol {
    margin: 0.75rem auto;
    padding-left: 1.5rem;
    color: var(--text-primary);
    line-height: 1.8;
    text-align: left;
    max-width: fit-content;
}

.modal-content li {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0.75rem 0;
}

.modal-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.modal-content em {
    color: var(--warning);
    font-style: normal;
    font-weight: 600;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
}

/* In-modal scrollbar styling (WebKit/Blink) */
.modal-content::-webkit-scrollbar {
    width: 10px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--surface-light);
    border-radius: 12px;
    /* Keep track inset from header/footer to avoid visual bleed */
    margin: 8px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 8px;
    border: 2px solid var(--surface-light);
}

/* Firefox scrollbar styling */
.modal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--surface-light);
}

.modal-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: auto;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.modal-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.highlight-box {
    background: rgba(245, 158, 11, 0.1);
    border: 2px solid var(--warning);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
}

.highlight-box p {
    color: var(--warning);
    font-weight: 600;
    margin: 0;
}

.info-box {
    background: rgba(8, 164, 213, 0.08);
    border: 1px solid rgba(8, 164, 213, 0.35);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin: 1rem 0;
}

.info-box p {
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Scrollbar for modal */
.modal::-webkit-scrollbar {
    width: 10px;
}

.modal::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 0 24px 24px 0;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

.version-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.45rem 0.85rem;
    margin: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.03) 100%);
    border: 2px solid var(--border);
    color: var(--text-secondary) !important;
    -webkit-text-fill-color: var(--text-secondary) !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 4px 0 rgba(0, 0, 0, 0.10);
}

.version-badge::before {
    content: none;
}

.version-badge:hover {
    border-color: var(--primary);
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(8, 164, 213, 0.18);
}

.version-badge:hover::before {
    content: none;
}

.version-badge-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

/* Prevent text selection on hero title, subtitle, and version badge */
.header h1,
.header .subtitle,
.header .version-badge {
    user-select: none;
}

/* Validation Buttons */
.validate-api-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: 2px solid rgba(0, 0, 0, 0.22);
    border-radius: 10px;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -3px 0 rgba(0, 0, 0, 0.22),
        0 6px 0 rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(8, 164, 213, 0.25);
    min-width: 85px;
    justify-content: center;
}

.validate-api-btn::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.18);
    box-shadow:
        calc(100% - 12px) 0 0 rgba(0, 0, 0, 0.18),
        0 calc(100% - 12px) 0 rgba(255, 255, 255, 0.35),
        calc(100% - 12px) calc(100% - 12px) 0 rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.validate-api-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        inset 0 -3px 0 rgba(0, 0, 0, 0.22),
        0 6px 0 rgba(0, 0, 0, 0.18),
        0 4px 16px rgba(8, 164, 213, 0.4);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
}

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

.validate-api-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.validate-api-btn.validating {
    background: linear-gradient(135deg, var(--text-secondary) 0%, #64748b 100%);
    pointer-events: none;
}

.validate-api-btn.validating .validate-icon {
    animation: spin 1s linear infinite;
}

.validate-api-btn.success {
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
}

.validate-api-btn.error {
    background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
}

.validate-icon {
    font-size: 1rem;
    display: inline-block;
}

/* OpenSubtitles auth layout */
.opensubs-auth-layout {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 280px);
    gap: 1rem;
    align-items: stretch;
    margin-top: 0.5rem;
}

@media (max-width: 900px) {
    .opensubs-auth-layout {
        grid-template-columns: 1fr;
    }
}

.opensubs-auth-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.validate-tile {
    position: relative;
    padding: 1rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background:
        linear-gradient(135deg, rgba(8, 164, 213, 0.12), rgba(51, 185, 225, 0.08)),
        var(--surface);
    box-shadow: 0 10px 32px var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    align-self: stretch;
    overflow: hidden;
}

.validate-tile::before {
    content: '';
    position: absolute;
    inset: -40% auto auto -40%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle at center, rgba(8, 164, 213, 0.18), transparent 55%);
    opacity: 0.75;
    pointer-events: none;
    filter: blur(16px);
}

.validate-tile .tile-eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.validate-tile .tile-title {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.validate-tile .tile-copy {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.validate-tile .validate-api-btn {
    width: 100%;
    justify-content: center;
}



.validation-feedback {
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    display: none;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.validation-feedback.show {
    display: block;
}

.validation-feedback.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
}

.validation-feedback.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.validation-feedback.info {
    background: rgba(8, 164, 213, 0.1);
    border: 1px solid rgba(8, 164, 213, 0.3);
    color: var(--primary-dark);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    box-shadow: 0 4px 12px var(--shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(20, 25, 49, 0.9);
    border-color: var(--border);
}

.theme-toggle:focus,
.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 164, 213, 0.35), 0 8px 20px var(--shadow);
}

.theme-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px var(--shadow);
    border-color: var(--primary);
}

.theme-toggle:active {
    transform: translateY(0) scale(0.98);
}

.theme-toggle-icon {
    font-size: 1.5rem;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    display: grid;
    place-items: center;
}

.theme-toggle-icon.sun {
    display: block;
}

.theme-toggle-icon.moon {
    display: none;
}

.theme-toggle-icon.blackhole {
    display: none;
}

[data-theme="dark"] .theme-toggle-icon.sun {
    display: none;
}

[data-theme="dark"] .theme-toggle-icon.moon {
    display: block;
}

[data-theme="dark"] .theme-toggle-icon.blackhole {
    display: none;
}

[data-theme="true-dark"] .theme-toggle-icon.sun {
    display: none;
}

[data-theme="true-dark"] .theme-toggle-icon.moon {
    display: none;
}

[data-theme="true-dark"] .theme-toggle-icon.blackhole {
    display: block;
}

@media (max-width: 768px) {
    .theme-toggle {
        top: 1rem;
        right: 1rem;
        width: 42px;
        height: 42px;
    }

    .theme-toggle-icon {
        font-size: 1.25rem;
    }
}

/* Mario-style block + coin animation (perf-friendly: transforms only) */
.theme-toggle.mario {
    background: linear-gradient(180deg, #f7d13e 0%, #e6b526 60%, #d49c1d 100%);
    border-color: #8a5a00;
    box-shadow:
        inset 0 2px 0 #fff3b0,
        inset 0 -3px 0 #b47a11,
        0 6px 0 #7a4d00,
        0 10px 16px rgba(0, 0, 0, 0.35);
    position: fixed;
}

.theme-toggle.mario::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #b47a11;
    top: 6px;
    left: 6px;
    box-shadow:
        calc(100% - 12px) 0 0 #b47a11,
        0 calc(100% - 12px) 0 #b47a11,
        calc(100% - 12px) calc(100% - 12px) 0 #b47a11;
    opacity: .9;
}

.theme-toggle.mario:active {
    transform: translateY(2px) scale(0.98);
    box-shadow:
        inset 0 1px 0 #fff3b0,
        inset 0 -1px 0 #b47a11,
        0 4px 0 #7a4d00,
        0 8px 14px rgba(0, 0, 0, 0.3);
}

.theme-toggle-icon svg {
    display: block;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Coin effect */
.coin {
    position: fixed;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    will-change: transform, opacity;
    contain: layout paint style;
}

.coin::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.2) 55%),
        radial-gradient(40% 40% at 35% 30%, #fff6bf 0%, rgba(255, 255, 255, 0) 70%),
        linear-gradient(180deg, #ffd24a 0%, #ffc125 50%, #e2a415 100%);
    border: 2px solid #8a5a00;
    box-shadow: 0 2px 0 #7a4d00, inset 0 1px 0 #fff8c6;
}

@keyframes coin-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(0) scale(0.9) rotateY(0deg);
    }

    10% {
        opacity: 1;
    }

    60% {
        transform: translate(-50%, -50%) translateY(-52px) scale(1.0) rotateY(360deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(-70px) scale(0.95) rotateY(540deg);
    }
}

.coin.animate {
    animation: coin-pop 0.7s cubic-bezier(.2, .8, .2, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
    .coin.animate {
        animation: none;
        opacity: 0;
    }
}

/* Theme-based variants for Mario toggle */
[data-theme="light"] .theme-toggle.mario {
    background: linear-gradient(180deg, #f7d13e 0%, #e6b526 60%, #d49c1d 100%);
    border-color: #8a5a00;
    box-shadow:
        inset 0 2px 0 #fff3b0,
        inset 0 -3px 0 #b47a11,
        0 6px 0 #7a4d00,
        0 10px 16px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .theme-toggle.mario::before {
    background: #b47a11;
    box-shadow:
        calc(100% - 12px) 0 0 #b47a11,
        0 calc(100% - 12px) 0 #b47a11,
        calc(100% - 12px) calc(100% - 12px) 0 #b47a11;
}

[data-theme="dark"] .theme-toggle.mario {
    background: linear-gradient(180deg, #4c6fff 0%, #2f4ed1 60%, #1e2f8a 100%);
    border-color: #1b2a78;
    box-shadow:
        inset 0 2px 0 #b3c4ff,
        inset 0 -3px 0 #213a9a,
        0 6px 0 #16246a,
        0 10px 16px rgba(20, 25, 49, 0.6);
}

[data-theme="dark"] .theme-toggle.mario::before {
    background: #213a9a;
    box-shadow:
        calc(100% - 12px) 0 0 #213a9a,
        0 calc(100% - 12px) 0 #213a9a,
        calc(100% - 12px) calc(100% - 12px) 0 #213a9a;
}

[data-theme="true-dark"] .theme-toggle.mario {
    background: linear-gradient(180deg, #1b1029 0%, #110b1a 60%, #0b0711 100%);
    border-color: #3b2a5d;
    box-shadow:
        inset 0 2px 0 #6b65ff33,
        inset 0 -3px 0 #2b2044,
        0 6px 0 #2a1e43,
        0 0 18px rgba(107, 101, 255, 0.35);
}

[data-theme="true-dark"] .theme-toggle.mario::before {
    background: #2b2044;
    box-shadow:
        calc(100% - 12px) 0 0 #2b2044,
        0 calc(100% - 12px) 0 #2b2044,
        calc(100% - 12px) calc(100% - 12px) 0 #2b2044;
}

.quick-stats-grid {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.quick-stat {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.quick-stat-label {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.quick-stat-value {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.05rem;
    color: var(--text-primary);
}

/* Help button — match toggle style, slightly different (radius, rivets) */
.help-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.help-button.toolbox-button {
    left: 2rem;
    right: auto;
}

.help-button:hover {
    transform: translateY(-2px);
}

.help-button.mario {
    border: 2px solid #8a5a00;
    background: linear-gradient(180deg, #f7d13e 0%, #e6b526 60%, #d49c1d 100%);
    color: #3b2a00;
    border-radius: 14px;
    /* slight diff vs toggle */
    box-shadow:
        inset 0 2px 0 #fff3b0,
        inset 0 -3px 0 #b47a11,
        0 6px 0 #7a4d00,
        0 10px 16px rgba(0, 0, 0, 0.35);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
    position: fixed;
}

.help-button.mario::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    opacity: .9;
    background: #b47a11;
    top: 6px;
    left: 6px;
    box-shadow: calc(100% - 12px) 0 0 #b47a11;
}

.toolbox-button {
    left: 2rem;
    right: auto;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: radial-gradient(circle at 28% 22%, #fff3c4 0%, #ffd27f 22%, #ff9d5c 46%, #ff5a7f 72%, #40142f 100%);
    border: 2px solid #3b0f1f;
    box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.32),
        0 12px 30px rgba(255, 77, 122, 0.38),
        inset 0 2px 0 rgba(255, 255, 255, 0.65),
        inset 0 -3px 0 rgba(66, 11, 38, 0.75);
    position: fixed;
    overflow: visible;
}

.toolbox-button::before {
    content: '';
    position: absolute;
    inset: -9px;
    border-radius: 22px;
    background: radial-gradient(circle, rgba(255, 93, 155, 0.4), rgba(255, 93, 155, 0));
    opacity: 0.65;
    filter: blur(6px);
    z-index: -1;
    animation: toolbox-breathe 3.2s ease-in-out infinite;
}

.toolbox-button::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.08));
    mix-blend-mode: screen;
    pointer-events: none;
}

.toolbox-button:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow:
        0 14px 24px rgba(0, 0, 0, 0.35),
        0 16px 34px rgba(255, 77, 122, 0.45),
        inset 0 2px 0 rgba(255, 255, 255, 0.75),
        inset 0 -3px 0 rgba(66, 11, 38, 0.8);
}

.toolbox-button.show {
    animation: toolbox-pop 0.24s ease-out;
}

.toolbox-button .toolbox-icon {
    width: 72%;
    height: 72%;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
    pointer-events: none;
}

.toolbox-button .toolbox-icon svg {
    width: 100%;
    height: 100%;
}

[data-theme="dark"] .toolbox-button {
    background: radial-gradient(circle at 30% 18%, #ffe8c7 0%, #f9c76c 18%, #ff8c61 44%, #ff5a93 70%, #2a1b4d 100%);
    border-color: #2c1b4a;
    box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.38),
        0 12px 30px rgba(116, 138, 255, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -3px 0 rgba(30, 19, 66, 0.9);
}

[data-theme="true-dark"] .toolbox-button {
    background: radial-gradient(circle at 30% 18%, #ffe8c7 0%, #c57aff 24%, #6d49ff 50%, #281c69 78%, #0c0b1a 100%);
    border-color: #201644;
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.45),
        0 14px 30px rgba(107, 101, 255, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        inset 0 -3px 0 rgba(29, 18, 79, 0.9);
}

@keyframes toolbox-pop {
    0% {
        transform: scale(0.85) translateY(8px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes toolbox-breathe {
    0% {
        transform: scale(0.94);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.02);
        opacity: 0.8;
    }

    100% {
        transform: scale(0.94);
        opacity: 0.5;
    }
}

@media (max-width: 768px) {
    .toolbox-button {
        display: none !important;
    }
}

[data-theme="dark"] .help-button.mario {
    border-color: #1b2a78;
    background: linear-gradient(180deg, #4c6fff 0%, #2f4ed1 60%, #1e2f8a 100%);
    color: #0f1a4a;
    box-shadow:
        inset 0 2px 0 #b3c4ff,
        inset 0 -3px 0 #213a9a,
        0 6px 0 #16246a,
        0 10px 16px rgba(20, 25, 49, 0.6);
}

[data-theme="dark"] .help-button.mario::before {
    background: #213a9a;
    box-shadow: calc(100% - 12px) 0 0 #213a9a;
}

[data-theme="true-dark"] .help-button.mario {
    border-color: #3b2a5d;
    background: linear-gradient(180deg, #1b1029 0%, #110b1a 60%, #0b0711 100%);
    color: #bdb4ff;
    box-shadow:
        inset 0 2px 0 #6b65ff33,
        inset 0 -3px 0 #2b2044,
        0 6px 0 #2a1e43,
        0 0 18px rgba(107, 101, 255, 0.35);
}

[data-theme="true-dark"] .help-button.mario::before {
    background: #2b2044;
    box-shadow: calc(100% - 12px) 0 0 #2b2044;
}

/* V3 Warning Tooltip - Responsive Design */
.v3-warning-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.v3-warning-tooltip .warning-icon {
    font-size: 1rem;
    color: var(--warning);
    cursor: help;
    animation: warningPulse 2s ease-in-out infinite;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.v3-warning-tooltip .tooltip-bubble {
    position: absolute;
    background: rgba(245, 158, 11, 0.96);
    color: white;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    opacity: 0;
    visibility: hidden;
    display: none !important;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);

    /* Mobile-first: show below the icon */
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    max-width: min(280px, calc(100vw - 32px));
    width: max-content;
}

/* Arrow pointing up (for mobile bottom position) */
.v3-warning-tooltip .tooltip-bubble::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(245, 158, 11, 0.96);
}

/* Show tooltip on hover/focus */
.v3-warning-tooltip:hover .tooltip-bubble,
.v3-warning-tooltip .warning-icon:focus+.tooltip-bubble {
    display: block !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Desktop: show to the right if enough space */
@media (min-width: 769px) {
    .v3-warning-tooltip .tooltip-bubble {
        top: 50%;
        left: calc(100% + 10px);
        transform: translateY(-50%) translateX(-4px);
        max-width: min(320px, calc(100vw - 60px));
        width: max-content;
    }

    .v3-warning-tooltip .tooltip-bubble::before {
        bottom: auto;
        left: auto;
        right: 100%;
        top: 50%;
        transform: translateY(-50%);
        border: none;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-right: 6px solid rgba(245, 158, 11, 0.96);
    }

    .v3-warning-tooltip:hover .tooltip-bubble,
    .v3-warning-tooltip .warning-icon:focus+.tooltip-bubble {
        display: block !important;
        transform: translateY(-50%) translateX(0);
    }
}

/* Animation for warning icon */
@keyframes warningPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.85;
    }
}

.link-button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.link-button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.subtle-link {
    color: var(--text-secondary);
    text-decoration: underline;
}

.subtle-link:hover {
    color: var(--primary);
}

/* Gemini API Key Rotation Styles */
.gemini-key-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
}

.gemini-key-input-wrapper input {
    flex: 1;
    min-width: 0;
}

.gemini-key-input-wrapper .validate-api-btn {
    flex-shrink: 0;
}

/* Compact validation button for inline use */
.validate-api-btn.compact {
    padding: 0.5rem 0.75rem;
    min-width: 70px;
    font-size: 0.8rem;
}

.validate-api-btn.compact .validate-icon {
    font-size: 0.9rem;
}

/* Dynamic keys list styling */
.dynamic-keys-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.gemini-key-row {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.gemini-key-row .password-field-wrapper {
    flex: 1 1 auto;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.gemini-key-row input {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.65rem;
    padding-right: 3rem;
    /* Space for toggle icon */
    font-size: 0.875rem;
    width: 100%;
}

.gemini-key-row .validate-api-btn {
    padding: 0.35rem 0.5rem;
    min-width: auto;
    font-size: 0.75rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.gemini-key-row .validate-api-btn .validate-icon {
    font-size: 0.85rem;
}

.gemini-key-row .btn-danger {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    min-width: 28px;
    border-radius: 6px;
    flex-shrink: 0;
}

/* More compact API Keys container */
#geminiApiKeysContainer {
    margin-top: 0.5rem;
}

#geminiApiKeysContainer label {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

#geminiApiKeysContainer .label-description {
    font-size: 0.75rem;
}

#addGeminiKeyBtn {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

/* Key Rotation Mode selector compact */
#geminiApiKeysContainer .form-group {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

#geminiApiKeysContainer select {
    padding: 0.45rem 0.65rem;
    font-size: 0.875rem;
}