/* ============================================================ */
/* FILE 1B: css/componentsV18.css - V18/V19/V20 STYLES          */
/* Bottom Sheet, Voice Badges, Sync Badge, Speed Chips          */
/* ============================================================ */
/* ⭐ V4 UPDATE (AUDIO LOG MODAL):
/*   🎯 THAY nút "Reset audio" → nút "📋 Audio Log"
/*   - THÊM block CSS cho modal Audio Log:
/*     • #audioLogModal .modal-content      — container modal
/*     • .audio-log-section                  — wrapper từng section
/*     • .audio-log-section-title            — title "🟢 Trạng thái hiện tại"
/*     • .audio-live-state                   — khung bảng live state
/*     • .audio-live-row                     — 1 dòng key/value
/*     • .audio-live-row .key / .val         — màu chữ, mono font
/*     • .val.ok / .val.warn / .val.err      — màu theo trạng thái
/*     • .audio-log-list                     — khung scroll log events
/*     • .audio-log-entry                    — 1 event
/*     • .audio-log-entry .time / .msg       — timestamp + message
/*     • .audio-log-entry.{type} .msg        — màu theo type
/*     • .audio-log-data                     — JSON data JSON.stringify
/*     • .audio-log-actions                  — footer 4 nút
/*   - Mobile responsive cho modal
/*   - KHÔNG đổi audio badge cũ (giữ class .audio-reset-badge)
/*
/* ⭐ V3 (AUDIO RESET BADGE):
/*   - THÊM .audio-reset-badge — badge 🔄 "Reset audio"
/*     • Fix bug iOS Safari speechSynthesis bị stuck
/*     • Cùng form với .sync-badge (kế thừa base class)
/*     • Desktop: fixed, ngay DƯỚI sync badge (top: 4rem)
/*     • Mobile: static, kế bên sync badge (DOM order)
/*     • Hover: giống sync badge (kế thừa)
/*     • Active: scale nhẹ để có tactile feedback
/* ⭐ V2 (DICTATION BADGE):
/*   - THÊM .bs-dict-badge — badge sao + L trong bs-item-meta
/*   - THÊM .bs-dict-star-filled / -empty / -label
/*   - THÊM .bs-dict-level-tag — tag 🎚️N màu tím
/*   - Mobile: badge nhỏ hơn
/* ⭐ V18 (REPLACE DROPDOWN):
/*   - THÊM .selector-badge (trigger mới)
/*   - THÊM .speed-chips-bar + .speed-chip (Speed inline)
/*   - THÊM .bs-* (Bottom Sheet system)
/*   - THÊM .voice-control-tabs (layout mới)
/* ⭐ V19 (VOICE BADGES):
/*   - THÊM .bs-voice-badge-* — phân loại voice
/* ⭐ V20 (SYNC BADGE PULSE):
/*   - THÊM .sync-badge.pulse-remote
/* ============================================================ */

/* ============================================================ */
/* ⭐ V18: VOICE CONTROL TABS — Layout mới                       */
/* ============================================================ */

.voice-control-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0.5rem auto 1.5rem auto;
    background: transparent;
    position: relative;
    z-index: 100;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 0.5rem;
}

/* ============================================================ */
/* ⭐ V18: SPEED CHIPS BAR                                       */
/* ============================================================ */

.speed-chips-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0.25rem 0.4rem 0.25rem 0.7rem;
    height: 44px;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.speed-chips-bar:hover {
    border-color: var(--accent);
}

.speed-chips-label {
    font-size: 0.9rem;
    margin-right: 0.3rem;
    flex-shrink: 0;
    opacity: 0.8;
}

.speed-chip {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
}

.speed-chip:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.speed-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.speed-chip:active {
    transform: scale(0.95);
}

/* ============================================================ */
/* ⭐ V18: SELECTOR BADGE                                       */
/* ============================================================ */

.selector-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0 0.9rem;
    height: 44px;
    max-width: 220px;
    min-width: 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.8rem;
}

.selector-badge:hover {
    border-color: var(--accent);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.selector-badge:active {
    transform: translateY(0);
}

.selector-badge .badge-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.selector-badge .badge-text {
    flex: 1;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ============================================================ */
/* ⭐ V18: BOTTOM SHEET SYSTEM                                  */
/* ============================================================ */

#bottomSheetRoot {
    position: relative;
    z-index: 1500;
}

.bs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 1499;
    -webkit-tap-highlight-color: transparent;
}

.bs-backdrop.show {
    opacity: 1;
}

.bs-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-sizing: border-box;
    overflow: hidden;
}

.bs-sheet.show {
    transform: translateY(0);
}

.bs-sheet.bs-size-auto { max-height: 70vh; height: auto; }
.bs-sheet.bs-size-half { height: 60vh; max-height: 60vh; }
.bs-sheet.bs-size-full { height: 85vh; max-height: 85vh; }

.bs-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 10px;
    margin: 0.5rem auto 0.3rem auto;
    flex-shrink: 0;
    opacity: 0.5;
}

.bs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.5rem 1.2rem 0.8rem 1.2rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.bs-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 0;
    flex: 1;
}

.bs-title-icon { font-size: 1.2rem; flex-shrink: 0; }

.bs-close {
    background: var(--bg-primary);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
    font-family: inherit;
    padding: 0;
    line-height: 1;
}

.bs-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

.bs-close:active {
    transform: rotate(90deg) scale(0.9);
}

.bs-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.6rem 0;
    min-height: 0;
}

.bs-body::-webkit-scrollbar { width: 6px; }
.bs-body::-webkit-scrollbar-track { background: var(--bg-primary); border-radius: 10px; }
.bs-body::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 10px; }
.bs-body::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.bs-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.bs-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem 0.6rem 1rem;
    padding: 0.5rem 0.9rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 60px;
    transition: all 0.2s ease;
}

.bs-search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.bs-search-icon { font-size: 0.9rem; flex-shrink: 0; opacity: 0.7; }

.bs-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.3rem 0;
    outline: none;
    font-family: inherit;
    min-width: 0;
}

.bs-search-input::placeholder { color: var(--text-secondary); opacity: 0.6; }

.bs-content { padding: 0 0.4rem; }

.bs-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 1rem 0.3rem 1rem;
    opacity: 0.7;
}

.bs-section-nofolder {
    border-top: 1px dashed var(--border);
    margin-top: 0.5rem;
    padding-top: 0.8rem;
}

.bs-folder { margin-bottom: 0.15rem; }

.bs-folder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
    border-radius: 10px;
    margin: 0 0.4rem;
}

.bs-folder-header:hover { background: var(--bg-primary); }

.bs-folder-toggle {
    font-size: 0.6rem;
    color: var(--text-secondary);
    transition: transform 0.25s ease;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.bs-folder-toggle.open { transform: rotate(90deg); }

.bs-folder-icon { font-size: 1rem; flex-shrink: 0; }

.bs-folder-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.bs-folder-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    flex-shrink: 0;
    font-weight: 600;
}

.bs-folder-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 0;
}

.bs-folder-children.open {
    max-height: 3000px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.bs-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem 0.65rem 1.6rem;
    cursor: pointer;
    border-radius: 10px;
    margin: 0.1rem 0.4rem;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    min-width: 0;
}

.bs-item:hover {
    background: var(--bg-primary);
    border-color: var(--border);
}

.bs-item:active { transform: scale(0.99); }

.bs-item.active {
    background: rgba(59, 130, 246, 0.08);
    border-color: var(--accent);
}

.bs-item-main { flex: 1; min-width: 0; }

.bs-item-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.bs-item.active .bs-item-name { color: var(--accent); }

.bs-item-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem;
}

.bs-item-check {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.bs-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1rem;
    opacity: 0.6;
}

.bs-item-advanced { padding-left: 1rem; }
.bs-item-advanced .bs-item-name { color: var(--accent); }

.bs-model-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-radius: 12px;
    margin: 0.15rem 0.6rem;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.bs-model-item:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.bs-model-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent);
}

.bs-model-main { flex: 1; min-width: 0; }

.bs-model-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.bs-model-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
    vertical-align: middle;
}

.bs-model-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    line-height: 1.4;
}

.bs-model-stars {
    font-size: 0.72rem;
    margin-top: 0.25rem;
    opacity: 0.85;
    letter-spacing: -1px;
}

.bs-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.bs-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
    display: block;
    line-height: 1;
}

.bs-empty p {
    margin: 0.5rem 0 0 0;
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.5;
}

.bs-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: bsSpin 0.8s linear infinite;
    margin: 0 auto 0.6rem auto;
}

@keyframes bsSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================ */
/* ⭐ V2: DICTATION BADGE TRONG BS-ITEM-META                     */
/* Hiển thị: "· ⭐⭐⭐☆☆ L3 🎚️3" ngay cạnh số câu               */
/* ============================================================ */

.bs-dict-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.05rem;
    margin-left: 0.15rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

.bs-dict-badge .bs-dict-star-filled {
    color: #fbbf24;
    letter-spacing: -1px;
    font-size: 0.68rem;
    line-height: 1;
}

.bs-dict-badge .bs-dict-star-empty {
    color: rgba(148, 163, 184, 0.4);
    letter-spacing: -1px;
    font-size: 0.68rem;
    line-height: 1;
}

.bs-dict-badge .bs-dict-star-label {
    margin-left: 0.15rem;
    font-weight: 800;
    font-size: 0.62rem;
    color: #f59e0b;
    letter-spacing: 0.3px;
    opacity: 0.95;
}

/* Tag hiển thị level distractor: 🎚️3 */
.bs-dict-level-tag {
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
    padding: 0.05rem 0.4rem;
    border-radius: 10px;
    font-size: 0.6rem;
    font-weight: 800;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.35);
    letter-spacing: 0.2px;
    line-height: 1.3;
    vertical-align: middle;
}

/* ============================================================ */
/* ⭐ V19: VOICE BADGES                                         */
/* ============================================================ */

.bs-voice-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.3rem;
    align-items: center;
}

.bs-voice-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.12rem 0.45rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: transform 0.15s ease;
}

.bs-voice-badge-icon { font-size: 0.7rem; line-height: 1; flex-shrink: 0; }
.bs-voice-badge-label { font-size: 0.65rem; letter-spacing: 0.2px; }

.bs-voice-badge-enhanced {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(236, 72, 153, 0.12));
    color: #d946ef;
    border-color: rgba(168, 85, 247, 0.4);
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(168, 85, 247, 0.15);
}

.bs-voice-badge-premium {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.12));
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.45);
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.15);
}

.bs-voice-badge-siri {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.35);
}

.bs-voice-badge-natural {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(59, 130, 246, 0.1));
    color: #10b981;
    border-color: rgba(34, 197, 94, 0.35);
    font-weight: 700;
}

.bs-voice-badge-compact {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
    border-color: rgba(148, 163, 184, 0.25);
    opacity: 0.85;
}

.bs-voice-badge-standard {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.25);
}

.bs-voice-badge-local {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.25);
}

.bs-voice-badge-cloud {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border-color: rgba(100, 116, 139, 0.3);
}

.bs-voice-lang {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    opacity: 0.75;
    letter-spacing: 0.2px;
}

.bs-voice-default-badge {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.15rem 0.65rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(59, 130, 246, 0.1));
    color: var(--success);
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 20px;
    border: 1px solid rgba(34, 197, 94, 0.3);
    box-shadow: 0 1px 4px rgba(34, 197, 94, 0.15);
    letter-spacing: 0.2px;
}

.bs-voice-item {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    align-items: flex-start;
}

.bs-voice-item .bs-item-name {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.bs-voice-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(168, 85, 247, 0.06));
    border-color: var(--accent);
}

.bs-voice-item.active .bs-item-name {
    color: var(--accent);
    font-weight: 700;
}

.bs-voice-item:hover .bs-voice-badge-enhanced {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(168, 85, 247, 0.25);
}

.bs-voice-item:hover .bs-voice-badge-premium {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
}

/* ============================================================ */
/* ⭐ V20: iOS VOICE HINT BANNER                                */
/* ============================================================ */

.bs-voice-ios-hint {
    margin: 0 1rem 0.8rem 1rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(168, 85, 247, 0.05));
    border-radius: 14px;
    border-left: 3px solid var(--accent);
    animation: fadeIn 0.3s ease;
}

.bs-voice-ios-hint-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.bs-voice-ios-hint-list {
    margin: 0;
    padding-left: 1.3rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.bs-voice-ios-hint-list li { margin-bottom: 0.15rem; }
.bs-voice-ios-hint-list strong { color: var(--text-primary); font-weight: 600; }

.bs-voice-ios-hint-note {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(59, 130, 246, 0.25);
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.85;
    line-height: 1.5;
    font-style: italic;
}

@media (max-width: 768px) {
    .bs-voice-ios-hint {
        padding: 0.7rem 0.8rem;
        margin: 0 0.8rem 0.6rem 0.8rem;
    }
    .bs-voice-ios-hint-title { font-size: 0.8rem; }
    .bs-voice-ios-hint-list { font-size: 0.72rem; padding-left: 1.1rem; }
    .bs-voice-ios-hint-note { font-size: 0.68rem; }
}

/* ============================================================ */
/* ===== SYNC BADGE + MODAL ===== */
/* ============================================================ */

.sync-badge {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 60px;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-family: inherit;
}

.sync-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.sync-badge.status-idle { color: var(--text-secondary); }
.sync-badge.status-syncing { color: var(--warning); animation: syncPulse 1s infinite; }
.sync-badge.status-synced {
    color: var(--success);
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}
.sync-badge.status-error {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.sync-badge.status-offline { color: var(--text-secondary); opacity: 0.6; }

.sync-badge-icon { font-size: 0.95rem; }
.sync-badge-text { font-size: 0.75rem; font-weight: 600; }

@keyframes syncPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#syncModal .modal-content {
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#syncModal .sync-code-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-primary);
    padding: 0.7rem 1rem;
    border-radius: 12px;
    border: 2px dashed var(--accent);
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    justify-content: space-between;
    margin: 0.8rem 0;
    word-break: break-all;
}

#syncModal .sync-option-btn:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

#syncModal .sync-status-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

#syncModal .sync-status-row:last-child { border-bottom: none; }
#syncModal .sync-status-row span:first-child { color: var(--text-secondary); flex-shrink: 0; }
#syncModal .sync-status-row span:last-child {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

/* ============================================================ */
/* ⭐ V20: SYNC BADGE PULSE ON REMOTE UPDATE                    */
/* ============================================================ */

.sync-badge.pulse-remote {
    animation: syncRemotePulse 2s cubic-bezier(0.4, 0, 0.6, 1);
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

@keyframes syncRemotePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
        border-color: var(--success);
    }
    20% {
        transform: scale(1.08);
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.3);
    }
    40% {
        transform: scale(1);
        box-shadow: 0 0 0 12px rgba(34, 197, 94, 0);
    }
    60% {
        transform: scale(1.05);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
        border-color: var(--border);
    }
}

.sync-badge.pulse-remote .sync-badge-icon {
    display: inline-block;
    animation: syncIconSpin 2s ease;
}

@keyframes syncIconSpin {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

.sync-badge.pulse-remote .sync-badge-text {
    color: var(--success);
    font-weight: 700;
}

@media (min-width: 769px) {
    .sync-badge.pulse-remote {
        z-index: 501;
    }
}

@media (max-width: 768px) {
    .sync-badge.pulse-remote {
        background: rgba(34, 197, 94, 0.1);
        border-color: var(--success);
    }

    @keyframes syncRemotePulse {
        0% {
            transform: scale(1);
            box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
        }
        50% {
            transform: scale(1.05);
            box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2);
        }
        100% {
            transform: scale(1);
            box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .sync-badge.pulse-remote {
        animation: none;
        background: rgba(34, 197, 94, 0.15);
        border-color: var(--success);
    }

    .sync-badge.pulse-remote .sync-badge-icon {
        animation: none;
    }
}

/* ============================================================ */
/* ⭐ V9: MOBILE SYNC BADGE                                     */
/* ============================================================ */

@media (max-width: 768px) {
    .sync-badge {
        position: static;
        display: flex;
        width: fit-content;
        max-width: 90%;
        margin: 0 auto 1rem auto;
        padding: 0.5rem 1.2rem;
        font-size: 0.85rem;
        border-radius: 60px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        justify-content: center;
    }

    .sync-badge:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }

    .sync-badge-icon { font-size: 1rem; }
    .sync-badge-text { font-size: 0.78rem; }

    #syncModal .modal-content { max-width: 95%; padding: 1.5rem; }
    #syncModal .sync-code-display {
        font-size: 0.9rem;
        letter-spacing: 1.2px;
        padding: 0.6rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .sync-badge {
        padding: 0.45rem 1rem;
        font-size: 0.8rem;
        margin-bottom: 0.9rem;
    }
    .sync-badge-icon { font-size: 0.95rem; }
    .sync-badge-text { font-size: 0.75rem; }
}

/* ============================================================ */
/* ⭐ V3 (Group H): AUDIO RESET BADGE                           */
/* ============================================================ */
/* Bug fix: iOS Safari speechSynthesis bị stuck — bấm 🔊 không  */
/* ra tiếng, phải kill Safari đa nhiệm mới hết.                 */
/*                                                              */
/* Design:                                                      */
/*   • Cùng form với sync badge (reuse base class .sync-badge)  */
/*   • DOM order: append SAU sync badge → mobile tự xếp dưới    */
/*   • Desktop: fixed, top: 4rem (ngay DƯỚI sync badge)         */
/*   • Mobile: static, kế thừa từ .sync-badge media query       */
/*   • Hover: kế thừa từ .sync-badge:hover                      */
/*   • Active: scale nhẹ — tactile feedback                     */
/*                                                              */
/* Click → gọi window.resetAudio() → toast do resetAudio() show */
/* KHÔNG auto pulse khi fail (theo yêu cầu Q3 = B)              */
/* ============================================================ */

.audio-reset-badge {
    /* Vị trí: fixed ngay dưới sync badge (sync badge đang top: 1rem) */
    top: 4rem;
    /* Color mặc định kế thừa từ .sync-badge.status-idle */
}

.audio-reset-badge:hover {
    /* Kế thừa hover từ .sync-badge, chỉ thêm accent border */
    border-color: var(--accent);
    color: var(--text-primary);
}

.audio-reset-badge:active {
    /* Tactile feedback nhẹ khi bấm */
    transform: scale(0.96);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Mobile: reset vị trí để kế thừa static từ .sync-badge media query */
@media (max-width: 768px) {
    .audio-reset-badge {
        top: auto;
        /* .sync-badge mobile query đã set: position: static; margin: 0 auto 1rem auto; */
        /* DOM order: append sau sync badge → tự xếp dưới */
    }

    .audio-reset-badge:hover {
        /* Mobile không hover — nhưng nếu user có stylus vẫn smooth */
        transform: translateY(-1px);
    }

    .audio-reset-badge:active {
        transform: scale(0.96);
    }
}

@media (max-width: 480px) {
    .audio-reset-badge {
        /* Kế thừa từ .sync-badge @480px */
        margin-bottom: 0.9rem;
    }
}

/* ============================================================ */
/* ⭐ V4: AUDIO LOG MODAL — Diagnostic & Event Log              */
/* ============================================================ */
/* Modal mở khi user click badge "📋 Audio Log".                */
/* Hiển thị: live state + event log + 4 nút action.             */
/* ============================================================ */

#audioLogModal .modal-content {
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5rem;
}

/* ----- Section wrapper ----- */
.audio-log-section {
    margin-bottom: 1rem;
}

.audio-log-section:last-of-type {
    margin-bottom: 0;
}

.audio-log-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0.9;
}

/* ----- Live state table ----- */
.audio-live-state {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    font-family: 'Courier New', 'SF Mono', monospace;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    line-height: 1.6;
}

.audio-live-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.22rem 0;
    gap: 0.5rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}

.audio-live-row:last-child {
    border-bottom: none;
}

.audio-live-row .key {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.audio-live-row .val {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

.audio-live-row .val.ok {
    color: var(--success);
}

.audio-live-row .val.warn {
    color: var(--warning);
}

.audio-live-row .val.err {
    color: var(--danger);
}

/* ----- Event log list ----- */
.audio-log-list {
    background: #0a0a0a;
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'Courier New', 'SF Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    border: 1px solid var(--border);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.audio-log-list::-webkit-scrollbar { width: 6px; }
.audio-log-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}
.audio-log-list::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 10px;
}
.audio-log-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.audio-log-entry {
    padding: 0.3rem 0.1rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    word-break: break-word;
}

.audio-log-entry:last-child {
    border-bottom: none;
}

.audio-log-entry .time {
    color: #64748b;
    font-size: 0.68rem;
    flex-shrink: 0;
    letter-spacing: -0.2px;
}

.audio-log-entry .msg {
    flex: 1;
    min-width: 0;
}

/* Màu theo type */
.audio-log-entry.speak .msg { color: #60a5fa; }
.audio-log-entry.start .msg { color: #22c55e; }
.audio-log-entry.end .msg { color: #22c55e; }
.audio-log-entry.error .msg { color: #ef4444; }
.audio-log-entry.watchdog .msg { color: #94a3b8; }
.audio-log-entry.system .msg { color: #a78bfa; }

.audio-log-data {
    color: #64748b;
    font-size: 0.68rem;
    display: block;
    margin-left: 1.4rem;
    margin-top: 0.1rem;
    word-break: break-all;
    opacity: 0.8;
}

/* ----- Footer actions ----- */
.audio-log-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 0.9rem;
    flex-shrink: 0;
}

.audio-log-actions button {
    font-size: 0.82rem;
    padding: 0.5rem 1rem;
    border-radius: 60px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    border: 1px solid var(--border);
}

.audio-log-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #audioLogModal .modal-content {
        max-width: 95%;
        max-height: 92vh;
        padding: 1.1rem;
        border-radius: 20px;
    }

    .audio-log-section-title {
        font-size: 0.72rem;
    }

    .audio-live-state {
        font-size: 0.72rem;
        padding: 0.6rem 0.75rem;
    }

    .audio-live-row {
        padding: 0.18rem 0;
    }

    .audio-log-list {
        max-height: 220px;
        font-size: 0.68rem;
        padding: 0.5rem 0.65rem;
    }

    .audio-log-entry .time {
        font-size: 0.62rem;
    }

    .audio-log-data {
        font-size: 0.62rem;
        margin-left: 1.2rem;
    }

    .audio-log-actions {
        justify-content: stretch;
        gap: 0.4rem;
    }

    .audio-log-actions button {
        flex: 1;
        min-width: calc(50% - 0.2rem);
        font-size: 0.75rem;
        padding: 0.55rem 0.5rem;
    }
}

@media (max-width: 480px) {
    #audioLogModal .modal-content {
        padding: 0.9rem;
        max-height: 94vh;
    }

    .audio-log-section {
        margin-bottom: 0.75rem;
    }

    .audio-live-state {
        font-size: 0.68rem;
        padding: 0.5rem 0.65rem;
        border-radius: 10px;
    }

    .audio-log-list {
        max-height: 180px;
        font-size: 0.64rem;
    }

    .audio-log-actions button {
        font-size: 0.7rem;
        padding: 0.5rem 0.4rem;
    }
}

/* ============================================================ */
/* ⭐ V18: RESPONSIVE — Voice Control Tabs                      */
/* ============================================================ */

@media (max-width: 768px) {
    .voice-control-tabs {
        gap: 0.4rem;
        padding: 0 0.3rem;
        margin: 0.5rem auto 1.2rem auto;
    }

    .speed-chips-bar {
        order: 1;
        flex: 1 1 100%;
        max-width: 100%;
        justify-content: center;
        height: 42px;
    }

    .speed-chip {
        flex: 1;
        min-width: 0;
        font-size: 0.7rem;
        padding: 0.35rem 0.4rem;
    }

    .selector-badge {
        order: 2;
        flex: 1 1 0;
        max-width: none;
        min-width: 0;
        height: 42px;
        padding: 0 0.6rem;
        gap: 0.3rem;
    }

    .selector-badge .badge-icon { font-size: 0.9rem; }
    .selector-badge .badge-text { font-size: 0.72rem; }

    .bs-sheet {
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .bs-sheet.bs-size-auto { max-height: 75vh; }
    .bs-sheet.bs-size-half { height: 65vh; max-height: 65vh; }
    .bs-sheet.bs-size-full { height: 88vh; max-height: 88vh; }

    .bs-header { padding: 0.4rem 1rem 0.7rem 1rem; }
    .bs-title { font-size: 0.95rem; }
    .bs-search-wrap { margin: 0 0.8rem 0.5rem 0.8rem; }

    .bs-item { padding: 0.6rem 0.8rem 0.6rem 1.3rem; }
    .bs-item-name { font-size: 0.85rem; }
    .bs-item-meta { font-size: 0.7rem; }

    /* ⭐ V2: Dictation badge mobile */
    .bs-dict-badge { font-size: 0.62rem; }
    .bs-dict-badge .bs-dict-star-filled,
    .bs-dict-badge .bs-dict-star-empty { font-size: 0.62rem; }
    .bs-dict-badge .bs-dict-star-label { font-size: 0.58rem; }
    .bs-dict-level-tag { font-size: 0.56rem; padding: 0.03rem 0.35rem; }

    .bs-model-item { padding: 0.7rem 0.8rem; }
    .bs-model-name { font-size: 0.85rem; }
    .bs-model-desc { font-size: 0.72rem; }

    .bs-voice-item { padding-top: 0.65rem; padding-bottom: 0.65rem; }
    .bs-voice-item .bs-item-name { font-size: 0.85rem; }
    .bs-voice-badge { font-size: 0.6rem; padding: 0.1rem 0.4rem; }
    .bs-voice-badge-icon { font-size: 0.65rem; }
    .bs-voice-badge-label { font-size: 0.6rem; }
    .bs-voice-lang { font-size: 0.65rem; }
    .bs-voice-default-badge { font-size: 0.6rem; padding: 0.12rem 0.55rem; }
}

@media (max-width: 380px) {
    .voice-control-tabs {
        gap: 0.3rem;
        padding: 0 0.2rem;
    }

    .speed-chips-bar {
        height: 40px;
        padding: 0.2rem 0.3rem 0.2rem 0.5rem;
    }

    .speed-chips-label { font-size: 0.8rem; margin-right: 0.15rem; }
    .speed-chip { font-size: 0.65rem; padding: 0.3rem 0.3rem; min-width: 0; }

    .selector-badge { height: 40px; padding: 0 0.5rem; }
    .selector-badge .badge-icon { font-size: 0.85rem; }
    .selector-badge .badge-text { font-size: 0.68rem; }

    .bs-item { padding: 0.55rem 0.7rem 0.55rem 1.1rem; }
    .bs-item-name { font-size: 0.82rem; }

    /* ⭐ V2: Dictation badge cực nhỏ */
    .bs-dict-badge { font-size: 0.56rem; margin-left: 0.1rem; }
    .bs-dict-badge .bs-dict-star-filled,
    .bs-dict-badge .bs-dict-star-empty { font-size: 0.56rem; }
    .bs-dict-badge .bs-dict-star-label { font-size: 0.52rem; margin-left: 0.1rem; }
    .bs-dict-level-tag { font-size: 0.5rem; padding: 0.02rem 0.3rem; margin-left: 0.15rem; }

    .bs-voice-badge { font-size: 0.55rem; padding: 0.08rem 0.35rem; gap: 0.1rem; }
    .bs-voice-badge-icon { font-size: 0.6rem; }
    .bs-voice-badge-label { font-size: 0.55rem; }
    .bs-voice-badges { gap: 0.15rem; }
}

/* ============================================================ */
/* ===== END FILE 1B ===== */
/* ============================================================ */