:root {
    --primary-color: #500000;
    --secondary-color: #683119;
    --accent-color: #ee8823;
    --refresh-color: #9e3f31;
    --background-color: #faf7f5;
    --card-background: #fffafa;
    --text-color: #222222;
    --border-color: #e8e4e1;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --stats-bg: rgba(165, 111, 74, 0.1);
}

.dark-mode {
    --primary-color: #d37e5d;
    --secondary-color: #e8cab0;
    --accent-color: #885139;
    --refresh-color: #c27743;
    --background-color: #210b01;
    --card-background: #3a1c15;
    --text-color: #e6e1e0;
    --border-color: #9a8a80;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --stats-bg: rgba(187, 140, 107, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Times New Roman', 'Noto Serif SC', serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 15px;
    font-size: 16px;
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}

h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.stats-container {
    background-color: var(--stats-bg);
    border-radius: 10px;
    padding: 12px 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.controls-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    /* 使搜索控件在向下滚动时固定在页面顶部 */
    position: sticky;
    top: 0;
    z-index: 150;
    /* 保持背景以避免内容透出并让粘性区域看起来自然 */
    background-color: none;
    /* 小内边距和阴影，让固定时更明显且不影响布局 */
    padding-top: 8px;
    padding-bottom: 8px;   
}

.search-container {
    flex: 1;
    position: relative;
}

#search {
    width: 100%;
    padding: 14px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    background-color: var(--card-background);
    color: var(--text-color);
}

#search:focus {
    border-color: var(--primary-color);
}

#search-btn {
    position: absolute;
    right: 5px;
    top: 5px;
    height: calc(100% - 10px);
    padding: 0 15px;
    background-color: var(--refresh-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

#search-btn:hover {
    background-color: var(--secondary-color);
}

#refresh-btn {
    padding: 0 20px;
    background-color: var(--refresh-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#refresh-btn:hover {
    background-color: var(--secondary-color);
}

.dictionary-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 80px;
}

.word-card {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform 0.2s;
}

.word-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px var(--shadow-color);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.word-title {
    font-size: 1.6rem;
    color: var(--primary-color);
    font-weight: bold;
    margin-right: 15px;
}

.phonetic {
    color: var(--secondary-color);
    font-style: italic;
    font-size: 0.95rem;
}

.part-of-speech {
    font-weight: bold;
    margin-top: 8px;
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.grammar-info {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.grammar-tag {
    background-color: var(--refresh-color);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
}

.definition {
    margin-left: 5px;
    margin-bottom: 10px;
    line-height: 1.5;
}

.example {
    margin-left: 15px;
    font-style: italic;
    color: var(--secondary-color);
    border-left: 2px solid var(--secondary-color);
    padding-left: 10px;
    margin-top: 8px;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--primary-color);
    padding: 5px;
}

.no-results {
    text-align: center;
    padding: 30px;
    color: var(--secondary-color);
    font-style: italic;
}

.settings-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

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

.modal-title {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

.setting-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.setting-section:last-child {
    border-bottom: none;
}

.setting-title {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.theme-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.random-count-options {
    display: flex;
    gap: 10px;
}

.count-option {
    flex: 1;
    text-align: center;
}

.count-option input[type="radio"] {
    display: none;
}

.count-option label {
    display: block;
    padding: 10px;
    background-color: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.count-option input[type="radio"]:checked+label {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--primary-color);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-background);
    color: var(--text-color);
    font-size: 1rem;
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-background);
    color: var(--text-color);
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    margin-top: 10px;
}

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

.grammar-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: fadeInOut 3s forwards;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        top: 0;
    }

    10% {
        opacity: 1;
        top: 20px;
    }

    90% {
        opacity: 1;
        top: 20px;
    }

    100% {
        opacity: 0;
        top: 0;
        visibility: hidden;
    }
}

@media (min-width: 768px) {
    body {
        padding: 20px;
        font-size: 17px;
    }

    .container {
        max-width: 700px;
    }

    .grammar-options {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-container {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .word-title {
        font-size: 1.4rem;
    }

    .grammar-options {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 15px;
    }

    .stats-container {
        flex-direction: column;
        gap: 10px;
    }

    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .controls-container {
        flex-direction: column;
    }

    #refresh-btn {
        padding: 12px;
    }
}

/* 在 styles.css 末尾添加以下样式 */

.import-export-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.3s;
}

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

.file-input-container {
    margin-top: 10px;
}

.file-info {
    margin-top: 10px;
    padding: 10px;
    background-color: var(--stats-bg);
    border-radius: 5px;
    font-size: 0.9rem;
}

.confirm-import {
    margin-top: 10px;
    display: none;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    flex: 1;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    flex: 1;
}
