:root {
    /* Colors */
    --bg-app: #F5F7FF;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-panel: #ffffff;
    --primary: #140533;
    --primary-foreground: #ffffff;
    --primary-light: #2a0a5e;
    --accent: #7c3aed;
    --accent-light: #ede9fe;
    --accent-purple: #EBE4FF;
    --accent-pink: #FCEBEF;
    --accent-gradient: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    --text-main: #0B0B0B;
    --text-muted: #64748B;
    --border-subtle: rgba(20, 5, 51, 0.1);
    --border: #e2e8f0;

    /* Typography */
    --font-heading: 'Satoshi', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    /* Shadow */
    --shadow-soft: 0 10px 40px -10px rgba(20, 5, 51, 0.1);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05);

    /* Layout */
    --header-height: 72px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    padding-top: var(--header-height);
    /* Standard padding for fixed navbar */
}

/* Background Orbs (Common across Index, Search, Details) */
body::before {
    content: '';
    position: fixed;
    top: -10vh;
    left: -10vw;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
    opacity: 0.6;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10vh;
    right: -10vw;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--accent-pink) 0%, transparent 70%);
    opacity: 0.5;
    z-index: -1;
    filter: blur(80px);
    pointer-events: none;
}

/* Common Components */

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid white;
    box-shadow: 0 4px 20px -5px rgba(20, 5, 51, 0.05);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.nav-logo {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    /* Matches branding */
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

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

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg);
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    box-shadow: var(--shadow-card);
    outline: none;
    transition: all 0.2s;
}

.input-field:focus {
    box-shadow: 0 0 0 4px var(--accent-purple);
    border-color: var(--primary);
}

.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.promo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    height: 36px;
}

.promo-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 5, 51, 0.2);
}

/* Responsive Navbar Styles */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    padding: 8px;
}

.nav-menu {
    display: flex;
    gap: 16px;
    align-items: center;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 24px;
        flex-direction: column;
        align-items: flex-start;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
        display: none;
        /* Hidden by default */
        gap: 20px;
    }

    .nav-menu.open {
        display: flex;
        animation: slideDown 0.2s ease-out;
    }

    .nav-menu .nav-link,
    .nav-menu .promo-link {
        width: 100%;
        justify-content: flex-start;
        font-size: 1rem;
        padding: 10px 0;
    }

    .nav-menu .promo-link {
        justify-content: center;
        margin-top: 10px;
    }

    /* Hide nav search on mobile */
    .nav-search-container {
        display: none !important;
    }

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

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

/* UI Fixes Phase 6 */

/* Global Overflow Fix */
html,
body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
    overscroll-behavior-y: none;
    /* Prevent bounce */
}

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

/* Copy Buttons */
.btn-copy,
.btn-share-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
    white-space: nowrap;
    /* Prevent text wrapping inside button */
}

.btn-copy:hover,
.btn-share-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-copy:active,
.btn-share-link:active {
    transform: translateY(0);
}

/* Helper Classes */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    /* Hide button text on mobile */
    .btn-text {
        display: none;
    }

    /* Larger touch target */
    .btn-copy,
    .btn-share-link {
        padding: 0;
        border-radius: 50%;
        width: 44px;
        height: 44px;
        justify-content: center;
        flex-shrink: 0;
    }

    .btn-copy i,
    .btn-share-link i {
        margin: 0;
    }

    /* Scrollable Table Container */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 24px;
        border-radius: 8px;
        border: 1px solid var(--border-subtle);
    }

    .vars-table {
        min-width: 500px;
        /* Force minimum width to trigger scroll */
        margin-top: 0;
    }

    /* Fix SI Modal Overflow & Scrolling */
    .si-modal-overlay {
        align-items: flex-start !important;
        /* Allow top scrolling */
        overflow-y: auto !important;
        padding: 24px 16px !important;
    }

    .si-modal {
        max-width: 90vw !important;
        width: 100% !important;
        margin: 24px auto !important;
        position: relative;
    }

    .si-select-group {
        flex-direction: column;
        gap: 8px;
    }

    .si-select {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Ensure padding on mobile container */
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100vw;
    }

    /* Reduce Inner Card Padding */
    .details-card {
        padding: 24px !important;
    }

    .variation-section {
        padding: 20px !important;
    }

    /* Fix Reference Table Overlay */
    .ref-table-container {
        overflow-x: auto;
    }

    /* Ensure Nav Menu is on top */
    .nav-menu {
        z-index: 2000;
    }
}

/* Greek Table Row Interaction */
.greek-row {
    transition: background-color 0.2s;
}

.greek-row:hover {
    background-color: #f8fafc;
    cursor: pointer;
}