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

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #e1e8ed;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

header {
    text-align: center;
    margin-bottom: 16px;
}

header h1 {
    font-size: 1.5em;
    color: var(--primary);
    margin-bottom: 8px;
}

.stats-bar {
    font-size: 0.85em;
    color: var(--text-light);
}

.stats-bar span {
    margin: 0 12px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    min-width: 60px;
    padding: 10px 8px;
    border: none;
    background: var(--card-bg);
    color: var(--text-light);
    font-size: 0.9em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.tab:hover:not(.active) {
    background: var(--border);
}

/* Controls */
.controls {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.filter-row select {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9em;
    background: white;
}

.view-options {
    display: flex;
    gap: 16px;
}

.view-options label {
    font-size: 0.85em;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Panels */
.panel {
    display: none;
}

.panel.active {
    display: block;
}

/* Word List */
.word-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.word-card {
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
}

.word-card:active {
    transform: scale(0.98);
}

.word-card .word-english {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.word-card .word-phonetic {
    font-size: 0.85em;
    color: var(--text-light);
    margin-bottom: 4px;
}

.word-card .word-meaning {
    font-size: 0.9em;
    color: var(--text);
}

.word-card .fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    color: var(--warning);
    padding: 4px;
}

.word-card .fav-btn.unfavorited {
    color: var(--border);
}

.word-card .unit-tag {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.7em;
    color: var(--text-light);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Player */
.player-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.player-card, .dict-card, .ra-card {
    background: var(--card-bg);
    padding: 32px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.card-english {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.card-phonetic {
    font-size: 1.2em;
    color: var(--text-light);
    margin-bottom: 12px;
}

.card-meaning {
    font-size: 1.3em;
    color: var(--text);
}

.card-progress, .dict-progress, .ra-progress {
    margin-top: 16px;
    font-size: 0.85em;
    color: var(--text-light);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-icon {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d8de;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-danger.recording {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.btn-icon {
    background: var(--border);
    color: var(--text);
    padding: 8px 12px;
    font-size: 1.1em;
}

.loop-label {
    font-size: 0.85em;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dictation */
.dict-controls, .ra-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dict-input {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.2em;
    text-align: center;
    margin: 16px 0;
    outline: none;
    transition: border-color 0.2s;
}

.dict-input:focus {
    border-color: var(--primary);
}

.dict-result {
    font-size: 1.1em;
    font-weight: 600;
    min-height: 1.5em;
}

.dict-result.correct {
    color: var(--success);
}

.dict-result.wrong {
    color: var(--danger);
}

.dict-phonetic {
    font-size: 1.5em;
    color: var(--text-light);
}

.answer-word {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary);
    margin-top: 16px;
}

.answer-meaning {
    font-size: 1.1em;
    color: var(--text);
    margin-top: 8px;
}

/* Read-along */
.ra-word {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary);
}

.ra-phonetic {
    font-size: 1.1em;
    color: var(--text-light);
    margin: 8px 0;
}

.ra-meaning {
    font-size: 1.1em;
    color: var(--text);
}

.ra-status {
    margin-top: 16px;
    font-size: 0.9em;
    color: var(--text-light);
}

.ra-result {
    font-size: 1em;
    font-weight: 600;
    margin-top: 8px;
    min-height: 1.2em;
}

.ra-result.good {
    color: var(--success);
}

.ra-result.bad {
    color: var(--danger);
}

/* Empty state */
.empty-msg {
    text-align: center;
    padding: 48px;
    color: var(--text-light);
    font-size: 1em;
}

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

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

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

/* Mobile */
@media (max-width: 600px) {
    #app {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.2em;
    }
    
    .card-english {
        font-size: 2em;
    }
    
    .tabs {
        gap: 2px;
    }
    
    .tab {
        padding: 8px 4px;
        font-size: 0.8em;
    }
}
