* {
    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;
}

.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;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));  /* 300px→280pxに変更 */
    gap: 16px;  /* 20px→16pxに変更 */
    background: #fffef7;
    padding: 24px 20px;  /* 少し詰める */
    border-radius: 32px;
    min-height: 500px;
}

.word-grid.detail-mode {
    display: block;
    padding: 28px 24px;
}

.word-card {
    background: #ffffff;
    border-radius: 16px;  /* 20px→16px */
    padding: 14px;  /* 18px→14px */
    cursor: pointer;
    border: 1px solid #ece2d4;
    transition: all 0.2s;
    position: relative;
}

.word-card:hover {
    transform: translateY(-4px);
    background: #fff9ef;
    border-color: #c0b28a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}


.word-text {
    font-size: 1.4rem;  /* 1.6rem→1.4rem */
    font-weight: 600;
    color: #2c5f2d;
    margin-bottom: 6px;
    padding-right: 30px;
}

.word-pinyin {
    font-size: 0.75rem;  /* 0.8rem→0.75rem */
    color: #b56a3c;
    background: #fef4e8;
    padding: 3px 8px;
    border-radius: 16px;
    display: inline-block;
    margin-bottom: 8px;
}

.word-meaning {
    font-size: 0.8rem;  /* 0.85rem→0.8rem */
    color: #4a5b4c;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;  /* 3→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;
}

.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;
}

.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;
}

.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;
}

.detail-japanese {
    background: #e8f0fe;
    padding: 12px 16px;
    border-radius: 16px;
    color: #1a3a6e;
}

.retry-link {
    background: transparent;
    border: 1px solid #1a3a6e;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.7rem;
    cursor: pointer;
    color: #1a3a6e;
    margin-top: 8px;
}

.retry-link:hover {
    background: #1a3a6e20;
}

@media (max-width: 768px) {
    body { padding: 1rem; }
    .word-grid { padding: 20px 16px; }
    .detail-view { padding: 20px 16px; }
    .detail-word { font-size: 2rem; }
    .toolbar { flex-direction: column; }
    .search-box { max-width: 100%; width: 100%; }
}