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

:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --danger-color: #F44336;
    --accent-color: #9C27B0;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --paper-texture: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><filter id="paper"><feTurbulence baseFrequency="0.04" numOctaves="5" result="noise"/><feDiffuseLighting in="noise" lighting-color="white" surfaceScale="1"><feDistantLight azimuth="45" elevation="60"/></feDiffuseLighting></filter></defs><rect width="100%" height="100%" fill="white" filter="url(%23paper)"/></svg>');
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    background-image: var(--paper-texture);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 80px;
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.welcome-card, .test-container, .comprehension-container, 
.exercises-container, .progress-container, .faq-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.welcome-card h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-card i {
    font-size: 1.5rem;
    opacity: 0.8;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Buttons */
.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-primary { background: var(--primary-color); }
.btn-secondary { background: var(--text-secondary); }
.btn-success { background: var(--success-color); }
.btn-warning { background: var(--warning-color); color: var(--text-primary); }
.btn-danger { background: var(--danger-color); }

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

/* Test Controls */
.test-controls {
    text-align: center;
    margin-bottom: 2rem;
}

.timer-display {
    text-align: center;
    font-size: 2rem;
    color: var(--primary-color);
    margin: 1rem 0;
    font-weight: bold;
}

.text-display {
    background: var(--background);
    padding: 2rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
    font-size: 1.1rem;
    line-height: 1.8;
}

.test-results {
    background: var(--success-color);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Comprehension */
.question-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.options-container {
    margin: 1rem 0;
}

.option-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 2px solid var(--border);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: var(--primary-color);
    background: rgba(33, 150, 243, 0.05);
}

.option-btn.selected {
    border-color: var(--primary-color);
    background: rgba(33, 150, 243, 0.1);
}

.comprehension-score, .final-score {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* Exercises */
.exercise-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.exercise-controls {
    text-align: center;
    margin: 1rem 0;
}

.exercise-area {
    height: 300px;
    background: var(--background);
    border-radius: 8px;
    position: relative;
    border: 2px dashed var(--border);
    margin: 1rem 0;
}

.moving-dot {
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s linear;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

.counter-display {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: bold;
    margin: 1rem 0;
}

.reading-exercise {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1.8;
    margin: 1rem 0;
}

/* Progress */
.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.progress-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.progress-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--primary-color);
}

.history-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.history-stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.no-data {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem;
}

/* FAQ */
.faq-list {
    space-y: 1rem;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: var(--surface);
    border: none;
    padding: 1rem;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.faq-question:hover {
    background: var(--background);
}

.faq-question[aria-expanded="true"] {
    background: var(--primary-color);
    color: white;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-icon {
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.faq-answer {
    padding: 0 1rem;
    background: var(--background);
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease-out;
}

.faq-answer.show {
    max-height: 200px;
    padding: 1rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 60px;
}

.nav-item.active {
    color: var(--primary-color);
    background: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Footer */
footer {
    background: var(--text-secondary);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        padding: 0.5rem;
    }
    
    .welcome-card, .test-container, .comprehension-container, 
    .exercises-container, .progress-container, .faq-container {
        padding: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .progress-stats {
        grid-template-columns: 1fr;
    }
    
    .history-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .exercise-area {
        height: 200px;
    }
    
    .text-display {
        padding: 1rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.2rem;
    }
    
    .timer-display {
        font-size: 1.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .nav-item span {
        font-size: 0.6rem;
    }
    
    .nav-item i {
        font-size: 1rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus States */
.btn:focus, .tab-btn:focus, .faq-question:focus, .option-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: rgba(33, 150, 243, 0.2);
}

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

::-webkit-scrollbar-track {
    background: var(--background);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
