:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --card-bg: #f5f5f5;
    --accent-color: #4a90e2;
    --border-color: #e0e0e0;
    --hover-bg: #e8e8e8;
    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --card-bg: #2d2d2d;
    --accent-color: #4a90e2;
    --border-color: #404040;
    --hover-bg: #3d3d3d;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-color);
}

.header-controls {
    display: flex;
    gap: 10px;
}

.bookmark-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bookmark-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.02);
}

.bookmark-btn.has-bookmark {
    background: #fff9c4;
    border-color: #ffeb3b;
    color: #f57f17;
}

[data-theme="dark"] .bookmark-btn.has-bookmark {
    background: #3e3e29;
    border-color: #ffeb3b;
    color: #ffeb3b;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input-wrapper {
    display: flex;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    border: none;
    background: var(--card-bg);
    color: var(--text-color);
    outline: none;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    background: var(--accent-color);
    border: none;
    padding: 14px 20px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
}

.search-btn:hover {
    background: #3a80d2;
    transform: scale(1.05);
}

.search-btn:active {
    transform: scale(0.95);
}

.search-count {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #666;
    pointer-events: none;
}

[data-theme="dark"] .search-count {
    color: #999;
}

.word-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
}

.word-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.word-item:hover {
    background: var(--hover-bg);
    transform: translateX(5px);
    box-shadow: 0 2px 8px var(--shadow);
}

.word-item.bookmark-highlight {
    background: #fff9c4 !important;
    border-color: #ffeb3b !important;
    animation: bookmarkPulse 1s ease-in-out;
}

.word-item.search-highlight {
    background: #e3f2fd !important;
    border-color: #90caf9 !important;
    animation: searchPulse 1s ease-in-out;
}

[data-theme="dark"] .word-item.bookmark-highlight {
    background: #3e3e29 !important;
    border-color: #ffeb3b !important;
}

[data-theme="dark"] .word-item.search-highlight {
    background: #1e3a5f !important;
    border-color: #90caf9 !important;
}

@keyframes bookmarkPulse {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

@keyframes searchPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.word-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.word {
    font-size: 22px;
    font-weight: 600;
    font-family: Georgia, serif;
    color: var(--text-color);
}

.word mark {
    background: #ffeb3b;
    color: #333;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] .word mark {
    background: #f59e0b;
    color: #1a1a1a;
}

.translation mark {
    background: #ffeb3b;
    color: #333;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] .translation mark {
    background: #f59e0b;
    color: #1a1a1a;
}

.phonetic {
    font-size: 14px;
    color: #888;
    font-style: italic;
}

.translation {
    font-size: 15px;
    color: var(--text-color);
    opacity: 0.9;
}

.speak-btn {
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.speak-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.speak-btn:active {
    transform: scale(0.95);
}

.speak-btn.speaking {
    animation: pulse 0.6s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.bookmark-mini-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bookmark-mini-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.2);
}

[data-theme="dark"] .bookmark-mini-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    font-size: 16px;
    color: var(--text-color);
    opacity: 0.7;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-color);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #e74c3c;
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-color);
    opacity: 0.8;
}

.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.4);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 24px;
    }

    .bookmark-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .word-item {
        padding: 14px 16px;
        margin-bottom: 8px;
    }

    .word {
        font-size: 20px;
    }

    .phonetic {
        font-size: 13px;
    }

    .translation {
        font-size: 14px;
    }

    .speak-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .bookmark-mini-btn {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .header-controls {
        order: 2;
    }

    .header h1 {
        order: 1;
    }

    .search-input {
        font-size: 15px;
        padding: 12px 15px;
    }

    .search-btn {
        padding: 12px 15px;
        font-size: 16px;
    }
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--accent-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
