:root {
    /* Apple Liquid Glass Palette */
    --glass-bg-light: rgba(255, 255, 255, 0.65);
    --glass-bg-dark: rgba(28, 28, 30, 0.65);
    --glass-border-light: rgba(255, 255, 255, 0.4);
    --glass-border-dark: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    --text-primary: #000000;
    --text-secondary: #86868b;
    --accent-color: #007AFF;
    /* Apple Blue */
    --accent-gradient: linear-gradient(135deg, #007AFF, #00C6FF);

    --radius-l: 24px;
    --radius-m: 16px;
    --radius-s: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #FFFFFF;
        --text-secondary: #98989d;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f5f5f7;
    /* Apple Light Grey */
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.47059;
    letter-spacing: -0.022em;
    overflow-x: hidden;
    min-height: 100vh;
    padding-bottom: 100px;
    /* Space for floating nav */
}

/* Fluid Animated Background */
.fluid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #f5f5f7;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #ff9a9e;
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: #a18cd1;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 40vw;
    height: 40vw;
    background: #fad0c4;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(30px, 50px) rotate(20deg);
    }
}

/* Glassmorphism Utility */
.glass {
    background: var(--glass-bg-light);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border-light);
    box-shadow: var(--glass-shadow);
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: #000000;
    }

    .fluid-bg {
        background: #000000;
    }

    .glass {
        background: var(--glass-bg-dark);
        border: 1px solid var(--glass-border-dark);
    }

    .blob {
        opacity: 0.4;
    }
}

/* Layout */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-top: calc(60px + env(safe-area-inset-top));
}

/* Typography */
h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.004em;
    margin-bottom: 12px;
    text-align: center;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

h3 {
    font-size: 19px;
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 24px;
}

/* Navbar */
.top-navbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 560px;
    height: 50px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    /* Glass Effect applied via class in HTML */
}

.header-logo {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.022em;
}

/* Cards & Lists */
.section-list {
    border-radius: var(--radius-l);
    overflow: hidden;
    margin-bottom: 24px;
    /* Glass Effect applied via class in HTML */
}

.mode-card {
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    text-align: left;
    padding: 20px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
}

.mode-card:active {
    background: rgba(0, 0, 0, 0.05);
}

.mode-card:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 76px;
    /* Align with text */
    right: 0;
    height: 1px;
    background: rgba(128, 128, 128, 0.2);
}

.card-icon-container {
    margin-right: 16px;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Liquid Gradients for Icons */
.exam-mode .card-icon {
    background: linear-gradient(135deg, #34C759, #30B34E);
}

.training-mode .card-icon {
    background: linear-gradient(135deg, #007AFF, #0055FF);
}

.share-mode .card-icon {
    background: linear-gradient(135deg, #AF52DE, #9042BE);
}

.card-content {
    flex: 1;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.card-status {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Progress Bars */
.linear-progress-container {
    height: 6px;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.linear-progress-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 3px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    border-radius: var(--radius-m);
    border: none;
    cursor: pointer;
    width: 100%;
    margin-bottom: 16px;
    transition: transform 0.2s, opacity 0.2s;
}

.btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--accent-color);
}

/* Language Selection */
.language-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.language-btn {
    width: 100%;
    text-align: left;
    padding: 18px 24px;
    background: var(--glass-bg-light);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border-light);
    border-radius: var(--radius-m);
    font-size: 17px;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.2s;
}

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

/* Test Interface */
.question-card {
    padding: 32px 24px;
    border-radius: var(--radius-l);
    margin-bottom: 24px;
    /* Glass Effect applied via class */
}

.question-text {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 24px;
}

.question-image {
    width: 100%;
    border-radius: var(--radius-m);
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-option {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-m);
    font-size: 17px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.answer-option:active {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(0.99);
}

.answer-option.selected {
    border-color: var(--accent-color);
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent-color);
    font-weight: 600;
}

.answer-option.correct {
    border-color: #34C759;
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.answer-option.incorrect {
    border-color: #FF3B30;
    background: rgba(255, 59, 48, 0.15);
    color: #D70015;
}

/* Bottom Sheet */
#explanationContainer {
    position: fixed;
    bottom: 24px;
    left: 20px;
    right: 20px;
    width: auto;
    border-radius: var(--radius-l);
    padding: 24px;
    z-index: 200;
    animation: slideUp 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    /* Glass Effect applied via class */
}

@keyframes slideUp {
    from {
        transform: translateY(120%);
    }

    to {
        transform: translateY(0);
    }
}

.result-indicator {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bottom Navigation (Floating Glass Pill) */
.bottom-nav-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 280px;
    background: rgba(20, 20, 20, 0.85);
    /* Darker glass for contrast */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 100px;
    padding: 12px 30px;
    z-index: 90;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.bottom-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.3s;
}

.nav-item svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active {
    color: #BF5AF2;
    /* Apple Purple */
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 85%;
    max-width: 340px;
    border-radius: var(--radius-l);
    padding: 24px;
    animation: scaleIn 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    /* Glass Effect applied via class */
}

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

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

/* Result Page */
.result-card {
    text-align: center;
    padding: 40px 20px;
}

.result-score {
    font-size: 56px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 10px 0;
}

.stat-box {
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-m);
    padding: 16px;
    min-width: 100px;
}

/* Loading */
.loading {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 122, 255, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Page Transitions */
.page {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page.active {
    display: block;
}

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

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