.dict-app {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

/* Top bar */
.dict-topbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.dict-search {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.dict-search:focus { border-color: var(--primary-light); }

.dict-scan-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.dict-scan-btn:hover { background: var(--primary-dark); }

/* Category chips */
.dict-cats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.dict-cat-chip {
    padding: 4px 12px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.dict-cat-chip:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.dict-cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Word grid */
.dict-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.dict-card {
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.dict-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}

.dict-card-thai {
    font-size: 28px;
    line-height: 1.3;
    margin-bottom: 6px;
}

.dict-card-english {
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 6px;
}

.dict-card-cat {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 999px;
    background: #e8f5e9;
    color: var(--primary-dark);
}

/* Word popup */
.dict-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
}
.dict-backdrop.open { display: block; }

.dict-popup {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    z-index: 101;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    max-height: 75vh;
    overflow-y: auto;
}
.dict-popup.open { display: block; }

@media (min-width: 640px) {
    .dict-popup {
        top: 50%;
        left: 50%;
        bottom: auto;
        right: auto;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 380px;
        border-radius: 16px;
    }
}

.dict-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
}
.dict-popup-close:hover { background: var(--border); }

.dict-popup-thai {
    font-size: 64px;
    text-align: center;
    margin-bottom: 8px;
    line-height: 1.2;
}

.dict-popup-english {
    font-size: 18px;
    color: var(--text-2);
    text-align: center;
    margin-bottom: 8px;
}

.dict-popup-cat {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-dark);
    background: #e8f5e9;
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    margin: 0 auto 16px;
    display: block;
    width: fit-content;
}

.dict-popup-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    margin-bottom: 10px;
    transition: background 0.15s;
}
.dict-popup-audio:hover { background: #2a75d0; }

.dict-popup-add {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s;
}
.dict-popup-add:hover { background: var(--primary-dark); }

/* Scan modal */
.dict-scan-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}
.dict-scan-backdrop.open { display: block; }

.dict-scan-modal {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    z-index: 201;
    max-height: 90vh;
    overflow-y: auto;
}
.dict-scan-modal.open { display: flex; flex-direction: column; }

@media (min-width: 640px) {
    .dict-scan-modal {
        top: 50%;
        left: 50%;
        bottom: auto;
        right: auto;
        transform: translate(-50%, -50%);
        width: 92%;
        max-width: 520px;
        border-radius: 16px;
    }
}

.dict-scan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.dict-scan-header h3 { font-size: 16px; font-weight: 700; }

.dict-scan-close {
    background: var(--bg-2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
}

.dict-scan-body { padding: 16px 20px; }

.dict-scan-preview {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.dict-scan-preview canvas { max-width: 100%; display: block; }
.dict-scan-placeholder { color: #fff; font-size: 13px; text-align: center; padding: 20px; }

.dict-scan-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.dict-scan-camera-btn,
.dict-scan-upload-btn,
.dict-scan-ocr-btn {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
}

.dict-scan-camera-btn {
    background: var(--secondary);
    color: #fff;
}
.dict-scan-camera-btn:hover { background: #2a75d0; }

.dict-scan-upload-btn {
    background: var(--bg-2);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.dict-scan-upload-btn:hover { background: var(--border); }

.dict-scan-ocr-btn {
    background: var(--primary);
    color: #fff;
}
.dict-scan-ocr-btn:hover { background: var(--primary-dark); }

.dict-scan-status {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 10px;
    min-height: 18px;
}

.dict-scan-results { display: flex; flex-direction: column; gap: 8px; }

.dict-scan-word-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.dict-scan-word-text {
    font-size: 22px;
    flex: 1;
}

.dict-scan-word-play {
    background: none;
    border: 1.5px solid var(--primary-light);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-dark);
    transition: background 0.15s;
}
.dict-scan-word-play:hover { background: var(--primary-light); }

.dict-scan-word-add {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.dict-scan-word-add:hover { background: var(--primary-dark); }
