/* QuizzMan Dictionary - Modern Gradient Design */

/* Font for rare CJK characters - Using Noto Sans for extended CJK support */
/* HanaMin fonts removed - CDN no longer available */
/* If you need rare character support, consider self-hosting HanaMin fonts */

:root {
    /* New vibrant color scheme */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary-color: #ec4899;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    /* Gradient backgrounds */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
    
    --bg-primary: #ffffff;
    --bg-secondary: #f0f4ff;
    --bg-tertiary: #e8edff;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.85);
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-accent: #6366f1;
    
    --border-color: #e2e8f0;
    --border-light: rgba(255, 255, 255, 0.2);
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-chinese: 'Noto Sans SC', 'Noto Serif CJK SC', 'HanaMinA', 'HanaMinB', 'SimSun-ExtB', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', 'MingLiU-ExtB', 'Yu Gothic', sans-serif;
    --font-rare-cjk: 'HanaMinA', 'HanaMinB', 'Noto Serif CJK SC', 'SimSun-ExtB', 'MingLiU-ExtB', 'Noto Sans CJK SC', 'Source Han Sans SC', 'Microsoft YaHei', sans-serif;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark mode - Rich purple theme */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-glass: rgba(26, 26, 46, 0.9);
    --gradient-card: linear-gradient(145deg, rgba(37,37,64,0.9) 0%, rgba(26,26,46,0.7) 100%);
    
    --text-primary: #f1f5f9;
    --text-secondary: #a5b4fc;
    --text-tertiary: #64748b;
    --text-accent: #a5b4fc;
    
    --border-color: #334155;
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.4);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-sans);
    background: var(--gradient-dark);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Light mode body */
body:not([data-theme="dark"]) {
    background: linear-gradient(135deg, #e0e7ff 0%, #fdf4ff 50%, #e0f2fe 100%);
}

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

/* Header - Glassmorphism */
.header {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.35rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-image {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.logo-icon {
    font-size: 1.75rem;
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.125rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.btn-icon-mini {
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    transition: all 0.2s;
}

.btn-icon-mini:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-icon-small {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.btn-icon-small.icon-filled svg {
    fill: var(--accent-color);
    stroke: var(--accent-color);
}

/* Main */
.main {
    padding: 2rem 0;
}

/* Search Block - Glassmorphism Card */
.search-block {
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.search-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

/* Hero Section in Search */
.search-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.search-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.search-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.search-subtitle strong {
    color: var(--primary-color);
    font-weight: 600;
}

@media (max-width: 768px) {
    .search-hero {
        margin-bottom: 1.5rem;
    }
    
    .search-title {
        font-size: 1.75rem;
    }
    
    .search-subtitle {
        font-size: 0.9rem;
    }
}

/* Search Input with Wrapper */
.search-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-input-wrapper {
    flex: 1;
    min-width: 300px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-tertiary);
    pointer-events: none;
    width: 20px;
    height: 20px;
}

.search-input {
    flex: 1;
    width: 100%;
    padding: 1rem 1.25rem 1rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    transition: all 0.3s ease;
    background: var(--bg-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.search-input-wrapper .mode-btn.auto-only {
    position: absolute;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

/* Quick Actions */
.search-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn i {
    width: 18px;
    height: 18px;
}

/* Filter Tags */
.search-filters {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-right: 0.25rem;
}

.search-mode-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.mode-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm), 0 0 10px rgba(99, 102, 241, 0.2);
}

/* Auto-only icon button variant */
.mode-btn.auto-only {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.mode-btn.auto-only .auto-icon {
    width: 20px;
    height: 20px;
}

/* Rotating animation when active/working */
.mode-btn.auto-only.busy {
    animation: rotate-icon 1s linear infinite;
}

@keyframes rotate-icon {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Screen-reader only text */
.sr-only { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

/* Responsive translation modal: on desktop use centered modal full-viewport, on mobile show inline container */
.translation-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.translation-modal-overlay.active { display: flex; }
.translation-modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
    padding: 1rem;
}

/* Mobile inline container (displayed under search input) */
.translation-inline-container {
    display: none;
    width: 100%;
    margin-top: 0.75rem;
}
.translation-inline-container.active { display: block; }

@media (max-width: 900px) {
    /* On small screens use inline container; disable modal overlay */
    .translation-modal-overlay { display: none !important; }
    .translation-inline-container { display: block; }
}

.btn-handwriting {
    padding: 1rem 1.5rem;
    background: var(--gradient-secondary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.btn-handwriting:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.btn-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.75rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    white-space: nowrap;
}

.btn-search i {
    width: 18px;
    height: 18px;
}

.btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* Remove old search-filters margin-top since we moved it */
.search-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-tag {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.filter-tag:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-tag.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Autocomplete */
.search-input-container {
    position: relative;  /* Make container relative for absolute positioning */
}

.autocomplete-dropdown {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.1);
    margin-top: 0.75rem;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autocomplete-list {
    padding: 0.5rem 0;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item.recommended {
    background: linear-gradient(to right, rgba(99, 102, 241, 0.08), transparent);
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: linear-gradient(to right, var(--bg-tertiary), var(--bg-primary));
    border-left: 3px solid var(--primary-color);
    padding-left: calc(1rem - 3px);
}

.autocomplete-item .chinese {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'Noto Sans SC', sans-serif;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 3rem;
}

.autocomplete-item .pinyin {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-style: italic;
    font-weight: 500;
}

.autocomplete-item .meaning {
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-item .recommend-badge {
    font-size: 0.75rem;
    color: var(--accent-color);
    margin-left: auto;
    flex-shrink: 0;
}

/* Responsive autocomplete */
@media (max-width: 768px) {
    .autocomplete-dropdown {
        max-height: 240px;  /* Smaller on mobile */
    }
    
    .autocomplete-item {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    
    .autocomplete-item .chinese {
        font-size: 1rem;
        min-width: 2rem;
    }
    
    .autocomplete-item .pinyin,
    .autocomplete-item .meaning {
        font-size: 0.75rem;
    }
}

/* History Dropdown */
.history-dropdown {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-clear-history {
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-clear-history:hover {
    background: var(--border-color);
    color: var(--danger-color);
}

.history-list {
    padding: 0.25rem 0;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--bg-tertiary);
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: var(--bg-tertiary);
}

.history-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.history-icon {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.history-term {
    font-size: 0.875rem;
    color: var(--text-primary);
    flex: 1;
}

.history-term mark {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color);
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-sm);
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-left: auto;
}

.btn-remove-history {
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all 0.2s;
}

.history-item:hover .btn-remove-history {
    opacity: 1;
}

.btn-remove-history:hover {
    background: var(--border-color);
    color: var(--danger-color);
}

/* Responsive history */
@media (max-width: 768px) {
    .history-dropdown {
        max-height: 240px;
    }
    
    .history-item {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    
    .history-content {
        gap: 0.5rem;
    }
    
    .history-term,
    .history-date {
        font-size: 0.75rem;
    }
}

/* Content Grid */
.content-grid {
    display: grid;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Handwriting Block - Now as overlay */
.handwriting-block {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-width: 420px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.handwriting-block.active {
    display: block;
}

/* Overlay backdrop for handwriting */
.handwriting-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 999;
}

.handwriting-overlay.active {
    display: block;
}

.block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.block-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.125rem;
}

.btn-close:hover {
    background: var(--danger-color);
    color: white;
}

#handwritingCanvas {
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: white;
    cursor: crosshair;
}

.handwriting-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-primary {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.handwriting-results {
    margin-top: 1rem;
}

.hw-candidates {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hw-candidate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.hw-candidate:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.hw-char {
    font-family: var(--font-chinese);
    font-size: 2rem;
    line-height: 1;
}

.hw-confidence {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.hw-info {
    flex: 1;
}

.hw-confidence {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Results Block - Glassmorphism */
.results-block {
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.result-count {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sort-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grid View for Results */
.results-list.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.results-list.grid-view .result-item {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem 1rem;
}

.results-list.grid-view .result-char {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.results-list.grid-view .result-info {
    align-items: center;
}

.results-list.grid-view .result-meaning {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.results-list.grid-view .save-word-btn {
    top: 0.5rem;
    right: 0.5rem;
}

/* Result Item - Modern Card */
.result-item {
    display: flex;
    gap: 1.25rem;
    padding: 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.15);
    transform: translateY(-4px);
}

.result-item:hover::before {
    opacity: 1;
}

.save-word-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: var(--bg-glass);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    z-index: 10;
}

.save-word-btn:hover {
    opacity: 1;
    transform: scale(1.15);
    background: var(--gradient-accent);
    color: white;
}

.result-char {
    font-family: var(--font-chinese);
    font-size: 3.5rem;
    line-height: 1;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 5rem;
    text-align: center;
    font-weight: 600;
}

/* Character length variations */
.result-char.char-medium {
    font-size: 2.5rem;
}

.result-char.char-long {
    font-size: 1.8rem;
    min-width: 6rem;
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.result-pinyin {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.result-meaning {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* Hán Việt reading highlight */
.result-meaning .han-viet {
    font-weight: 600;
    color: var(--accent-color);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    margin-right: 0.25rem;
}

.result-meaning .no-meaning {
    color: var(--text-tertiary);
    font-style: italic;
}

.result-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.hsk {
    background: var(--gradient-accent);
}

.strokes {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* Enhanced Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-tertiary);
}

.empty-illustration {
    margin-bottom: 1.5rem;
    color: var(--primary-light);
}

.empty-illustration i {
    opacity: 0.6;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.empty-suggestions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.suggestion-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.suggestion-chip {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-family: var(--font-chinese);
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Results Header Enhanced */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 1rem;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-icon {
    color: var(--primary-color);
    width: 20px;
    height: 20px;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.view-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.view-btn i {
    width: 18px;
    height: 18px;
}

/* Stats Section */
.stats-section {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
    margin-top: 2rem;
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    text-align: center;
    min-width: 100px;
}

.stat-item i {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .stats-section {
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    .stat-item {
        min-width: 80px;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
}

/* Load More Button */
.btn-load-more {
    width: 100%;
    padding: 1rem;
    margin-top: 1.5rem;
    background: var(--gradient-secondary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-load-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.3);
}

/* Modal - Glassmorphism with full viewport slide animation */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.3), var(--shadow-glow);
    position: relative;
    border: 1px solid var(--border-light);
    border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Slide out animation when closing */
.modal-overlay.closing .modal-content {
    transform: translateY(100%);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    z-index: 10;
    color: white;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--danger-color);
    transform: rotate(90deg);
}

.detail-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(147, 197, 253, 0.12));
    color: #1e293b;
    padding: 2rem 2rem;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}


.char-display {
    font-family: var(--font-chinese);
    font-size: 7rem;
    line-height: 1;
    margin-bottom: 1rem;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
}

.char-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1.5rem;
    padding: 0.5rem 0;
}

.char-meta .meta-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
    background: transparent;
    border: none;
}

.char-meta .meta-row.full-width {
    grid-column: 1 / -1;
}

@media (max-width: 600px) {
    .char-meta {
        grid-template-columns: 1fr;
    }
}

.char-meta .meta-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-tertiary);
    min-width: 70px;
    flex-shrink: 0;
}

.char-meta .meta-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
}

.char-meta .unicode {
    font-family: 'Courier New', monospace;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.char-meta .pinyin {
    color: var(--accent-color);
    font-size: 1rem;
}

.char-meta .hanviet {
    color: var(--primary-color);
    font-weight: 600;
}

.char-meta .radical {
    color: var(--text-primary);
}

.char-meta .cangjie {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.char-meta .four-corner {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.char-meta .liushu {
    font-size: 0.9rem;
}

.char-meta .meaning {
    color: var(--text-primary);
}

.detail-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 1.25rem 1.5rem 0;
    border-bottom: 2px solid var(--border-light);
    background: var(--bg-tertiary);
}

.tab-btn {
    padding: 0.875rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 3px 3px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    background: var(--bg-primary);
}

.tab-btn.active::after {
    opacity: 1;
}

.detail-body {
    padding: 2rem;
    background: var(--bg-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-item label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 600;
}

.info-item span {
    font-size: 1rem;
    color: var(--text-primary);
}

/* Etymology Tab Styles */
.etymology-section {
    padding: 1rem 0;
}

.etymology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--bg-tertiary);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
}

.etym-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.etym-item label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.etym-item span {
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-chinese);
}

.etym-section {
    margin-bottom: 1.5rem;
}

.etym-section h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.classical-text {
    background: var(--bg-tertiary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-chinese);
    line-height: 1.8;
    color: var(--text-primary);
    border-left: 3px solid var(--primary-color);
}

.classical-text:empty::before {
    content: '-';
    color: var(--text-tertiary);
}

.historical-forms {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.form-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-width: 100px;
}

.form-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.form-char {
    font-size: 2rem;
    font-family: var(--font-chinese);
    color: var(--text-primary);
}

.form-char img {
    max-width: 60px;
    max-height: 60px;
}

.meanings-section {
    margin-top: 1.5rem;
}

.meanings-section h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.meaning-group {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.meaning-group h4 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.meaning-def {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 0.75rem;
}

.meaning-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.meaning-item {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
}

.meaning-number {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 0.5rem;
}

.example-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.example-list li {
    padding-left: 1.5rem;
    position: relative;
}

.example-list li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.stroke-order-section {
    text-align: center;
}

#strokeOrderCanvas {
    margin: 0 auto 1rem;
}

.stroke-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.example-card {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.example-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.example-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.example-card:hover::before {
    opacity: 0.03;
}

.ex-zh {
    font-family: var(--font-chinese);
    font-size: 1.25rem;
    margin-bottom: 0.625rem;
    color: var(--text-primary);
    font-weight: 500;
}

.ex-pinyin {
    color: var(--primary-color);
    margin-bottom: 0.375rem;
    font-style: italic;
}

.ex-vi {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
    line-height: 1.6;
}

.audio-btn {
    margin-top: 0.75rem;
    padding: 0.625rem 1.25rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3);
}

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.tag {
    padding: 0.625rem 1.125rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tag:hover {
    background: var(--gradient-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.related-section {
    margin-bottom: 1.5rem;
}

.related-section h4 {
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.1rem;
}

/* Related Words and Compound Words Styles */
.related-word-tag,
.compound-word-tag {
    display: inline-flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.875rem 1rem;
    background: var(--gradient-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    max-width: 200px;
    backdrop-filter: blur(4px);
}

.related-word-tag:hover,
.compound-word-tag:hover {
    background: var(--gradient-primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.related-word-tag strong,
.compound-word-tag strong {
    font-size: 1.125rem;
    color: var(--primary-color);
}

.related-word-tag:hover strong,
.compound-word-tag:hover strong {
    color: white;
}

.pinyin-small {
    font-size: 0.75rem;
    color: #64748b;
}

.related-word-tag:hover .pinyin-small,
.compound-word-tag:hover .pinyin-small {
    color: rgba(255, 255, 255, 0.9);
}

.meaning-small {
    font-size: 0.813rem;
    color: #475569;
    line-height: 1.3;
}

.related-word-tag:hover .meaning-small,
.compound-word-tag:hover .meaning-small {
    color: rgba(255, 255, 255, 0.85);
}

.similarity-badge {
    align-self: flex-end;
    padding: 0.125rem 0.375rem;
    background: var(--primary-color);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.688rem;
    font-weight: 600;
}

.related-word-tag:hover .similarity-badge {
    background: white;
    color: var(--primary-color);
}

.compound-group {
    margin-bottom: 1.25rem;
}

.compound-group:last-child {
    margin-bottom: 0;
}

/* Meanings Tab Styles */
.meanings-detailed {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.meaning-section {
    padding: 1.25rem;}

.meaning-section h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meaning-section:empty {
    display: none;
}

.xinhua-content {
    font-family: var(--font-chinese);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.xinhua-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.xinhua-item {
    padding: 0.5rem 0.75rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--radius-sm);
    line-height: 1.6;
}

.xinhua-item.numbered {
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
}

.xinhua-origin {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.xinhua-category {
    font-weight: 600;
    color: var(--primary-color);
    padding: 0.25rem 0;
    margin-top: 0.5rem;
}

.primary-meaning {
    border-left: 4px solid var(--success-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), transparent);
}


.meaning-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}


.meaning-item:hover {
    background: var(--bg-secondary);
    border-left-color: var(--secondary-color);
    transform: translateX(4px);
}

.meaning-number {
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 1.75rem;
    flex-shrink: 0;
    font-size: 1.1rem;
}

#vietnameseMeaningContent,
#englishMeaningContent,
#derivationContent,
#abbreviationContent {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

#vietnameseMeaningContent ul,
#englishMeaningContent ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

#vietnameseMeaningContent ul li,
#englishMeaningContent ul li {
    margin: 0.5rem 0;
}

/* Hamburger Menu */
.hamburger-menu {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 0.625rem;
    transition: all 0.2s;
}

.hamburger-menu:hover {
    background: var(--bg-hover);
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Header responsive */
    .header-content {
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .logo {
        flex-shrink: 0;
    }

    .logo-text {
        display: none;
    }

    .logo-image {
        width: 36px;
        height: 36px;
    }

    .nav {
        position: fixed;
        top: 4rem;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        z-index: 999;
    }

    .nav.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-link {
        width: 100%;
        text-align: center;
        padding: 0.875rem;
    }

    .hamburger-menu {
        display: flex;
        order: -1;
    }

    .header-actions {
        margin-left: auto;
    }

    /* Content responsive */
    .container {
        padding: 0 1rem;
    }

    .search-block {
        padding: 1.25rem;
    }

    .search-modes {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .search-modes::-webkit-scrollbar {
        height: 4px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }

    .character-display {
        font-size: 4rem;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    /* Handwriting canvas responsive */
    #hwCanvas {
        max-width: 100%;
    }

    .hw-candidates {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .search-input {
        font-size: 1rem;
    }

    .character-display {
        font-size: 3rem;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .filter-tag {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    .result-card {
        padding: 1rem;
    }
}

/* ============================================
   TRANSLATION UI STYLES
   ============================================ */

.btn-translate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-translate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.translation-block {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-width: 600px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.translation-block.active {
    display: block;
}

/* Overlay backdrop for translation */
.translation-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 999;
}

.translation-overlay.active {
    display: block;
}

.translation-form {
    margin-bottom: 20px;
}

.language-selectors {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.lang-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.lang-group label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.lang-select {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s;
}

.lang-select:focus {
    outline: none;
    border-color: #667eea;
}

.swap-langs {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}

.swap-langs:hover {
    background: #e5e7eb;
    transform: rotate(180deg);
}

.translation-input {
    position: relative;
    margin-bottom: 16px;
}

.translation-input textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
    font-family: inherit;
}

.translation-input textarea:focus {
    outline: none;
    border-color: #667eea;
}

.char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 12px;
    color: #9ca3af;
    background: white;
    padding: 2px 4px;
}

.translate-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.translate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.translate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.translation-results {
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

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

.result-header h4 {
    margin: 0;
    color: #1f2937;
    font-size: 16px;
}

.performance-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.confidence-score {
    font-size: 12px;
    color: #6b7280;
}

.confidence-score span:last-child {
    font-weight: 600;
    color: #059669;
}

.method-info {
    font-size: 10px;
    color: #9ca3af;
    font-family: monospace;
}

.method-info:empty {
    display: none;
}

.translated-text {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
    color: #1e293b;
    margin-bottom: 16px;
    white-space: pre-wrap;
    transition: opacity 0.3s ease, transform 0.2s ease;
    transform: translateY(0);
}

.translated-text.loading {
    opacity: 0.6;
    transform: translateY(-2px);
}

/* Animation for performance indicators */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Button transitions */
.translate-btn {
    transition: all 0.2s ease;
}

.translate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.translate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.translate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Optimistic UI classes */
.text-gray-400 {
    color: #9ca3af;
}

.text-gray-500 {
    color: #6b7280;
}

.text-sm {
    font-size: 0.875rem;
}

.translation-feedback {
    background: #fafbfc;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
}

.rating-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.rating-section span:first-child {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.star-rating {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 20px;
    color: #d1d5db;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.star:hover,
.star.active {
    color: #fbbf24;
}

.star.active {
    text-shadow: 0 0 4px rgba(251, 191, 36, 0.3);
}

.feedback-section {
    margin-top: 12px;
}

.feedback-section textarea,
.feedback-section input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.feedback-section textarea:focus,
.feedback-section input:focus {
    outline: none;
    border-color: #667eea;
}

.feedback-section textarea {
    resize: vertical;
    min-height: 60px;
}

#submitFeedback {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#submitFeedback:hover {
    background: #059669;
}

/* Responsive design for translation block */
@media (max-width: 768px) {
    .language-selectors {
        flex-direction: column;
        gap: 8px;
    }
    
    .lang-group {
        width: 100%;
    }
    
    .swap-langs {
        margin-top: 0;
        align-self: center;
    }
    
    .rating-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Performance Optimizations & Animations */
.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Smooth transitions for better UX */
.translation-block {
    transition: all 0.3s ease-in-out;
    transform-origin: top;
}

.translation-results {
    transition: all 0.3s ease-out;
    will-change: opacity, transform;
}

.feedback-section {
    transition: opacity 0.3s ease-in-out;
    will-change: opacity;
}

/* Loading states */
.translation-input:disabled {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.translate-btn {
    transition: all 0.2s ease;
    will-change: background-color, transform;
}

.translate-btn:active {
    transform: scale(0.98);
}

/* Star rating animations */
.star {
    transition: all 0.2s ease;
    will-change: color, transform;
}

.star:hover {
    transform: scale(1.1);
}

.star.filled {
    animation: starFill 0.3s ease-out;
}

@keyframes starFill {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Toast notifications */
#errorToast, #successToast {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    will-change: transform;
}

/* Optimized scrolling */
html {
    scroll-behavior: smooth;
}

/* Hardware acceleration for performance */
.header, .translation-block, .search-results {
    backface-visibility: hidden;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .animate-spin {
        animation: none;
    }
    
    .translation-block,
    .translation-results,
    .feedback-section,
    .star {
        transition: none;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Cache indicator styling */
.confidence-score {
    position: relative;
}

.confidence-score .cache-indicator {
    position: absolute;
    top: -8px;
    right: -20px;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: normal;
}

/* Enhanced input focus states */
.translation-input:focus {
    transform: scale(1.01);
    transition: all 0.2s ease;
}

/* Micro-interactions for buttons */
.btn-icon, .translate-btn, .close-btn {
    position: relative;
    overflow: hidden;
}

.btn-icon::before, .translate-btn::before, .close-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn-icon:active::before, .translate-btn:active::before, .close-btn:active::before {
    width: 200px;
    height: 200px;
}

/* Optimized font loading */
.font-chinese {
    font-display: swap;
}

/* Preload important UI elements */
.translation-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
}

/* Favorites Modal */
.favorites-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.favorites-modal-overlay.active {
    display: flex;
}

.favorites-modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
}

.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.favorites-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.favorites-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-wrap: wrap;
    align-items: center;
}

.favorites-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.favorites-search input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.favorites-search i {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    width: 16px;
    height: 16px;
}

.favorites-sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.favorites-sort label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.favorites-sort select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.favorites-actions {
    display: flex;
    gap: 0.5rem;
}

.favorites-actions .btn-secondary,
.favorites-actions .btn-danger {
    padding: 0.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.favorites-actions .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.favorites-actions .btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.favorites-actions .btn-danger {
    background: var(--danger-color);
    color: white;
}

.favorites-actions .btn-danger:hover {
    background: #dc2626;
}

.favorites-stats {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

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

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hsk-stats {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.favorites-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.empty-favorites {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-tertiary);
}

.empty-favorites i {
    margin-bottom: 1rem;
    color: var(--text-tertiary);
}

.empty-favorites p {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.favorite-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.favorite-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.favorite-char {
    font-family: var(--font-chinese);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--primary-color);
    min-width: 3rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.favorite-pinyin {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.favorite-meaning {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.favorite-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.hsk-badge {
    background: var(--warning-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.strokes {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.added-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.favorite-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.favorite-actions .btn-view,
.favorite-actions .btn-remove-favorite {
    padding: 0.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.favorite-actions .btn-view {
    color: var(--primary-color);
}

.favorite-actions .btn-view:hover {
    background: rgba(59, 130, 246, 0.1);
}

.favorite-actions .btn-remove-favorite {
    color: var(--danger-color);
}

.favorite-actions .btn-remove-favorite:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Save/favorite button in search results */
.save-word-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.2s;
    z-index: 10;
}

.save-word-btn:hover {
    transform: scale(1.1);
    color: var(--danger-color);
}

.save-word-btn.favorited {
    color: var(--danger-color);
}

/* Responsive favorites modal */
@media (max-width: 768px) {
    .favorites-modal-content {
        margin: 0.5rem;
        max-height: 95vh;
    }
    
    .favorites-controls {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .favorites-search {
        min-width: auto;
    }
    
    .favorites-sort {
        justify-content: space-between;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .favorite-item {
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .favorite-char {
        font-size: 2rem;
        min-width: 2.5rem;
    }
    
    .favorite-actions {
        flex-direction: row;
    }
}

/* ========================================
   Etymology Admin Interface Styles
   ======================================== */

.etymology-admin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1100;
    display: none;
    padding: 2rem;
    box-sizing: border-box;
}

.etymology-admin-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.etymology-admin-content {
    background: var(--background-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.etymology-admin-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.etymology-admin-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.etymology-admin-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-tertiary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.etymology-admin-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.etymology-admin-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.etymology-admin-toolbar {
    padding: 1rem 2rem;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.etymology-toolbar-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.etymology-toolbar-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--background-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.etymology-toolbar-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.etymology-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.etymology-toolbar-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.etymology-toolbar-btn.primary:hover {
    background: var(--primary-dark);
}

.etymology-character-display {
    font-family: var(--font-chinese);
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    background: rgba(var(--primary-rgb), 0.1);
}

.etymology-admin-main {
    flex: 1;
    overflow: hidden;
    display: flex;
}

.etymology-admin-tabs {
    display: flex;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.etymology-tab {
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.etymology-tab:hover {
    background: var(--bg-hover);
}

.etymology-tab.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--background-color);
}

.etymology-tab-content {
    flex: 1;
    overflow: auto;
    padding: 2rem;
}

.etymology-form-section {
    margin-bottom: 2rem;
}

.etymology-form-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.etymology-form-section h3 i {
    color: var(--primary-color);
}

.etymology-form-group {
    margin-bottom: 1.5rem;
}

.etymology-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.etymology-form-label.required:after {
    content: ' *';
    color: var(--danger-color);
}

.etymology-form-input,
.etymology-form-textarea,
.etymology-form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: all 0.2s;
    background: var(--background-color);
    box-sizing: border-box;
}

.etymology-form-input:focus,
.etymology-form-textarea:focus,
.etymology-form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.etymology-form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.etymology-form-textarea.large {
    min-height: 150px;
}

.etymology-character-input {
    font-family: var(--font-chinese);
    font-size: 1.5rem;
    text-align: center;
    max-width: 100px;
}

.etymology-components-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.etymology-component-item {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
}

.etymology-component-char {
    font-family: var(--font-chinese);
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 3rem;
    text-align: center;
    color: var(--primary-color);
}

.etymology-component-fields {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 1rem;
}

.etymology-component-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.etymology-component-remove:hover {
    background: var(--danger-dark);
    transform: scale(1.1);
}

.etymology-add-component {
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.etymology-add-component:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.05);
}

.etymology-preview {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-top: 1rem;
}

.etymology-preview h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 1.125rem;
}

.etymology-preview-character {
    font-family: var(--font-chinese);
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--radius-lg);
    border: 2px solid var(--primary-color);
}

.etymology-preview-section {
    margin-bottom: 1.5rem;
}

.etymology-preview-section h5 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.etymology-preview-text {
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 0.75rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
}

.etymology-preview-components {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.etymology-preview-component {
    background: var(--background-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.etymology-preview-component-char {
    font-family: var(--font-chinese);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

.etymology-history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.etymology-history-item {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.etymology-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.etymology-history-version {
    font-weight: 600;
    color: var(--primary-color);
}

.etymology-history-date {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.etymology-history-changes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.etymology-history-change {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.etymology-history-field {
    font-weight: 500;
    min-width: 100px;
    color: var(--text-primary);
}

.etymology-history-value {
    flex: 1;
    color: var(--text-secondary);
}

.etymology-history-value.added {
    color: var(--success-color);
    background: rgba(var(--success-rgb), 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.etymology-history-value.removed {
    color: var(--danger-color);
    background: rgba(var(--danger-rgb), 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.etymology-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.etymology-status-indicator.saved {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success-color);
}

.etymology-status-indicator.modified {
    background: rgba(var(--warning-rgb), 0.1);
    color: var(--warning-color);
}

.etymology-status-indicator.error {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger-color);
}

.etymology-image-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface-color);
}

.etymology-image-upload:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.05);
}

.etymology-image-upload.drag-over {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
}

.etymology-image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-md);
    margin: 1rem auto;
    display: block;
    border: 1px solid var(--border-color);
}

/* Responsive etymology admin */
@media (max-width: 1024px) {
    .etymology-admin-overlay {
        padding: 1rem;
    }
    
    .etymology-admin-content {
        max-width: 95%;
    }
    
    .etymology-component-fields {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .etymology-preview-components {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .etymology-admin-overlay {
        padding: 0.5rem;
    }
    
    .etymology-admin-header {
        padding: 1rem;
    }
    
    .etymology-admin-toolbar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .etymology-toolbar-group {
        justify-content: center;
    }
    
    .etymology-tab-content {
        padding: 1rem;
    }
    
    .etymology-component-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .etymology-component-fields {
        grid-template-columns: 1fr;
    }
    
    .etymology-component-char {
        min-width: auto;
        padding: 0.5rem;
        background: var(--background-color);
        border-radius: var(--radius-md);
    }
    
    .etymology-preview-character {
        font-size: 2.5rem;
        padding: 0.75rem;
    }
    
    .etymology-history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* New responsive styles for refactored layout */
    .search-input-wrapper {
        min-width: 100%;
    }
    
    .search-input-container {
        flex-direction: column;
    }
    
    .btn-search {
        width: 100%;
        justify-content: center;
    }
    
    .search-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .action-btn {
        flex: 1;
        min-width: 0;
        padding: 0.625rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .action-btn span {
        display: none;
    }
    
    .action-btn i {
        margin: 0;
    }
    
    .filter-label {
        display: none;
    }
    
    .filter-tag {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .results-controls {
        justify-content: space-between;
    }
    
    .empty-suggestions {
        flex-direction: column;
    }
    
    .stats-section {
        gap: 1rem;
        padding: 1rem;
    }
    
    .stat-item {
        min-width: 70px;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
}

/* ============== Updating Status Styles ============== */
.updating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    animation: pulse-subtle 2s ease-in-out infinite;
}

.updating-badge.small {
    padding: 0.0625rem 0.25rem;
    font-size: 0.625rem;
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.updating-notice {
    display: block;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    text-align: center;
}

.is-updating {
    color: #92400e;
}

/* ============== Pronunciation Section Styles ============== */
.pronunciation-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pronunciation-section h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.pronunciation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.pronunciation-grid .info-item {
    background: var(--background-tertiary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
}

.pronunciation-grid .info-item label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ============== Dictionary References Styles ============== */
.dict-refs-content {
    margin-top: 0.5rem;
}

.dict-refs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.dict-ref-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--background-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
}

.dict-ref-item .dict-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.dict-ref-item .dict-desc {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0.125rem 0 0.5rem;
}

.dict-ref-item .dict-value {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
    background: var(--background-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.dict-ref {
    display: block;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* ============== Classical Text Styles ============== */
.classical-text {
    font-family: "Noto Serif SC", "Source Han Serif SC", serif;
    line-height: 1.8;
    padding: 1rem;
    background: var(--background-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-color);
}

/* ============== Historical Forms Styles ============== */
.historical-forms {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 1rem;
}

.form-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.form-char {
    font-size: 2.5rem;
    font-family: "Noto Serif SC", serif;
    min-width: 4rem;
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* ============== Etymology Section Improvements ============== */
.etym-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.etym-section h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

.etymology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.etym-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.etym-item label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.etym-item span {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Mobile responsive for new styles */
@media (max-width: 640px) {
    .pronunciation-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dict-refs-grid {
        grid-template-columns: 1fr;
    }
    
    .historical-forms {
        gap: 1rem;
    }
    
    .form-char {
        font-size: 2rem;
        min-width: 3rem;
        min-height: 3rem;
    }
}

/* Enhanced Meanings Display */
.meaning-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.han-viet-reading {
    font-size: 1.1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(236, 72, 153, 0.04));
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.han-viet-reading strong {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.vietnamese-meanings {
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.sub-meaning {
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
    margin-left: 0.5rem;
}

.view-more-hint {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-top: 0.75rem;
    font-style: italic;
    opacity: 0.8;
}

.meaning-def {
    line-height: 1.7;
    margin-bottom: 0.5rem;
}

.meaning-def strong {
    color: var(--text-secondary);
}
/* ============== Variants Tab Styles ============== */
.variants-section {
    padding: 1rem;
}

.variant-group {
    margin-bottom: 1.5rem;
}

.variant-group h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.variant-chars {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.variant-char {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.variant-char.clickable {
    cursor: pointer;
}

.variant-char.clickable:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.variant-char .char {
    font-size: 2rem;
    font-family: var(--font-chinese);
    color: var(--text-primary);
    line-height: 1.2;
}

.variant-char .label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    padding: 0.125rem 0.375rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-top: 0.375rem;
}

/* Dark mode variant styles */
[data-theme="dark"] .variant-char {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .variant-char.clickable:hover {
    background: var(--bg-secondary);
}

[data-theme="dark"] .variant-char .label {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

/* ============== Dictionary References Simple (Related Tab) ============== */
.dict-refs-simple {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dict-ref-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .dict-ref-badge {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* ============== Nôm Tab Styles ============== */
.nom-section {
    padding: 1rem 0;
}

.nom-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.nom-header h4 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.nom-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nom-meanings-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Nôm source group styles */
.nom-source-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

.nom-source-group.nguyen-trai-group {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(236, 72, 153, 0.05) 100%);
    border-left: 4px solid var(--primary-color);
}

.nom-source-group.nom-tay-group {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
    border-left: 4px solid var(--success-color);
}

.nom-group-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.nom-meaning-item {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.nom-meaning-item:last-child {
    margin-bottom: 0;
}

.nom-meaning-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.nom-reading {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: var(--font-chinese);
}

.nom-word-class {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary-hover);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.nom-meaning-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
}

.nom-source {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-style: italic;
}

.nom-source-info {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.nom-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
}

.nom-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Kangxi dictionary styles */
.kangxi-ref {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.kangxi-img-link {
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.kangxi-img-link:hover {
    opacity: 1;
}

.kangxi-image-wrapper {
    margin-bottom: 1rem;
}

.kangxi-toggle-img {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.kangxi-toggle-img:hover {
    background: var(--bg-tertiary);
}

.kangxi-image-container {
    display: none;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-width: 100%;
}

.kangxi-image-container.show {
    display: block;
}

.kangxi-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

.kangxi-img-error {
    padding: 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.kangxi-definition {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-family: 'HanaMinA', 'HanaMinB', 'Noto Serif CJK SC', 'SimSun-ExtB', 'MingLiU-ExtB', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', serif;
}

.kangxi-source {
    color: var(--color-accent, #0ea5e9);
    font-weight: 500;
}

.kangxi-variant {
    color: var(--text-tertiary);
    font-size: 0.9em;
}

.kangxi-definition em {
    font-style: normal;
    color: var(--color-primary, #6366f1);
}

/* Word class abbreviation styles */
.wc-dt { background: #dbeafe; color: #1e40af; } /* Danh từ */
.wc-dgt { background: #dcfce7; color: #166534; } /* Động từ */
.wc-tt { background: #fef3c7; color: #92400e; } /* Tính từ */
.wc-pht { background: #fce7f3; color: #9d174d; } /* Phó từ */
.wc-trgt { background: #e0e7ff; color: #4338ca; } /* Trạng từ */
.wc-lt { background: #f3e8ff; color: #7e22ce; } /* Liên từ */
.wc-st { background: #fee2e2; color: #b91c1c; } /* Số từ */

[data-theme="dark"] .nom-meaning-item {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

[data-theme="dark"] .nom-word-class {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

[data-theme="dark"] .wc-dt { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .wc-dgt { background: rgba(34, 197, 94, 0.2); color: #86efac; }
[data-theme="dark"] .wc-tt { background: rgba(234, 179, 8, 0.2); color: #fde047; }
[data-theme="dark"] .wc-pht { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
[data-theme="dark"] .wc-trgt { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
[data-theme="dark"] .wc-lt { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
[data-theme="dark"] .wc-st { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
/* ============================================
   FOOTER STYLES
   ============================================ */

.site-footer {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-top: 1px solid var(--border-color);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: 4rem;
}

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

.footer-main {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.footer-logo-icon {
    font-size: 1.75rem;
}

.footer-tagline {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.footer-links-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-links-group h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.footer-links-group a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.footer-links-group a:hover {
    color: var(--primary);
    padding-left: 0.25rem;
}

.footer-bottom {
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.footer-copyright {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.footer-note {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.footer-note a {
    color: var(--primary);
    text-decoration: none;
}

.footer-note a:hover {
    text-decoration: underline;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .footer-main {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .footer-links {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .footer-brand {
        text-align: center;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .footer-links {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .footer-links-group {
        align-items: center;
    }
    
    .footer-links-group a:hover {
        padding-left: 0;
    }
}

/* Dark theme adjustments */
[data-theme="dark"] .site-footer {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #0f172a 100%);
}
/* ============== Combined Etymology Tab Styles ============== */
.glyph-evolution-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.glyph-evolution-section h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.historical-forms {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

.form-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-width: 100px;
    transition: transform var(--transition-fast);
}

.form-item:hover {
    transform: translateY(-2px);
}

.form-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.form-char {
    font-size: 2.5rem;
    color: var(--text-primary);
    font-family: var(--font-chinese);
}

.form-char.ancient-font {
    font-family: 'Oracle Bone', 'Bronze Script', var(--font-chinese);
}

/* Current character highlight in form display */
.form-char-current {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

/* Clickable variant character in form display */
.form-char-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid transparent;
}

.form-char-clickable:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* ============== Stroke Preview in Overview ============== */
/* Merged style for stroke preview section */

/* Char display header stroke animation container */
#modalChar {
    min-width: 120px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.variants-section-combined {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.variants-section-combined h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.variant-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.variant-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.variant-group label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 150px;
}

.etymology-info {
    margin-bottom: 2rem;
}

.etymology-info h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.etymology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.etym-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.etym-item label {
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.etym-item span {
    color: var(--text-primary);
    font-family: var(--font-chinese);
}

.etym-section {
    margin-bottom: 1.5rem;
}

.etym-section h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.classical-text {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-family: var(--font-chinese);
    line-height: 1.8;
    white-space: pre-line;
}

/* ============== Pronunciation Tab Styles ============== */
.pronunciation-detailed {
    padding: 1rem 0;
}

.pronunciation-detailed h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.pronunciation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

/* ============== Stroke Preview in Overview ============== */
.stroke-preview-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.stroke-preview-section h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.stroke-preview {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    width: 150px;
    height: 150px;
    margin: 0 auto 1rem;
    align-items: center;
}

.stroke-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-stroke {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    min-width: 2.5rem;
}

.btn-stroke:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-stroke:active {
    transform: translateY(0);
}

.btn-stroke:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============== MOE/Xinhua Content Styles ============== */
.xinhua-content,
.moe-content {
    padding: 0.5rem 0;
    background: transparent;
    border-radius: 0;
    font-family: var(--font-chinese);
    line-height: 1.8;
}

.moe-content {
    max-height: none;
    overflow: visible;
}

/* Han Viet Main Display */
.hanviet-main {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* ============== Meaning Formatting Styles - Content-First Design ============== */
/* Nguyên tắc: Nội dung > UI, giảm lớp thị giác, màu có ngữ nghĩa */

.meaning-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Meanings organized by source - Đơn giản hóa */
.meanings-by-source {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.source-block {
    background: transparent;
    padding: 0;
    border-left: none;
}

/* Simplified source block - với border nhẹ phân tách */
.source-block-white {
    background: transparent !important;
    border-radius: 0;
    padding: 1rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(229, 231, 235, 0.8);
    border-left: 3px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Header nguồn - gradient nổi bật, in nghiêng */
.source-header-numbered {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.08));
    border-radius: 8px;
    border: none;
    font-style: italic;
}

.source-number {
    display: none; /* Ẩn số thứ tự */
}

/* Text label - tên nguồn từ điển - nổi bật hơn */
.source-label {
    font-size: 0.9rem;
    color: #4f46e5;
    font-weight: 600;
    font-style: italic;
    background: linear-gradient(45deg, #6366f1, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Source attribution ở cuối block - metadata style */
.source-attribution {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: right;
}

.source-block-white .source-meanings {
    display: block;
}

/* Flat meaning items - chỉ text, không nền */
.source-block-white .source-meanings .meaning-item,
.source-block-white .source-meanings .meaning-entry {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #374151;
    padding: 0.35rem 0;
    background: transparent;
    border: none;
}

.source-block-white .source-meanings .meaning-entry + .meaning-entry {
    border-top: 1px dashed #e5e7eb;
}

.source-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.source-code {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #6b7280;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.source-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.source-meanings {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.source-meanings .meaning-item {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    padding-left: 0;
    border-left: none;
}

.source-meanings .meaning-item:hover {
    background: transparent;
}

.more-meanings {
    font-size: 0.8rem;
    color: #9ca3af;
    font-style: italic;
    padding-left: 0;
    margin-top: 0.25rem;
}

/* Pinyin inline highlights - subtle, không nổi bật quá */
.pinyin-inline {
    display: inline;
    color: #6b7280;
    font-weight: 400;
    font-style: italic;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* Classifier (Lượng từ) styling - đơn giản */
.classifier-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    margin-bottom: 0.5rem;
    background: transparent;
    border-radius: 0;
    border-left: none;
}

.classifier-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
    color: #78350f;
    font-size: 0.85rem;
    background: transparent;
    padding: 0.15rem 0;
    border-radius: 0;
}

.classifier-value {
    color: #374151;
    font-weight: 500;
}

/* ============================================================
   SOURCE-SPECIFIC MEANING FORMATTING STYLES - Simplified
   Nguyên tắc: Content-first, màu có ngữ nghĩa, giảm decoration
   ============================================================ */

/* Base meaning content wrapper - bỏ box, flat design */
.meaning-content {
    background: transparent;
    color: #1f2937;
    padding: 0;
    border-radius: 0;
    line-height: 1.8;
    font-size: 0.95rem;
}

/* Reading header block - inline, không nền */
.reading-header {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

/* Han Viet reading - in đậm, không nền */
.han-viet-reading {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    text-transform: capitalize;
}

/* Pinyin - nhỏ, xám */
.pinyin-reading {
    font-size: 0.85rem;
    color: #9ca3af;
    font-style: italic;
}

/* Meaning content - counter reset at content level for continuous numbering */
.meaning-content {
    margin: 0.75rem 0;
    counter-reset: definition-counter; /* Reset at content level not block level */
}

/* Definition blocks - với counter tự động đánh số */
.definition-block {
    margin: 0.25rem 0;
    /* counter-reset: definition-counter; moved up to meaning-content */
}

.sub-definition {
    padding: 0.25rem 0;
    padding-left: 1rem;
    counter-increment: definition-counter;
    position: relative;
}

.sub-definition::before {
    content: counter(definition-counter) ".";
    position: absolute;
    left: 0;
    font-weight: 700;
    color: #6366f1;
    font-size: 0.9rem;
    top: 0.25rem;
}

.sub-marker {
    display: none; /* Ẩn marker cũ vì dùng CSS counter */
}

.def-text {
    color: #374151;
}

.def-num {
    display: inline-block;
    min-width: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.numbered-def {
    padding: 0.5rem 0;
    padding-left: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.numbered-def:last-child {
    border-bottom: none;
}

.def-line {
    padding: 0.25rem 0;
}

/* Examples list - flat, chỉ indent */
.examples-list {
    margin-top: 0.5rem;
    margin-left: 1rem;
    padding-left: 0.5rem;
    border-left: none;
    background: transparent;
}

.example-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0;
    align-items: baseline;
}

/* Chữ Hán trong ví dụ - màu đỏ = chữ Hán */
.ex-chinese {
    font-weight: 600;
    color: #b91c1c;
    cursor: pointer;
    font-size: 0.95rem;
}

.ex-chinese:hover {
    text-decoration: underline;
    color: #991b1b;
}

/* Nghĩa trong ví dụ - màu đen/xám */
.ex-meaning {
    color: #4b5563;
    font-size: 0.9rem;
}

/* ============ BKTD Format - Đơn giản hóa ============ */
.bktd-format {
    border-left: none;
}

/* Compound section - collapsible */
.compound-section {
    margin: 0.25rem 0;
    padding-left: 0.5rem;
    border-left: none;
}

/* Compound header - clickable */
.compound-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    padding: 0.2rem 0;
}

.compound-header:hover {
    background: rgba(99, 102, 241, 0.04);
}

.compound-toggle {
    font-size: 0.65rem;
    color: #9ca3af;
    width: 0.8rem;
    transition: transform 0.15s;
}

/* Collapsible content - initially hidden */
.compound-content {
    padding-left: 1.1rem;
    display: none; /* Initially hidden, toggled by JS */
}

/* Removed collapsed class - using display toggle instead */
/* .compound-content.collapsed {
    max-height: 0;
    opacity: 0;
} */

/* Từ ghép - in đậm */
.compound-word {
    font-size: 0.95rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
}

.compound-word:hover {
    color: #6366f1;
    text-decoration: underline;
}

/* Han Viet cho từ ghép - xám */
.compound-hanviet {
    font-weight: 500;
    color: #6b7280;
    margin-left: 0.35rem;
    font-size: 0.85rem;
}

.compound-pinyin {
    font-style: italic;
    color: #9ca3af;
    font-size: 0.85rem;
}

/* ============ Cihui Format - Simplified ============ */
.cihui-format {
    border-left: none;
}

/* Classifier - đơn giản, không gradient */
.classifier-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    background: transparent;
    border-radius: 0;
}

.classifier-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem;
    background: #fbbf24;
    color: #78350f;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 3px;
}

.pinyin-tone {
    color: #6b7280;
    font-style: italic;
    font-weight: 400;
}

.usage-note {
    color: #9ca3af;
    font-style: italic;
    font-size: 0.85rem;
}

/* ============ Thiều Chửu Format - Simplified ============ */
.thieuchuu-format {
    border-left: none;
}

/* Han Viet inline - chip nhỏ, không nổi bật như link */
.hanviet-inline {
    display: inline;
    font-weight: 500;
    color: #4b5563;
    background: #f3f4f6;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.9rem;
}

/* Hanzi reference - màu đỏ = chữ Hán */
.hanzi-ref {
    color: #b91c1c;
    cursor: pointer;
    font-weight: 500;
}

.hanzi-ref:hover {
    text-decoration: underline;
    color: #991b1b;
}

/* Alternative reading - xám đậm, không quá nổi bật */
.alt-reading {
    display: inline;
    font-weight: 600;
    color: #4b5563;
    background: #e5e7eb;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* ============ HVDTD Format - Simplified ============ */
.hvdtd-format {
    border-left: none;
}

/* Hanzi inline - màu đỏ = chữ Hán */
.hanzi-inline {
    color: #b91c1c;
    cursor: pointer;
    font-weight: 500;
}

.hanzi-inline:hover {
    text-decoration: underline;
}

/* ============ NQH Format - Simplified ============ */
.nqh-format {
    border-left: none;
}

.meanings-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meaning-item {
    padding: 0.35rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.meaning-item:last-child {
    border-bottom: none;
}

/* Example marker - xanh lá = ví dụ/mở rộng */
.example-marker {
    font-weight: 500;
    color: #059669;
    font-size: 0.85rem;
}

/* See also - xanh dương = tham chiếu */
.see-also {
    font-weight: 500;
    color: #2563eb;
    cursor: pointer;
}

.see-also:hover {
    text-decoration: underline;
}

/* ============ LacViet Format - Simplified ============ */
.lacviet-format {
    border-left: none;
}

.pinyin-header {
    margin-bottom: 0.25rem;
}

/* Han Viet header - đơn giản, không box */
.hanviet-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0;
    margin-bottom: 0.5rem;
    background: transparent;
    border-radius: 0;
}

.hanviet-header .label {
    color: #9ca3af;
    font-size: 0.8rem;
}

/* Han Viet reading - metadata style */
.hanviet-reading {
    font-weight: 600;
    color: #4b5563;
    letter-spacing: 0;
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.definitions-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.def-item {
    padding: 0.35rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.def-item:last-child {
    border-bottom: none;
}

/* Chinese explanation - nhẹ nhàng hơn */
.zh-explanation {
    margin-top: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border-left: none;
    border-radius: 0;
    font-size: 0.85rem;
    color: #7f1d1d;
}

/* ============ TDTT (Thiền tông) Format ============ */
.tdtt-format {
    border-left: none;
}

.tdtt-text {
    line-height: 1.8;
    font-size: 0.95rem;
}

.tdtt-text .numbered-def {
    margin: 0.75rem 0;
    padding: 0.5rem 0;
}

.tdtt-text .def-num {
    color: #6366f1;
    margin-right: 0.5rem;
}

.tdtt-text .text-ref {
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ============ Chinese Sources (xinhua, hydcd, kanghi) - Simplified ============ */
.chinese-format {
    border-left: none;
}

.book-ref {
    color: #6b7280;
    font-style: italic;
    font-size: 0.9rem;
}

.def-separator {
    color: #d1d5db;
    margin: 0 0.25rem;
}

.chinese-text {
    line-height: 1.8;
    color: #374151;
}

/* ============ English Sources (unihan, han_hoa_anh) - Simplified ============ */
.english-format {
    border-left: none;
}

.english-meaning {
    color: #374151;
    font-style: normal;
}

/* ============ TDTT Format - Simplified ============ */
.tdtt-format {
    border-left: none;
}

.text-ref {
    font-style: italic;
    color: #9ca3af;
    font-size: 0.8rem;
}

/* Generic format fallback - no border */
.generic-format {
    border-left: none;
}

/* ============ Dark Mode Support - Simplified ============ */
[data-theme="dark"] .detail-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(147, 197, 253, 0.08));
    color: #e2e8f0;
    border-bottom-color: rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .meaning-content {
    background: transparent;
    color: #e2e8f0;
}

[data-theme="dark"] .reading-header {
    background: transparent;
}

[data-theme="dark"] .han-viet-reading {
    color: #9ca3af;
    background: #374151;
}

[data-theme="dark"] .def-text {
    color: #e2e8f0;
}

[data-theme="dark"] .examples-list {
    background: transparent;
    border-left-color: #4b5563;
}

[data-theme="dark"] .ex-chinese {
    color: #f87171;
}

[data-theme="dark"] .ex-meaning {
    color: #9ca3af;
}

[data-theme="dark"] .compound-section {
    background: transparent;
}

[data-theme="dark"] .compound-header:hover {
    background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .compound-toggle {
    color: #6b7280;
}

[data-theme="dark"] .compound-word {
    color: #34d399;
}

[data-theme="dark"] .compound-hanviet {
    color: #9ca3af;
}

[data-theme="dark"] .classifier-item {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
}

[data-theme="dark"] .hanviet-inline {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

[data-theme="dark"] .alt-reading {
    background: rgba(234, 88, 12, 0.2);
    color: #fb923c;
}

[data-theme="dark"] .hanzi-inline,
[data-theme="dark"] .hanzi-ref {
    color: #f87171;
}

[data-theme="dark"] .numbered-def {
    border-bottom-color: #334155;
}

[data-theme="dark"] .sub-definition::before {
    color: #a5b4fc;
}

[data-theme="dark"] .sub-definition {
    border-bottom-color: #334155;
}

[data-theme="dark"] .def-item {
    border-bottom-color: #334155;
}

[data-theme="dark"] .hanviet-header {
    background: rgba(13, 148, 136, 0.15);
}

[data-theme="dark"] .hanviet-reading {
    color: #2dd4bf;
}

[data-theme="dark"] .zh-explanation {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

[data-theme="dark"] .source-block-white {
    background: transparent !important;
    border: 1px solid rgba(75, 85, 99, 0.6);
    border-left: 3px solid rgba(99, 102, 241, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .source-header-numbered {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.12));
    border: 1px solid rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .source-number {
    color: #e2e8f0;
}

[data-theme="dark"] .source-label {
    color: #a5b4fc;
    background: linear-gradient(45deg, #a5b4fc, #f0abfc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .source-attribution {
    color: #64748b;
}

[data-theme="dark"] .han-viet-reading {
    color: #f1f5f9;
}

[data-theme="dark"] .compound-word {
    color: #e2e8f0;
}

[data-theme="dark"] .def-text {
    color: #cbd5e1;
}

[data-theme="dark"] .meaning-entry {
    border-top-color: #334155 !important;
}

[data-theme="dark"] .source-block-white .source-meanings .meaning-item,
[data-theme="dark"] .source-block-white .source-meanings .meaning-entry {
    color: #e2e8f0;
    background: transparent;
}

[data-theme="dark"] .source-block-white .source-meanings .meaning-item:hover,
[data-theme="dark"] .source-block-white .source-meanings .meaning-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Meaning markers - semantic colors */
.marker-same,
.marker-antonym,
.marker-synonym {
    display: inline;
    font-weight: 500;
    padding: 0 0.15rem;
    font-size: 0.9rem;
}

.marker-same { color: #059669; }    /* Xanh lá = đồng nghĩa */
.marker-antonym { color: #dc2626; } /* Đỏ = trái nghĩa */
.marker-synonym { color: #2563eb; } /* Xanh dương = tham chiếu */

/* Legacy cihui content styling - kept for compatibility */
.cihui-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Han Viet Section - Simplified, metadata style */
.han-viet-section {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border-left: none;
    margin-bottom: 0.5rem;
}

.han-viet-section .label {
    font-weight: 400;
    color: #9ca3af;
    white-space: nowrap;
    font-size: 0.9rem;
}

/* Han Viet reading - Xám đậm, chip style, KHÔNG giống link */
.han-viet-section .reading {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    text-transform: capitalize;
    background: #f3f4f6;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.vietnamese-meanings-section {
    padding: 0.25rem 0;
}

.vietnamese-meanings-section .label {
    display: block;
    font-weight: 400;
    color: #9ca3af;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.meaning-list.formatted {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Meaning items - flat, no box */
.meaning-list .meaning-item {
    padding: 0.35rem 0;
    background: transparent;
    border-radius: 0;
    line-height: 1.7;
    border-bottom: 1px solid #f3f4f6;
}

.meaning-list .meaning-item.reading-line {
    background: var(--bg-secondary);
    font-weight: 500;
    color: var(--text-accent);
}

.meaning-list .meaning-item.numbered {
    padding-left: 1.5rem;
}

.meaning-list .meaning-item.bullet {
    padding-left: 1.25rem;
}

.meaning-text {
    line-height: 1.8;
    white-space: pre-line;
}

/* Xinhua formatting */
.xinhua-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.xinhua-origin {
    font-style: italic;
    color: var(--text-tertiary);
    padding: 0.25rem 0;
    background: transparent;
    border-radius: 0;
}

.xinhua-category {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.xinhua-item {
    padding: 0.25rem 0;
    line-height: 1.7;
    background: transparent;
    border-radius: 0;
}

.xinhua-item.numbered {
    border-left: none;
    padding-left: 1.25rem;
}

/* Dark mode adjustments for meanings */
[data-theme="dark"] .han-viet-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, transparent 100%);
}

[data-theme="dark"] .meaning-list .meaning-item {
    background: var(--bg-tertiary);
}
/* New meaning block styles */
.meaning-blocks {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meaning-block .reading-header {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.meaning-list-clean {
    list-style: none;
    padding: 0;
    margin: 0;
}

.meaning-list-clean li {
    padding: 0.25rem 0;
    line-height: 1.6;
}

.meaning-list-clean li.more-indicator {
    color: var(--text-tertiary);
    font-style: italic;
}

.more-indicator {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Overview meaning def improvements */
.meaning-def {
    line-height: 1.8;
    margin-bottom: 0.75rem;
}

.meaning-def strong {
    color: var(--text-accent);
}

[data-theme="dark"] .meaning-block {
    background: var(--bg-tertiary);
}