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

body {
    background: #f5f2eb;
    font-family: 'Noto Sans CJK SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    padding: 2rem 1.5rem;
    color: #1e2a2e;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.9rem;
    font-weight: 500;
    background: linear-gradient(135deg, #2c5f2d, #5f8b4c);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    display: inline-block;
}

.sub {
    margin-top: 0.5rem;
    color: #4a5b4c;
    font-size: 0.9rem;
}

.stats {
    background: #e9e2d4;
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 40px;
    font-size: 0.85rem;
    margin-top: 0.8rem;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background: #fffaf3;
    padding: 12px 20px;
    border-radius: 48px;
}

.search-box {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid #e3d9cb;
    border-radius: 40px;
    font-size: 0.9rem;
    background: white;
}

.search-btn {
    background: #2c5f2d;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    cursor: pointer;
}

.search-btn:hover {
    background: #1f4820;
}

.info-badge {
    font-size: 0.85rem;
    background: #e7dfd3;
    padding: 4px 12px;
    border-radius: 32px;
}

.legend {
    display: flex;
    gap: 20px;
    font-size: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.upload-area {
    background: #2c5f2d20;
    border: 2px dashed #2c5f2d;
    border-radius: 40px;
    padding: 6px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.upload-area:hover {
    background: #2c5f2d40;
}

.quiz-trigger-btn {
    background: #2c5f2d;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 600;
}

.quiz-trigger-btn:hover {
    background: #1f4820;
}

.pagination-wrapper {
    background: #fffaf3;
    border-radius: 20px;
    padding: 12px 20px;
    margin-bottom: 20px;
}

.pagination-info {
    text-align: center;
    font-size: 0.85rem;
    color: #8b7355;
    margin-bottom: 10px;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.page-nav-btn {
    background: #e9e2d4;
    border: none;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-nav-btn:hover:not(:disabled) {
    background: #c0b28a;
    color: white;
}

.page-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 4px 12px;
    border-radius: 30px;
    border: 1px solid #e3d9cb;
}

.page-input {
    width: 60px;
    text-align: center;
    border: none;
    font-size: 0.9rem;
    padding: 4px 0;
    outline: none;
}

.page-go-btn {
    background: #2c5f2d;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    cursor: pointer;
}

.page-go-btn:hover {
    background: #1f4820;
}

.page-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.page-number-btn {
    background: #e9e2d4;
    border: none;
    min-width: 36px;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-number-btn:hover {
    background: #c0b28a;
    color: white;
}

.page-number-btn.active {
    background: #2c5f2d;
    color: white;
}

.chengyu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    background: #fffef7;
    padding: 28px 24px;
    border-radius: 32px;
    min-height: 500px;
}

.chengyu-grid.detail-mode {
    display: block;
    padding: 28px 24px;
}

.chengyu-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 18px;
    cursor: pointer;
    border: 1px solid #ece2d4;
    transition: all 0.2s;
    position: relative;
}

.chengyu-card:hover {
    transform: translateY(-4px);
    background: #fff9ef;
    border-color: #c0b28a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chengyu-word {
    font-size: 1.6rem;
    font-weight: 600;
    color: #2c5f2d;
    margin-bottom: 8px;
    padding-right: 30px;
}

.chengyu-pinyin {
    font-size: 0.8rem;
    color: #b56a3c;
    background: #fef4e8;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 10px;
}

.chengyu-explanation {
    font-size: 0.85rem;
    color: #4a5b4c;
    line-height: 1.5;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chengyu-example {
    font-size: 0.75rem;
    color: #8b7355;
    border-top: 1px dashed #ece2d4;
    padding-top: 8px;
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.img-search-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    padding: 4px;
}

.img-search-btn:hover {
    opacity: 1;
}

.detail-view-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 500px;
}

.detail-view {
    background: #fffef7;
    border-radius: 32px;
    padding: 32px 40px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.detail-word {
    font-size: 3rem;
    font-weight: 600;
    color: #2c5f2d;
    margin-bottom: 16px;
    text-align: center;
}

.detail-pinyin {
    font-size: 1.2rem;
    color: #b56a3c;
    background: #fef4e8;
    padding: 6px 16px;
    border-radius: 40px;
    display: inline-block;
    margin-bottom: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-label {
    font-weight: 600;
    color: #2c5f2d;
    font-size: 1rem;
    margin-bottom: 8px;
    border-left: 3px solid #2c5f2d;
    padding-left: 12px;
}

.detail-content {
    font-size: 0.95rem;
    color: #4a5b4c;
    line-height: 1.6;
    padding-left: 15px;
}

.detail-example {
    background: #faf6ef;
    padding: 12px 16px;
    border-radius: 16px;
    font-style: italic;
}

.back-btn {
    background: #e9e2d4;
    border: none;
    padding: 8px 24px;
    border-radius: 40px;
    cursor: pointer;
    margin-bottom: 24px;
    font-size: 0.9rem;
    display: inline-block;
}

.back-btn:hover {
    background: #d4c9b6;
}

.detail-img-search {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #ece2d4;
}

.quiz-container-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 500px;
}

.quiz-card {
    background: #faf6ef;
    border-radius: 48px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 32px 24px 40px;
    text-align: center;
    box-shadow: 0 12px 24px rgba(0,0,0,0.05);
    border: 1px solid #ece2d4;
}

.quiz-hanzi {
    font-size: 3rem;
    font-weight: 600;
    color: #2c5f2d;
    background: #fff2e2;
    display: inline-block;
    padding: 12px 32px;
    border-radius: 80px;
    margin: 16px 0 8px;
    letter-spacing: 6px;
}

.quiz-pinyin {
    font-size: 1.2rem;
    color: #b56a3c;
    background: #fef4e8;
    padding: 8px 20px;
    border-radius: 40px;
    display: inline-block;
    margin: 8px 0 20px;
    letter-spacing: 1px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 28px 0 24px;
}

.quiz-opt-btn {
    background: white;
    border: 2px solid #e3d9cb;
    border-radius: 16px;
    padding: 12px 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    text-align: left;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.quiz-opt-btn:hover:not(:disabled) {
    background: #e9f0e3;
    border-color: #9bb87f;
    transform: translateY(-2px);
}

.quiz-opt-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.quiz-feedback {
    border-radius: 16px;
    padding: 12px 20px;
    font-size: 0.95rem;
    margin: 12px auto;
    display: inline-block;
    max-width: 90%;
    text-align: left;
}

.quiz-feedback.correct {
    background: #d9e6c3;
    color: #2c5f2d;
    border-left: 4px solid #4c9a2a;
}

.quiz-feedback.wrong {
    background: #ffe1de;
    color: #bc4e2c;
    border-left: 4px solid #c73f1e;
}

.quiz-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.quiz-btn {
    background: #e9e2d4;
    border: none;
    padding: 8px 28px;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.quiz-btn.primary {
    background: #2c5f2d;
    color: white;
}

.quiz-status {
    font-size: 0.8rem;
    color: #8b7355;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px dashed #e3d9cb;
}

.loading-placeholder {
    text-align: center;
    padding: 60px;
    background: #faf3e8;
    border-radius: 40px;
    color: #a27b5c;
}

footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.75rem;
    color: #7b6e58;
    padding-top: 24px;
    border-top: 1px dashed #ddd0be;
}

.dict-status {
    background: #e9e2d4;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.75rem;
    color: #2c5f2d;
    max-width: 500px;
    margin: 0 auto 12px;
    text-align: center;
}

/* 自动翻译进度条 */
.auto-translate-progress {
    background: #e8f0fe;
    border-radius: 20px;
    padding: 10px 16px;
    margin: 0 auto 12px;
    max-width: 600px;
    text-align: center;
    border: 1px solid #1a3a6e20;
}

.auto-translate-progress .progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #1a3a6e;
}

.stop-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
}

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

/* 自动翻译按钮 */
.auto-translate-btn {
    background: #2c5f2d;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 40px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auto-translate-btn:hover {
    background: #1f4820;
}

.auto-translate-btn.running {
    background: #e67e22;
}

.auto-translate-btn.running:hover {
    background: #d35400;
}

/* 重新翻译按钮等待状态 */
.retry-translate-btn.waiting {
    background: #95a5a6;
    color: white;
    cursor: not-allowed;
    opacity: 0.7;
}

.retry-translate-btn.waiting:hover {
    background: #95a5a6;
    transform: none;
}

@media (max-width: 768px) {
    body { padding: 1rem; }
    .chengyu-grid { padding: 20px 16px; }
    .detail-view { padding: 20px 16px; }
    .detail-word { font-size: 2rem; }
    .detail-pinyin { font-size: 0.9rem; }
    .detail-content { font-size: 0.85rem; }
    .quiz-hanzi { font-size: 2rem; letter-spacing: 3px; }
    .quiz-pinyin { font-size: 0.9rem; }
    .quiz-opt-btn { font-size: 0.8rem; padding: 8px 14px; }
    .toolbar { flex-direction: column; }
    .search-box { max-width: 100%; width: 100%; }
    .pagination-controls { gap: 8px; }
    .page-nav-btn { padding: 4px 10px; font-size: 0.75rem; }
}
/* 日语翻译模式按钮 */
.translate-mode-btn {
    background: #e9e2d4;
    color: #4a5b4c;
    border: none;
    padding: 6px 16px;
    border-radius: 40px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.translate-mode-btn.active {
    background: #1a3a6e;
    color: white;
}

.translate-mode-btn.active:hover {
    background: #0f2a52;
}

.translate-mode-btn:hover:not(.active) {
    background: #c0b28a;
    color: white;
}

.translation-status {
    background: #e8f0fe;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.75rem;
    color: #1a3a6e;
    max-width: 500px;
    margin: 0 auto 12px;
    text-align: center;
    border: 1px solid #1a3a6e20;
}

.translation-status .progress-bar {
    background: #1a3a6e20;
    border-radius: 10px;
    height: 6px;
    margin-top: 6px;
    overflow: hidden;
}

.translation-status .progress-fill {
    background: #1a3a6e;
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* 日语释义样式 */
.japanese-meaning {
    font-size: 0.75rem;
    color: #1a3a6e;
    background: #e8f0fe;
    padding: 4px 8px;
    border-radius: 8px;
    margin-top: 6px;
    border-left: 3px solid #1a3a6e;
}

.detail-japanese {
    background: #e8f0fe;
    padding: 12px 16px;
    border-radius: 16px;
    color: #1a3a6e;
}
