:root {
    --primary-color: #2563eb;
    --secondary-color: #eff6ff;
    --accent-color: #f97316;
    --text-color: #1e293b;
    --light-bg: #f8fafc;
    --card-shadow: 0 4px 12px rgba(0,0,0,0.15);
    --correct-color: #10b981;
    --incorrect-color: #ef4444;
}

.mode-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body { margin: 0; padding: 0; }
body {
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.2);
    position: relative;
    overflow: hidden;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1rem;
    align-items: center;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

#search-input { padding: 0.5rem 1rem; border: 2px solid #ddd; border-radius: 4px; font-size: 1rem; width: 250px; transition: border-color 0.3s; } #search-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }

#search-btn {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#search-btn:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

.mode-selector {
    display: flex;
    gap: 0.5rem;
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: white;
    color: var(--text-color);
    transition: all 0.3s;
    transform: translateY(0);
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

.progress-tracker {
    flex-grow: 1;
    min-width: 200px;
}

.grammar-link { display: inline-block; margin: 10px 0; padding: 8px 15px; background-color: var(--primary-color); color: white; text-decoration: none; border-radius: 4px; font-weight: bold; transition: transform 0.2s; }
.grammar-link:hover { background-color: #1d4ed8; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2); }

.back-to-home { position: fixed; bottom: 20px; right: 20px; padding: 12px 20px; background-color: var(--accent-color); color: white; text-decoration: none; border-radius: 50px; box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3); font-weight: bold; z-index: 1000; transition: all 0.3s; display: block; transform: translateZ(0); -webkit-transform: translateZ(0); }
.back-to-home:hover { background-color: #27ae60; }

.back-to-top { position: fixed; bottom: 90px; right: 20px; padding: 12px 20px; background-color: var(--primary-color); color: white; text-decoration: none; border-radius: 50px; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); font-weight: bold; z-index: 1000; transition: all 0.3s; display: block; transform: translateZ(0); -webkit-transform: translateZ(0); }
.back-to-top:hover { background-color: #2980b9; }
.progress-bar {
    height: 8px;
    background-color: #ddd;
    border-radius: 4px;
    margin-top: 0.3rem;
    overflow: hidden;
}

#progress-fill { height: 100%; background-color: var(--correct-color); transition: width 0.5s ease-out, background-color 0.3s; animation: pulse 2s infinite ease-in-out; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }

.learning-tools {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.learning-tools button {
    padding: 0.5rem 1.2rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    transform: translateY(0);
}

.learning-tools button:hover {
    background-color: var(--primary-color);
}

.mode-content {
    display: none;
}

#test-mode {
    text-align: center;
    padding: 2rem;
}

.test-card { max-width: 600px; margin: 0 auto; background-color: white; padding: 2rem; border-radius: 10px; box-shadow: var(--card-shadow); transition: transform 0.3s, box-shadow 0.3s; border-top: 4px solid var(--primary-color); }

#test-question {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.test-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.test-option {
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.test-option:hover { border-color: var(--accent-color); transform: scale(1.02); transition: all 0.2s; }

.test-option.correct { background-color: rgba(16, 185, 129, 0.2); border-color: var(--correct-color); color: var(--correct-color); font-weight: bold; }

.test-option.incorrect { background-color: rgba(239, 68, 68, 0.2); border-color: var(--incorrect-color); color: var(--incorrect-color); font-weight: bold; }

#test-result {
    font-size: 1.2rem;
    font-weight: bold;
    height: 2rem;
}

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

.unit-navigation { background-color: white; border-radius: 8px; padding: 1rem; box-shadow: var(--card-shadow); margin-bottom: 2rem; 
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 1rem 0;
    margin-bottom: 2rem;
    justify-content: center;
    scrollbar-width: thin;
}

.unit-btn {
    background-color: white;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    font-weight: 500;
}

.unit-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.unit-btn:hover:not(.active) {
    background-color: var(--secondary-color);
}

.word-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    padding: 15px;
}

@media (max-width: 375px) {
    .word-container {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
        padding: 10px;
    }
    .controls, .mode-controls, .tool-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    .mode-btn, .tool-btn {
        margin: 5px;
    }
}

/* 移动端触摸优化 */
.unit-btn, .mode-btn, .tool-btn {
    min-height: 48px;
    min-width: 48px;
    touch-action: manipulation;
}

test-option {
    padding: 15px;
    margin: 10px 0;
}

.word-card .word {
    font-size: 18px;
    padding: 8px 0;
}

.word-card {
    background-color: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.word-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.word-card .learned-checkbox {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

.learned {
    opacity: 0.7;
    position: relative;
}

.learned::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    color: #4CAF50;
    font-size: 1.5rem;
    font-weight: bold;
}

.word {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.word:hover {
    text-decoration: underline;
}

.phonetic {
    color: #666;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.pos {
    display: inline-block;
    background-color: var(--secondary-color);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 0.8rem;
}

.meaning {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
}

example {
    color: #555;
    font-style: italic;
    border-left: 3px solid var(--accent-color);
    padding-left: 1rem;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .word-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    header h1 {
        font-size: 1.8rem;
    }
}