/**
 * Word Popup Component Styles
 * Shared across: collection.html, reader.html, telegram/message.html
 *
 * Requires CSS variables to be defined in parent:
 *   --bg-primary, --bg-secondary, --card-bg, --text-primary, --text-secondary,
 *   --text-muted, --border-color, --accent-color, --accent-hover
 */

/* Word Popup Container */
.word-popup {
    display: none;
    position: absolute;
    background: var(--card-bg, var(--bg-primary));
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    border: 1px solid var(--border-color);
    z-index: 900; /* Below navbar (1000) so it slides under when scrolling */
    width: 280px;
    max-width: calc(100vw - 24px); /* Don't overflow viewport on mobile */
    max-height: 50vh;
    overflow-y: auto;
    transition: box-shadow 0.2s ease;
}

/* Wider popup on larger screens for languages with long compound words */
@media (min-width: 400px) {
    .word-popup {
        width: 320px;
    }
    .word-popup.expanded {
        width: 340px;
    }
}

.word-popup.show {
    display: flex;
    flex-direction: column;
}

.word-popup.expanded {
    width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}

/* When popup is above the word, flip the layout so menu expands upward */
.word-popup.position-above {
    flex-direction: column-reverse;
}

.word-popup.position-above .word-popup-menu {
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    margin-top: 0;
    margin-bottom: 10px;
    padding-top: 0;
    padding-bottom: 6px;
}

/* Main content area */
.word-popup-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.word-popup-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.word-popup-char {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 4px;
}

/* Lemma display - shows base form when different from surface form */
/* e.g., "vägen → väg" */
.word-popup-lemma {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.word-popup-lemma .lemma-word {
    color: var(--accent-color);
    font-weight: 500;
}

/* Gender badge (Swedish en/ett) */
.gender-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.gender-badge.gender-common {
    background: #e3f2fd;
    color: #1565c0;
}

.gender-badge.gender-neuter {
    background: #fce4ec;
    color: #c2185b;
}

/* Accent badge */
.accent-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.accent-badge.accent-1 {
    background: #e8f5e9;
    color: #2e7d32;
}

.accent-badge.accent-2 {
    background: #fff3e0;
    color: #ef6c00;
}

/* Meaning row - holds POS badge + meaning inline */
.word-popup-meaning-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

/* POS badge (part of speech) - filled style with white text */
.pos-badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    text-transform: lowercase;
    background: var(--bg-secondary);
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 1px;
}

.pos-badge.pos-verb { background: #4A90D9; color: white; }
.pos-badge.pos-noun { background: #D97706; color: white; }
.pos-badge.pos-adj { background: #059669; color: white; }
.pos-badge.pos-adv { background: #7C3AED; color: white; }
.pos-badge.pos-clf { background: #BE185D; color: white; }   /* Classifier/measure word */
.pos-badge.pos-name { background: #DC2626; color: white; }  /* Proper nouns */
.pos-badge.pos-expr { background: #4338CA; color: white; }  /* Expression/idiom */
.pos-badge.pos-prep,
.pos-badge.pos-conj,
.pos-badge.pos-part,
.pos-badge.pos-aux,
.pos-badge.pos-pron { background: #64748b; color: white; }

.word-popup-pinyin {
    font-size: 0.9rem;
    color: var(--accent-color);
    font-weight: 500;
}

.word-popup-meaning {
    font-size: 0.85rem;
    color: var(--text-muted);
    word-break: break-word;
}

/* Classifiers row (Chinese measure words) */
.word-popup-classifiers {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-color);
}

.word-popup-classifiers .clf-label {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.word-popup-classifiers .clf-list {
    color: var(--text-secondary);
    font-weight: 500;
}

.word-popup-more {
    font-size: 0.75rem;
    color: var(--accent-color);
    text-decoration: none;
    margin-left: 4px;
    cursor: pointer;
}

.word-popup-more:hover {
    text-decoration: underline;
}

/* Grouped definitions for homographs (words with multiple POS) */
.word-popup-definitions-grouped {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.word-popup-pos-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.word-popup-pos-group .pos-label {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: lowercase;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    min-width: 28px;
    text-align: center;
}

.word-popup-pos-group .pos-definitions {
    color: var(--text-muted);
    word-break: break-word;
}

/* Detected/primary POS group is highlighted */
.word-popup-pos-group.detected .pos-label {
    background: var(--accent-color);
    color: white;
}

.word-popup-pos-group.detected .pos-definitions {
    color: var(--text-primary);
    font-weight: 500;
}

/* Secondary POS groups are faded */
.word-popup-pos-group.secondary {
    opacity: 0.6;
}

.word-popup-pos-group.secondary:hover {
    opacity: 0.9;
}

/* POS-specific colors for labels */
.word-popup-pos-group .pos-label.pos-verb { background: #4A90D9; color: white; }
.word-popup-pos-group .pos-label.pos-noun { background: #D97706; color: white; }
.word-popup-pos-group .pos-label.pos-adj { background: #059669; color: white; }
.word-popup-pos-group .pos-label.pos-adv { background: #7C3AED; color: white; }
.word-popup-pos-group .pos-label.pos-clf { background: #BE185D; color: white; }
.word-popup-pos-group .pos-label.pos-name { background: #DC2626; color: white; }
.word-popup-pos-group .pos-label.pos-expr { background: #4338CA; color: white; }
.word-popup-pos-group.secondary .pos-label { opacity: 0.7; }

/* Mandarin reading label (pinyin) */
.word-popup-pos-group .pos-label.reading-label {
    background: #DC2626;
    color: white;
    font-style: italic;
    min-width: 60px;
    text-align: center;
}
.word-popup-pos-group.secondary .pos-label.reading-label { opacity: 0.5; }

/* Action buttons (level, audio, add) */
.word-popup-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Level badge in actions column */
.word-popup-actions .word-popup-level {
    font-size: 0.6rem;
    padding: 3px 6px;
    margin-bottom: 2px;
}

/* Frequency badge in actions column */
.word-popup-freq {
    font-size: 0.6rem;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* Frequency color classes */
.freq-very-common {
    background: #e8f5e9;
    color: #2e7d32;
}

.freq-common {
    background: #e3f2fd;
    color: #1565c0;
}

.freq-uncommon {
    background: #fff3e0;
    color: #ef6c00;
}

.freq-rare {
    background: #ffebee;
    color: #c62828;
}

.word-popup-audio,
.word-popup-add {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    font-size: 0.85rem;
}

.word-popup-audio:hover,
.word-popup-add:hover {
    background: var(--accent-color);
    color: white;
}

/* Touch-friendly: also style active state for mobile */
.word-popup-audio:active,
.word-popup-add:active {
    background: var(--accent-color);
    color: white;
}

.word-popup-add.in-collection {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.word-popup-add.in-collection:hover,
.word-popup-add.in-collection:active {
    background: rgba(34, 197, 94, 0.25);
    color: #16a34a;
}

.word-popup-add.in-other {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.word-popup-add.in-other:hover,
.word-popup-add.in-other:active {
    background: rgba(34, 197, 94, 0.2);
}

/* Collection menu */
.word-popup-menu {
    display: none;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
    padding-top: 6px;
    animation: wordPopupMenuFadeIn 0.15s ease-out;
}

@keyframes wordPopupMenuFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.word-popup-menu.show {
    display: block;
}

.word-popup-menu-items {
    /* Container for menu items */
}

.word-popup-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-radius: 6px;
}

.word-popup-menu-item:hover,
.word-popup-menu-item:active {
    background: var(--bg-secondary);
}

.word-popup-menu-item i {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 16px;
    text-align: center;
}

.word-popup-menu-item.current {
    color: var(--accent-color);
}

.word-popup-menu-item.current i {
    color: var(--accent-color);
}

.word-popup-menu-item.in-collection {
    color: var(--text-muted);
    cursor: default;
}

.word-popup-menu-item.in-collection:hover,
.word-popup-menu-item.in-collection:active {
    background: transparent;
}

.word-popup-menu-item.in-collection i {
    color: #22c55e;
}

.word-popup-menu-item.remove {
    color: #ef4444;
}

.word-popup-menu-item.remove i {
    color: #ef4444;
}

.word-popup-menu-item.remove:hover,
.word-popup-menu-item.remove:active {
    background: rgba(239, 68, 68, 0.1);
}

/* Search input */
.word-popup-menu-search {
    padding: 4px 0 8px 0;
}

.word-popup-menu-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-sizing: border-box;
}

.word-popup-menu-search input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* More hint */
.word-popup-menu-more {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 6px 4px;
    text-align: center;
}

/* Divider */
.word-popup-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* New collection form */
.word-popup-menu-new {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
}

.word-popup-menu-new input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 0;
}

.word-popup-menu-new input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.word-popup-menu-new button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.word-popup-menu-new button:hover,
.word-popup-menu-new button:active {
    background: var(--accent-hover, var(--accent-color));
    filter: brightness(1.1);
}

/* Back button (for component detail view) */
.word-popup-back {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 8px;
    transition: color 0.15s;
}

.word-popup-back:hover {
    color: var(--accent-color);
}

.word-popup-back i {
    font-size: 0.75rem;
}

/* Word popup header (char + level) */
.word-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Level pill styles are in base.css */

/* Legacy class for backwards compatibility */
.word-popup-level {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* ============================================================
   Tabbed Interface - Icon Buttons Style
   ============================================================ */

/* Tab bar with icon buttons - left aligned, same size as action buttons */
.word-popup-tabs-icons {
    display: flex;
    justify-content: flex-start;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.word-popup-tab-icon {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    font-size: 0.85rem;
}

.word-popup-tab-icon:hover {
    background: var(--accent-color);
    color: white;
}

.word-popup-tab-icon.active {
    background: var(--accent-color);
    color: white;
}

.word-popup-tab-icon.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.word-popup-tab-icon.disabled:hover {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* Tab content area */
.word-popup-tab-content {
    display: none;
    margin-top: 10px;
}

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

/* Component/Character list (inside tab) */
.word-popup-components {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.word-popup-component {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.word-popup-component:hover {
    background: var(--accent-color);
}

.word-popup-component:hover .component-char,
.word-popup-component:hover .component-pinyin,
.word-popup-component:hover .component-meaning {
    color: white;
}

.component-char {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 24px;
}

.component-info {
    flex: 1;
    min-width: 0;
}

.component-pinyin {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 500;
}

.component-meaning {
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.component-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin-left: auto;
    padding-right: 4px;
}

.component-meta .word-popup-level,
.component-meta .level-pill {
    font-size: 0.55rem;
    padding: 2px 4px;
}

/* Frequency dot indicator (simple common/uncommon/rare) */
.freq-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.freq-dot-common {
    background: #4caf50;
}

.freq-dot-uncommon {
    background: #ff9800;
}

.freq-dot-rare {
    background: #f44336;
}

.word-popup-component:hover .freq-dot {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.component-arrow {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.word-popup-component:hover .component-arrow {
    color: white;
}

/* Forms list (conjugations, declensions) */
.word-popup-forms {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.word-popup-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.8rem;
}

.word-popup-form.current {
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid var(--accent-color);
}

.form-word {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 80px;
}

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

/* Noun Declension Grid - 2x2 layout */
.noun-forms-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 2px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.75rem;
}

/* Allow horizontal scroll on the tab content if grid is too wide */
.word-popup-tab-content[data-tab-content="forms"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.word-popup-tab-content[data-tab-content="forms"]::-webkit-scrollbar {
    height: 4px;
}

.word-popup-tab-content[data-tab-content="forms"]::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.noun-forms-grid .grid-header {
    background: var(--bg-secondary);
    padding: 5px 6px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.noun-forms-grid .grid-label {
    background: var(--bg-secondary);
    padding: 6px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.noun-forms-grid .grid-cell {
    background: var(--card-bg);
    padding: 6px;
    text-align: center;
    white-space: nowrap;
}

.noun-forms-grid .form-word {
    font-weight: 500;
    color: var(--text-primary);
    min-width: auto;
}

.noun-forms-grid .grid-cell:has(.form-word.current) {
    background: var(--accent-color);
}

.noun-forms-grid .form-word.current {
    color: #fff;
    font-weight: 600;
}

.noun-forms-grid .form-empty {
    color: var(--text-muted);
}

/* Verb Conjugation Table - Grid layout with Active/Passive columns */
.verb-forms-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 2px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.75rem;
}

.verb-forms-grid .grid-header {
    background: var(--bg-secondary);
    padding: 5px 6px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.verb-forms-grid .grid-label {
    background: var(--bg-secondary);
    padding: 6px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.verb-forms-grid .grid-cell {
    background: var(--card-bg);
    padding: 6px;
    text-align: center;
    white-space: nowrap;
}

.verb-forms-grid .form-word {
    font-weight: 500;
    color: var(--text-primary);
}

.verb-forms-grid .grid-cell:has(.form-word.current) {
    background: var(--accent-color);
}

.verb-forms-grid .form-word.current {
    color: #fff;
    font-weight: 600;
}

.verb-forms-grid .form-empty {
    color: var(--text-muted);
}

/* Fallback for simple verb list (languages without active/passive distinction) */
.verb-forms-table {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.verb-form-row {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 8px 12px;
}

.verb-form-row .form-label {
    min-width: 80px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.verb-form-row .form-word {
    font-weight: 500;
    color: var(--text-primary);
    min-width: auto;
}

.verb-form-row.current {
    background: var(--accent-color);
}

.verb-form-row.current .form-label,
.verb-form-row.current .form-word {
    color: #fff;
    font-weight: 600;
}

/* Metrics list (frequency data) */
.word-popup-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metrics-header {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.word-popup-metric {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

.metric-corpus {
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 90px;
    flex-shrink: 0;
}

.metric-bar-container {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.metric-bar-fill.freq-very-common {
    background: #4caf50;
}

.metric-bar-fill.freq-common {
    background: #2196f3;
}

.metric-bar-fill.freq-uncommon {
    background: #ff9800;
}

.metric-bar-fill.freq-rare {
    background: #f44336;
}

.metric-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 45px;
    text-align: right;
}

/* Examples list */
.word-popup-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.word-popup-example {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* Loading state */
.word-popup-loading {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.word-popup-loading i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Empty state */
.word-popup-empty {
    text-align: center;
    padding: 20px 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.word-popup-empty i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* ============================================================
   Add to Collection View
   ============================================================ */

.word-popup-add-view {
    /* Container for the add-to-collection subpage */
}

.word-popup-add-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.word-popup-add-word {
    font-size: 1.1rem;
    font-weight: 600;
}

.word-popup-add-pinyin {
    font-size: 0.8rem;
    color: var(--accent-color);
}

.word-popup-collection-list {
    max-height: 200px;
    overflow-y: auto;
}

.word-popup-collection-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.word-popup-collection-item:hover {
    background: var(--bg-secondary);
}

.word-popup-collection-item.in-collection {
    background: rgba(34, 197, 94, 0.1);
}

.word-popup-collection-item.in-collection:hover {
    background: rgba(34, 197, 94, 0.15);
}

.collection-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.word-popup-collection-item.in-collection .collection-item-icon {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.collection-item-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
}

.collection-item-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.collection-item-check {
    color: #22c55e;
    font-size: 0.9rem;
}

/* New collection input */
.word-popup-new-collection {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    align-items: center;
}

.word-popup-new-collection input {
    flex: 1;
    padding: 8px 12px;
    margin-bottom: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.word-popup-new-collection input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.word-popup-new-collection button {
    padding: 8px 16px;
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    background: var(--accent-color);
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.word-popup-new-collection button:hover {
    filter: brightness(1.1);
}

/* Standalone Collection Picker Modal */
.word-popup-modal {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 20px;
    max-width: 360px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.word-popup-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.word-popup-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.word-popup-modal .word-popup-add-view {
    padding: 0;
}

.word-popup-modal .word-popup-add-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.word-popup-add-meaning {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* =========================================================================
   Strokes Tab (Mandarin stroke order animation)
   ========================================================================= */

.word-popup-strokes {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
}

.strokes-container {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 80px;
}

.strokes-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    width: 100%;
    height: 80px;
}

.strokes-loading i {
    animation: spin 1s linear infinite;
}

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

.stroke-char-box {
    width: 80px;
    height: 80px;
    display: inline-block;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.stroke-char-box:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.05));
}

.stroke-char-box:active {
    transform: scale(0.95);
}

.stroke-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 48px;
    color: var(--text-muted);
}

.strokes-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}
