/* --- Synapse 5.0: Nebula Theme --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root:not([data-theme="dark"]) {
    --bg-main: #f8fafc;
    --text-primary: #0f172a;
    --surface: rgba(255, 255, 255, 0.7);
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --secondary: #8b5cf6;
    --secondary-gradient: linear-gradient(135deg, #8b5cf6, #d8b4fe);
    --accent: #06b6d4;
    --border: rgba(203, 213, 225, 0.6);
    --glass-header: rgba(255, 255, 255, 0.8);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 40px rgba(99, 102, 241, 0.15);
    --glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    /* Slate 900 - Darker */
    --text-primary: #f1f5f9;
    --surface: rgba(30, 41, 59, 0.7);
    /* Darker surface */
    --primary: #818cf8;
    --primary-gradient: linear-gradient(135deg, #818cf8, #c084fc);
    --secondary: #c084fc;
    --secondary-gradient: linear-gradient(135deg, #c084fc, #e879f9);
    --accent: #22d3ee;
    --border: rgba(255, 255, 255, 0.1);
    --glass-header: rgba(15, 23, 42, 0.85);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.7);
    --glow: 0 0 25px rgba(129, 140, 248, 0.2);
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
    border: 0;
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    background-clip: content-box;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
    border: 0;
}

[data-theme="dark"] body {
    background: #0f172a;
    /* Force dark background, disable light gradient */
}

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

.no-scroll {
    overflow: hidden !important;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--bg-main);

    /* Animated Premium Background - Bright Aurora Style */
    background-color: var(--bg-main);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.45) 0%, transparent 60%),
        radial-gradient(circle at 100% 0%, rgba(236, 72, 153, 0.35) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.35) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(139, 92, 246, 0.45) 0%, transparent 50%);
    background-size: 200% 200%;
    /* Larger to allow movement */
    background-attachment: fixed;
    animation: gentleFlow 15s ease infinite alternate;
    /* The little movement */
    transition: background-color 0.3s ease, color 0.3s ease;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
        /* Fix "White Block" glitch on mobile */
        background-size: cover;
    }
}

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

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Restored Grid Backgrounds - HIDDEN */
.bg-grid,
.bg-3d-mesh,
.nebula-bg {
    display: none !important;
}

/* Texture Unhidden for premium feel */
.noise-overlay {
    opacity: 0.04;
    z-index: 0;
}

[data-theme="light"] body {
    /* Simple clean background for light mode */
    background-color: #f8fafc;
}

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

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Noise Texture for Premium Feel */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    opacity: 0.04;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48ZmlsdGVyIGlkPSJuIj48ZmVUdXJYdWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iMC42NSIgbnVtT2N0YXZlcz0iMyIHN0aXRjaFRpbGVzPSJzdGl0Y2giLz48L2ZpbHRlcj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWx0ZXI9InVybCgjbikiIG9wYWNpdHk9IjAuNSIvPjwvc3ZnPg==');
}

/* --- Header --- */
.glass-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    /* Higher opacity to prevent bleed */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transform: translateZ(0);
    /* Force GPU layer to prevent ghosting */
}

@media (max-width: 768px) {
    .glass-header {
        position: absolute;
        /* Prevent fixed artifacts on resize */
        backdrop-filter: none;
        /* Disable expensive filter causing artifacts */
        background: white;
        /* Solid background on mobile */
    }
}

[data-theme="dark"] .glass-header {
    background: rgba(10, 10, 30, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    /* Wider for dashboard feel */
    margin: 0 auto;
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    user-select: none;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
    transition: transform 0.3s ease;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* More space */
}

/* Fix for overlapping badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    /* Prevent wrap */
    box-shadow: var(--shadow-sm);
}

.brand-name {
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

.brand-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.6;
}

.btn-icon-glass {
    background: transparent;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-icon-glass:hover {
    background: var(--surface);
    color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    border-color: var(--primary);
}

/* --- Hero --- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    /* Reduced padding to fit 100vh better */
    padding: 100px 2rem 50vh;
    /* Huge padding to allow scrolling sections to top */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hero {
    text-align: center;
    /* Allow expanding/collapsing based on state */
    transition: all 0.5s ease;
}

/* When options are open, compact the hero */
.hero.compact h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero.compact p {
    display: none;
}

.hero.compact .hero-mode-switch {
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: 3rem;
    /* Slightly smaller */
    margin-bottom: 0.8rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Upload Card (Premium Glass) --- */
.upload-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 4rem;
    /* More padding */
    text-align: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    max-width: 700px;
    /* Wider */
    margin: 0 auto;

    /* Deep Glass Effect */
    background: var(--surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    box-shadow:
        0 20px 40px -10px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    z-index: 50;
    overflow: hidden;
}

.upload-card:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow:
        0 30px 60px -12px rgba(99, 102, 241, 0.25),
        inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    border-color: rgba(99, 102, 241, 0.4);
}

.upload-visual i {
    font-size: 5rem;
    /* Huge Icon */
    margin-bottom: 2rem;
    display: inline-block;
    color: var(--primary);
    filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.4));
}

.upload-text-content h3 {
    font-size: 2.2rem;
    /* Much Larger Text */
    margin-bottom: 1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.upload-hint {
    opacity: 0.9;
    font-size: 1.3rem;
    /* Readable Hint */
    font-weight: 500;
    color: var(--text-secondary);
}

/* --- Bento Grid Configuration --- */
.options-section {
    margin-top: 4rem;
    scroll-margin-top: 120px;
}

/* The Grid Container */
.config-dashboard {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto auto;
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

/* Bento Cells */
.config-group {
    border-radius: 24px;
    padding: 1.5rem;
    /* Background handled by var(--surface) and dark mode overrides */
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.config-group:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    /* Smoother shadow */
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.9);
    /* Brighter */
}

[data-theme="dark"] .config-group:hover {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}
}

.config-group label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Cell Placements */
/* Output Format: Top Left, 8 cols */
.config-group:nth-child(1) {
    grid-column: span 8;
}

/* Difficulty: Top Right, 4 cols */
.config-group:nth-child(2) {
    grid-column: span 4;
}

/* Quantity: Bottom Left, 6 cols */
.config-group:nth-child(3) {
    grid-column: span 6;
}

/* Topic: Bottom Right, 6 cols */
.config-group:nth-child(4) {
    grid-column: span 6;
}

/* Mobile Breakpoint */
@media (max-width: 768px) {

    /* Accessible Hidden Input (Fix for click events) */
    .visually-hidden {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        /* Do NOT use display: none, it breaks file input click in some browsers */
    }

    /* Force hide for now to be safe */
}


/* --- Animated Upload Button (The "Wow" Factor) --- */
.upload-actions {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

/* Upload Button Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: 200% center;
    }

    100% {
        background-position: -200% center;
    }
}

.btn-upload {
    position: relative;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 20%, rgba(255, 255, 255, 0.1) 40%, rgba(255, 255, 255, 0.1) 100%);
    background-size: 200% auto;
    animation: shimmer 4s linear infinite;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    padding: 1rem 3rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 10;
}

.btn-upload:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
    border-color: var(--primary);
    color: var(--primary);
    background: white;
    /* Bright on hover */
}

.btn-upload:hover::before {
    left: 100%;
}

.btn-upload i {
    font-size: 1.5rem;
}

/* --- Export Button (Clean & Attractive, No Shine) --- */
.btn-export {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.btn-export:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.btn-export:active {
    transform: scale(0.98);
}

/* Generating Animation: Smooth Pulse */
.btn-generate.generating {
    background: #8b5cf6;
    /* Solid nice purple matches image */
    pointer-events: none;
    cursor: default;
    opacity: 1;
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    box-shadow: none;
    animation: pulsePurple 2s infinite;
}

@keyframes pulsePurple {
    0% {
        background: #8b5cf6;
    }

    50% {
        background: #7c3aed;
    }

    100% {
        background: #8b5cf6;
    }
}

/* Results Typography & Layout */
.results-grid {
    display: grid;
    gap: 2rem;
    width: 65vw;
    /* Adjusted for better reading width */
    margin: 0 auto;
}

.result-item {
    padding: 2.5rem;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    animation: slideInLeft 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-item:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-3px);
    border-color: var(--primary);
}

/* Number Badge */
.q-badge-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 1.2rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.q-content {
    line-height: 1.8;
    font-size: 1.15rem;
    color: var(--text-primary);
    font-weight: 500;
}

.mcq-options {
    list-style: none;
    margin-top: 1.5rem;
    display: grid;
    gap: 0.8rem;
}

.mcq-options li {
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    cursor: pointer;
}

.mcq-options li:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

/* Ensure they stay visible after animation */
.options-section:not(.hidden),
.results-section:not(.hidden) {
    opacity: 1;
}

/* Animations */
.fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

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

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

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

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

/* Ensure result items are visible even if animation fails */
.result-item {
    opacity: 1;
    animation: slideInLeft 0.5s ease-out backwards;
    /* changed from forwards to backwards/normal or just allow it to run */
}

/* Pulse Animation for Drop Zone */
.upload-card {
    animation: softPulse 4s infinite ease-in-out;
}

@keyframes softPulse {
    0% {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    }

    50% {
        box-shadow: 0 10px 25px rgba(99, 102, 241, 0.15);
        border-color: rgba(99, 102, 241, 0.3);
    }

    100% {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    }
}

.options-section {
    margin-top: 6rem;
    /* Increased spacing */
}

/* Results Header Layout */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.section-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    color: var(--primary);
}

.section-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 2rem;
    letter-spacing: -1px;
}

.config-dashboard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    gap: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    box-shadow: var(--shadow-card);
    background: rgba(255, 255, 255, 0.95);
    /* Solid stable background */
    /* backdrop-filter removed to fix hover glitch */
}

.full-width {
    grid-column: 1 / -1;
}

.config-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.8rem;
    opacity: 0.8;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.mode-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
}

.mode-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mode-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.mode-card.result-item.editing button[title="Edit"] {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.center-text {
    text-align: center;
    justify-content: center;
}

.mode-info h3 {
    font-size: 1rem;
    margin: 0.5rem 0 0.2rem;
    white-space: nowrap;
    /* Prevent breaking if possible, but allow via min-width */
}

.mode-info span {
    font-size: 0.8rem;
    opacity: 0.7;
    line-height: 1.2;
    display: block;
}

.mode-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.mode-card.active .mode-icon {
    color: var(--primary);
}

/* Inputs */
input[type="text"],
select,
.slider-wrapper {
    width: 100%;
    padding: 1rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: inherit;
    font-size: 1rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.btn-generate {
    width: 100%;
    margin-top: 3rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
    transition: 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Searchable Select Component --- */
.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper input {
    padding-left: 2.8rem;
    padding-right: 3rem;
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    height: 50px;
    transition: all 0.2s;
}

.input-icon-wrapper input:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    outline: none;
    background: var(--surface);
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-primary);
    opacity: 0.5;
    font-size: 1.2rem;
    pointer-events: none;
}

.icon-btn-sm {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    opacity: 0.6;
    transition: 0.2s;
}

.icon-btn-sm:hover {
    background: rgba(0, 0, 0, 0.05);
    /* Safe hover for light/dark */
    opacity: 1;
    color: var(--primary);
}

[data-theme="dark"] .icon-btn-sm:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Custom Dropdown List */
.custom-dropdown-list {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: var(--surface);
    /* Glassmorphism inherited from variable */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    animation: fadeInDown 0.2s ease-out;
}

.custom-dropdown-list.hidden {
    display: none;
}

.dropdown-item {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-item:hover,
.dropdown-item.focused {
    background: var(--primary);
    color: white;
}

.dropdown-empty {
    padding: 1rem;
    text-align: center;
    opacity: 0.6;
    font-size: 0.9rem;
    font-style: italic;
}

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

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

/* Generating Animation: Bouncing Dots */
.btn-generate.generating {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    /* Keep original color */
    pointer-events: none;
    cursor: default;
    opacity: 0.9;
}

.dot {
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
    margin-left: 2px;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

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

    40% {
        transform: scale(1);
    }
}

.btn-generate:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
}



.result-item {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 1rem;
    border-left: 5px solid var(--primary);
}

.answer-item {
    border-left-color: var(--secondary);
    background: rgba(139, 92, 246, 0.05);
}

/* Alerts - Premium Redesign */
.hidden {
    display: none !important;
}

/* Ensure modal is flex when visible */
.modal-overlay:not(.hidden) {
    display: flex !important;
}

/* Ensure modal is flex when visible */
.modal-overlay:not(.hidden) {
    display: flex !important;
}

.alert-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1.05rem;
    animation: alertEntrance 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    transition: all 0.3s ease;
    border-left: none;
    /* Reset old style */
}

/* Dark Mode Adaptation */
[data-theme="dark"] .alert {
    background: rgba(15, 23, 42, 0.8);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 30px -3px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Icon Styling */
.alert i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Error State */
.alert-error {
    background: rgba(254, 242, 242, 0.95);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-error i {
    color: #ef4444;
}

[data-theme="dark"] .alert-error {
    background: rgba(69, 10, 10, 0.6);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
}

/* Warning State */
.alert-warning {
    background: rgba(255, 251, 235, 0.95);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-warning i {
    color: #f59e0b;
}

[data-theme="dark"] .alert-warning {
    background: rgba(69, 26, 3, 0.6);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Entrance Animation */
@keyframes alertEntrance {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

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

/* --- Mode Switcher --- */
.hero-mode-switch {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.mode-btn:hover {
    background: var(--surface);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Modern Input for Topic */
.modern-input {
    width: 100%;
    padding: 1.2rem;
    border-radius: 16px;
    border: 2px solid var(--border);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    transition: 0.2s;
    outline: none;
    text-align: center;
}

.modern-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* --- Mode-Based Visibility --- */
/* In PDF Mode, hide the custom input if empty or make it secondary */
#options-panel[data-mode="pdf"] #custom-topic {
    display: none;
}

/* In Topic Mode, hide the select dropdown completely */
#options-panel[data-mode="topic"] .custom-select-wrapper {
    display: none;
}

/* In Topic Mode, make the custom input prominent */
#options-panel[data-mode="topic"] #custom-topic {
    display: block;
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    font-weight: 600;
}

/* --- Modal & Settings Styles --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-card);
    position: relative;
    backdrop-filter: blur(20px);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    /* Very subtle bg */
    border-radius: 16px;
    border: 1px solid var(--border);
}

/* API Key Layout */
.setting-item.column {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.setting-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.setting-info p {
    font-size: 0.9rem;
    opacity: 0.6;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* API Input */
.api-input-wrapper {
    display: flex;
    gap: 0.8rem;
    width: 100%;
}

.input-group {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

#api-key-input {
    width: 100%;
    padding-right: 3rem;
    /* Space for eye icon */
    font-family: monospace;
    letter-spacing: 1px;
}

.btn-icon-inside {
    position: absolute;
    right: 0.8rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    opacity: 0.5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    font-size: 1.2rem;
}

.btn-icon-inside:hover {
    opacity: 1;
    color: var(--primary);
}

.btn-secondary-sm {
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.05);
    /* Transparent */
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    display: flex;
    /* Centering icon */
    align-items: center;
    justify-content: center;
}

.btn-secondary-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.btn-primary-sm {
    padding: 0 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}

.btn-primary-sm:hover {
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.status-msg {
    font-size: 0.85rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    animation: fadeIn 0.3s;
}

.modal-footer {
    margin-top: 2rem;
    text-align: center;
    opacity: 0.5;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .container {
        padding: 100px 1rem 2rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .results-grid {
        width: 100%;
        padding: 0 1rem;
    }

    .config-dashboard {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        display: flex;
        /* Switch to flex column for simplicity */
        flex-direction: column;
        gap: 1.5rem;
    }

    .config-group,
    .config-group:nth-child(n) {
        /* Overriding specific nth-child rules */
        grid-column: auto;
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-export {
        width: 100%;
        justify-content: center;
    }
}

/* Segmented Control */
.segmented-control {
    display: flex;
    position: relative;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.3rem;
    gap: 0.5rem;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 0.8rem;
    cursor: pointer;
    z-index: 2;
    transition: 0.3s;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
    /* Override default config-group label margin */
    border-radius: 8px;
    opacity: 0.6;
}

.segmented-control input:checked+label {
    color: white;
    opacity: 1;
}

.segmented-glider {
    position: absolute;
    top: 0.3rem;
    bottom: 0.3rem;
    left: 0.3rem;
    width: calc((100% - 1.6rem) / 3);
    /* 3 options, taking gaps into account roughly */
    background: var(--primary-gradient);
    border-radius: 8px;
    z-index: 1;
    transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Glider Positioning Logic */
#diff-easy:checked~.segmented-glider {
    transform: translateX(0);
}

#diff-medium:checked~.segmented-glider {
    /* 100% of glider width + gap */
    transform: translateX(calc(100% + 0.5rem));
}

#diff-hard:checked~.segmented-glider {
    transform: translateX(calc(200% + 1rem));
}

/* Result Section Spacing */
.results-section {
    margin-top: 5rem;
    /* Big gap between Generate Button and Results */
    padding-bottom: 2rem;
}

/* Footer Fix - Static at bottom */
.site-footer {
    text-align: center;
    padding: 2rem;
    opacity: 0.4;
    color: var(--text-secondary);
    font-size: 0.8rem;
    width: 100%;
    margin-top: auto;
    /* Pushes to bottom in flex container */
    background: transparent;
    border-top: none;
    backdrop-filter: none;
    position: relative;
}

/* Adjust main container to not overlap footer */
.container {
    padding-bottom: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scroll Offset for Fixed Header */
@media (max-width: 768px) {
    .container {
        padding-bottom: 30vh;
    }
}

/* --- History Modal Redesign --- */
.history-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem;
}

.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card);
    border-color: var(--primary);
    background: var(--surface);
    /* Use variable instead of white */
}

[data-theme="light"] .history-card:hover {
    background: white;
}

.h-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.h-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.h-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.h-badge.mcq {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.h-badge.qa {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.h-badge.both {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.h-content h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    line-height: 1.3;
    color: var(--text-primary);
}

.h-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
}

.h-hover-action {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

/* --- Quiz Overlay (Zen Mode) --- */
.quiz-overlay {
    position: fixed;
    inset: 0;
    /* Safer than 100vw/vh */
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    z-index: 5000;
    display: none;
    /* Default hidden, overridden by .hidden status or flex */
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.quiz-overlay:not(.hidden) {
    display: flex;
}

.quiz-container {
    width: 90%;
    max-width: 800px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.quiz-card-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.quiz-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid white;
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(99, 102, 241, 0.15);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-primary);
}

.q-text {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.q-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.option-btn {
    background: white;
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.option-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-hover);
}

.option-btn.selected {
    background: rgba(99, 102, 241, 0.15) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.option-btn.correct {
    background: rgba(34, 197, 94, 0.2) !important;
    border-color: #22c55e !important;
    color: #15803d !important;
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: #ef4444 !important;
    color: #b91c1c !important;
    opacity: 0.8;
}

/* Quiz Button Premium Style */
.btn-quiz {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-quiz:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6);
}

.btn-quiz::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 3s infinite;
}

#quiz-next-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    cursor: pointer;
}

#quiz-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}

/* Review Mode */
.review-list {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    margin: 1.5rem 0;
    padding-right: 0.5rem;
    padding-bottom: 2rem;
    /* Fix truncation of last item */
}

.review-item {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.review-item.incorrect {
    border-left: 4px solid #ef4444;
}

.review-item.correct {
    border-left: 4px solid #22c55e;
}

.review-q {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.review-ans {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.review-ans.bg-green {
    color: #15803d;
    font-weight: 600;
}

.review-ans.bg-red {
    color: #b91c1c;
    text-decoration: line-through;
    margin-right: 0.5rem;
}

.quiz-answer-display {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
}

.quiz-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    min-height: 60px;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

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

/* --- NEW Dropdown Styles --- */
.custom-dropdown-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    /* Glass effect */
    border: 1px solid var(--border);
    border-radius: 16px;
    /* Smooth corners */
    max-height: 300px;
    overflow-y: auto;
    z-index: 500;
    padding: 0.5rem;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    animation: fadeIn 0.2s ease-out;
}

.dropdown-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item:hover {
    background: var(--primary);
    color: white;
    transform: translateX(4px);
}

/* Dark Mode Dropdown Polish */
[data-theme="dark"] .custom-dropdown-list {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Force Dark Mode Visibility for Config Section */
[data-theme="dark"] .section-title {
    color: var(--text-primary);
}

[data-theme="dark"] .config-group label {
    color: var(--text-secondary);
}

[data-theme="dark"] .segmented-control {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .segmented-control label {
    color: var(--text-secondary);
}

[data-theme="dark"] .segmented-control input:checked+label {
    color: white;
}

/* Fix Mode Selection Cards in Dark Mode */
[data-theme="dark"] .mode-card {
    background: rgba(255, 255, 255, 0.05);
    /* Translucent dark */
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

[data-theme="dark"] .mode-card.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: white;
}

[data-theme="dark"] .mode-card h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .mode-card span {
    color: var(--text-secondary);
}

/* Fix Slider in Dark Mode */
[data-theme="dark"] .slider-wrapper {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .slider-val {
    color: var(--text-primary);
}

/* Fix Input Field Highlighting */
[data-theme="dark"] .modern-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

[data-theme="dark"] .modern-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* FIX: Config Group Background & Layout Context */
.config-group {
    position: relative;
    /* Ensure containment */
    z-index: 1;
    transform: translateZ(0);
    /* Force Hardware Acceleration/Composite Layer */
    isolation: isolate;
    /* Create new stacking context */
}

[data-theme="dark"] .config-group {
    background: #0f172a !important;
    /* Deep dark background */
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

/* Fix Mode Cards Z-Index overlap */
.mode-cards {
    position: relative;
    z-index: 2;
    transform: translateZ(0);
}

/* Ensure Glider doesn't fly away */
.segmented-control {
    position: relative;
    z-index: 1;
    overflow: hidden;
    /* Clip internal glider if it tries to escape */
    border-radius: 12px;
    /* Match border radius */
    transform: translateZ(0);
}

/* Fix Search Input Z-Index */
.searchable-select-wrapper {
    position: relative;
    z-index: 50;
    /* Ensure dropdown is on top */
}

/* Ensure Dropdown is visible */
[data-theme="dark"] .custom-dropdown-list {
    z-index: 100;
}