/* ============================================================
   PHẦN 1: CẤU TRÚC CHÍNH (WRAPPER, BOOK, PAGE, HOTSPOTS)
   ============================================================ */

/* Container chính */
.iaib-wrapper {
    position: relative; width: 100%; margin: 20px auto; max-width: 1000px;
    background: #f0f0f0; padding: 10px; border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    overflow: hidden; box-sizing: border-box;
    touch-action: pan-y; 
}

/* Khung Sách */
.iaib-book {
    width: 100%;
    aspect-ratio: 3 / 2; /* Tỷ lệ 2 trang */
    position: relative;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Trang Sách */
.iaib-page {
    display: none; height: 100%; flex-shrink: 0;
    background-color: #fff;
    border-right: 1px solid #eee;
    box-sizing: border-box; position: relative;
    transition: opacity 0.3s ease;
}
.iaib-page.active { display: block; animation: iaibFadeIn 0.4s ease; }
@keyframes iaibFadeIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

.iaib-page-content {
    width: 100%; height: 100%; position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}

/* Ảnh nền */
.iaib-page-bg {
    width: 100%; height: 100%;
    object-fit: fill !important;; object-position: center;
    pointer-events: none; user-select: none;
    position: absolute; top: 0; left: 0; z-index: 1;
}

/* SVG Layer */
.iaib-svg-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10; pointer-events: auto;
}

/* --- HOTSPOTS (Vùng chọn) --- */
.iaib-hotspot {
    fill: transparent; stroke: transparent; cursor: pointer;
    transition: fill 0.05s, stroke 0.05s;
    vector-effect: non-scaling-stroke;
}
.iaib-hotspot:hover {
    stroke: red; stroke-width: 2px; stroke-dasharray: 6, 4;
    fill: rgba(255, 255, 255, 0.1);
}
.iaib-hotspot.active {
    fill: rgba(255, 235, 59, 0.3) !important;
    stroke: #fdd835 !important; stroke-width: 2px;
}

/* --- TÙY CHỈNH VÙNG CHỌN DỊCH CÂU (INFO) - LOGIC MỚI --- */

/* 1. MẶC ĐỊNH: Ẩn hoàn toàn (Không chiếm chỗ, không bắt dính chuột) */
.iaib-hotspot.type-info,
.iaib-info-icon {
    display: none !important;
}

/* 2. KHI BẬT TOGGLE (.show-info): Hiện lại */

/* Hiện vùng chọn (Polygon) - Vẫn trong suốt để không che ảnh */
.iaib-page.show-info .iaib-hotspot.type-info {
    display: block !important;
    stroke: transparent;
    fill: transparent;
    pointer-events: auto; /* Bắt đầu nhận click */
    cursor: pointer;
}

/* Hover vào polygon giữ nguyên trong suốt (chỉ đổi con trỏ chuột) */
.iaib-page.show-info .iaib-hotspot.type-info:hover {
    stroke: transparent;
    fill: transparent;
}

/* Hiện Icon chữ "i" */
.iaib-page.show-info .iaib-info-icon {
    display: flex !important; /* Dùng flex để căn giữa chữ i */
    opacity: 1;
    pointer-events: auto;
    /* Hiệu ứng nhảy ra (Pop-in) cho mượt */
    animation: iaibPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- STYLE CHI TIẾT CHO ICON INFO (GIỮ NGUYÊN THÔNG SỐ CỦA BẠN) --- */
.iaib-info-icon {
    position: absolute;
    
    /* Kích thước Responsive từ code cũ của bạn */
    width: clamp(18px, 4%, 30px); 
    height: clamp(18px, 5%, 30px);
    font-size: clamp(14px, 2.5vw, 20px);
    
    border: 1.5px solid #333; 
    border-radius: 50%;
    background: #fff; 
    color: #333;
    font-weight: bold; 
    font-family: "Times New Roman", serif; 
    font-style: italic;
    
    /* Flexbox căn giữa */
    justify-content: center;
    align-items: center;
    
    cursor: pointer; 
    z-index: 20;
    
    /* Định vị tâm */
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.iaib-info-icon::before { 
    content: "i"; 
    margin-top: -1px; 
}

/* Hover Effect cho Icon khi đang hiện */
.iaib-page.show-info .iaib-info-icon:hover {
    transform: translate(-50%, -50%) scale(1.15);
    background: #2271b1; 
    color: #fff; 
    border-color: #2271b1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Animation hỗ trợ */
@keyframes iaibPopIn {
    from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Layout Modes & Footer */
.iaib-layout-double .iaib-page.active { width: 50%; border-right: 1px solid #eee; }
.iaib-layout-double .iaib-page.active:nth-of-type(even) { border-right: none; }
.iaib-layout-single .iaib-book { aspect-ratio: 4 / 3; }
.iaib-layout-single .iaib-page.active { width: 100%; border-right: none; }
.iaib-page-footer { position: absolute; bottom: 5px; width: 100%; text-align: center; font-size: 12px; color: #999; pointer-events: none; z-index: 20; }

/* Media Bar & Toolbar */
.iaib-media-container { display: flex; width: 100%; background: #f9f9f9; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; flex-shrink: 0; min-height: 50px; }
.iaib-media-bar { flex: 1; padding: 10px; display: flex; gap: 10px; align-items: center; justify-content: center; visibility: hidden; }
.iaib-bar-left { border-right: 1px solid #eee; }
.iaib-media-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid #ccc; background: #fff; color: #333; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.iaib-media-btn:hover { background: #e0e0e0; }
.iaib-audio-player { width: 100%; height: 32px;}
.iaib-layout-single .iaib-bar-right { display: none !important; }
.iaib-layout-single .iaib-bar-left { border-right: none; width: 100%; justify-content: center; }

.iaib-toolbar { background: #333; padding: 10px; display: flex; justify-content: space-between; align-items: center; color: #fff; flex-shrink: 0; width: 100%; box-sizing: border-box; }
.iaib-tool-group { display: flex; gap: 10px; align-items: center; }
.iaib-ctrl-btn { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.iaib-ctrl-btn:hover { background: rgba(255,255,255,0.3); }

/* ============================================================
   PHẦN 2: POPUP TỪ ĐIỂN, TOC & FULLSCREEN
   ============================================================ */

/* --- STYLE CHO POPUP TỪ ĐIỂN (Copy chuẩn từ HFB) --- */
.iaib-tooltip-overlay {
    display: none;
    
    /* Thay đổi quan trọng: absolute để nằm trong iaib-wrapper */
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    
    /* Nền đen mờ */
    background: rgba(0, 0, 0, 0.7); 
    
    /* Z-index cao hơn các thành phần khác trong sách (như toolbar, page) */
    z-index: 999999999999; 
    
    justify-content: center; 
    align-items: center;
    opacity: 0; 
    transition: opacity 0.3s ease;
    
    /* Bo góc theo wrapper nếu cần */
    border-radius: 8px; 
}

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

.iaib-tooltip-box {
    background: #fff;
    width: 90%; 
    max-width: fit-content;
    padding: 35px 20px 20px 20px; 
    border-radius: 12px; 
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    font-family: sans-serif; 
    text-align: left;
    
    /* Giới hạn chiều cao để không bị tràn wrapper nếu wrapper bé */
    max-height: 90%; 
    overflow-y: auto;
    min-width: 300px;
}

@media (min-width: 1280px) { 
    .iaib-tooltip-box { min-width: 600px; } 
}

/* Nút đóng tròn xoe */
.iaib-close-tooltip {
    position: absolute; top: 8px; right: 8px;
    font-size: 24px; cursor: pointer;
    color: #555; padding: 5px;
    line-height: 1; background: rgba(0,0,0,0.05);
    border-radius: 50%;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
}
.iaib-close-tooltip:hover { background: #eee; color: red; }

/* --- DICTIONARY POPUP STYLES (FINAL MATCH) --- */
#iaib-tooltip-text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    padding: 15px;
    max-width: 100%;
}

/* 1. Header Area */
.iaib-def-header {
    text-align: center;
}

.iaib-def-word {
    font-size: 32px;
    font-weight: 700;
    color: #d32f2f; /* Màu đỏ */
    line-height: 1.2;
    margin-bottom: 5px;
}

.iaib-def-ipa {
    color: #888;
    font-size: 18px;
    font-style: italic;
    font-family: "Lucida Sans Unicode", "Arial Unicode MS", sans-serif;
    margin-bottom: 8px;
}

/* 2. Meta Row (Type + Level) */
.iaib-def-meta-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.iaib-def-type {
    color: #666;
}

/* Thẻ Level (A1, B1...) giống ảnh mẫu */
.iaib-tag-level {
    display: inline-block;
    background-color: #e3f2fd; /* Nền xanh nhạt */
    color: #1976d2;            /* Chữ xanh đậm */
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 12px;
    border: 1px solid #bbdefb;
}

/* 3. Content Sections (English/Vietnamese Blocks) */
.iaib-def-section {
    background-color: #f8f9fa; /* Nền xám nhạt cho khối */
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 12px;
    border: 1px solid #eee;
    text-align: left;
}

.iaib-section-title {
    display: inline-block;
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 12px;
    border: 1px solid #bbdefb;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.iaib-section-content {
    font-size: 15px;
    line-height: 1.5;
    color: #2c3e50;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .iaib-def-word { font-size: 28px; }
    .iaib-def-ipa { font-size: 16px; }
}


/* --- TOC (MỤC LỤC) --- */
.iaib-toc-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 89; opacity: 0; visibility: hidden; transition: opacity 0.3s ease; pointer-events: none; }
.iaib-toc-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
.iaib-toc-sidebar { position: absolute; top: 0; right: 0; bottom: 0; width: 250px; background: #fff; border-left: 1px solid #eee; z-index: 90; display: flex; flex-direction: column; box-shadow: -2px 0 5px rgba(0,0,0,0.1); transform: translateX(100%); transition: transform 0.3s ease; }
.iaib-toc-open .iaib-toc-sidebar { transform: translateX(0); }
.iaib-toc-header { padding: 15px; background: #f5f5f5; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; }
.iaib-toc-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.iaib-toc-list li { padding: 10px 15px; border-bottom: 1px solid #eee; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.iaib-toc-list li:hover { background: #f9f9f9; }
.iaib-toc-num { background: #333; color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.iaib-toc-close { font-size: 18px; cursor: pointer; }

/* Utilities */
.iaib-hidden { display: none !important; }

/* --- FULLSCREEN & RESPONSIVE --- */
.iaib-wrapper:fullscreen { background: #222; padding: 0; margin: 0; max-width: none; height: 100vh; display: flex; flex-direction: column; }
.iaib-wrapper:fullscreen .iaib-book { flex: 1; background: #222; aspect-ratio: unset; }
.iaib-wrapper:fullscreen .iaib-page.active { height: 100%; }
.iaib-wrapper:fullscreen .iaib-media-container, .iaib-wrapper:fullscreen .iaib-toolbar { background: #222; border-color: #444; }
.iaib-wrapper:fullscreen .iaib-media-btn { background: #333; border-color: #555; color: #fff; }

/* Fix Object-fit khi Fullscreen (Dùng class JS thêm vào) */
.iaib-fullscreen .iaib-page-bg {
    object-fit: unset !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important; left: 0 !important;
    transform: none !important;
}

/* Ẩn nút Fullscreen trên Mobile (Dưới 768px) */
@media (max-width: 767px) {
    .iaib-btn-fullscreen { display: none !important; }
}
@media (max-width: 600px) { 
    .iaib-layout-double .iaib-book { aspect-ratio: 4 / 3; } 
}

/* Style cho Audio/Video trong Popup */
.iaib-tooltip-box video, .iaib-tooltip-box audio {
    outline: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* --- STYLE CHO VÙNG CHỌN AUDIO & VIDEO --- */

/* 1. AUDIO: Màu Đỏ */
.iaib-hotspot.type-audio {
    /*
    stroke: #ff0000;
    stroke-width: 2px;
    stroke-dasharray: 5, 3; /* Nét đứt thưa hơn chút cho dễ nhìn */ 
    fill: transparent;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
    cursor: pointer; pointer-events: auto; transition: all 0.2s;
}
.iaib-hotspot.type-audio:hover {
    stroke-width: 3px; stroke-dasharray: none;
    fill: rgba(255, 0, 0, 0.1);
}

/* 2. VIDEO: Màu Xanh Dương */
.iaib-hotspot.type-video {
    stroke: #2196f3; /* Màu xanh video */
    stroke-width: 2px;
    stroke-dasharray: 5, 3;
    fill: transparent;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
    cursor: pointer; pointer-events: auto; transition: all 0.2s;
}
.iaib-hotspot.type-video:hover {
    stroke-width: 3px; stroke-dasharray: none;
    fill: rgba(33, 150, 243, 0.1);
}

/* --- ICON AUDIO & VIDEO (MỚI) --- */
.iaib-media-icon {
    position: absolute;
    /* Dịch chuyển: 
       -50% X: để căn giữa theo chiều ngang
       +5px Y: để icon nằm cách đáy vùng chọn một chút (không dính sát) 
    */
    transform: translate(-50%, 5px); 
    
    width: 24px; 
    height: 24px;
    
    display: flex; 
    align-items: center; 
    justify-content: center;
    
    border-radius: 50%;
    color: #fff;
    
    cursor: pointer; 
    z-index: 20;
    
    /* Hiệu ứng mờ (Opacity) */
    opacity: 0.6; 
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.iaib-media-icon svg {
    width: 16px; 
    height: 16px; 
    display: block;
}

/* Màu sắc riêng */
.iaib-media-icon.icon-audio {
    background-color: #ff0000; /* Đỏ */
    border: 1px solid rgba(255,255,255,0.5);
}

.iaib-media-icon.icon-video {
    background-color: #2196f3; /* Xanh */
    border: 1px solid rgba(255,255,255,0.5);
}

/* Hover Effect: Hiện rõ, phóng to nhẹ */
.iaib-media-icon:hover {
    opacity: 1;
    transform: translate(-50%, 5px) scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    z-index: 25;
}

/* Hiệu ứng khi hover vào vùng chọn (Polygon) thì cũng làm sáng icon lên */
.iaib-page:hover .iaib-media-icon {
    /* Tùy chọn: Nếu muốn icon luôn sáng khi chuột vào trang sách thì bỏ comment dòng này */
    /* opacity: 0.9; */
}

/* --- STYLE RIÊNG CHO TỪ VỰNG (WORD) KHI HOVER --- */
.iaib-hotspot.type-word:hover {
    fill: rgba(255, 235, 59, 0.3) !important; /* Màu vàng nền trong suốt */
    stroke: #fdd835 !important;               /* Viền vàng đậm */
    stroke-width: 2px !important;
    
    /* Thêm chút bóng đổ cho viền nổi bật hơn */
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.2));
}

/* --- ICON IMAGE & HTML --- */
.iaib-media-icon.icon-image {
    background-color: #ff9800; /* Màu Cam */
    border: 1px solid rgba(255,255,255,0.5);
}
.iaib-media-icon.icon-html {
    background-color: #9c27b0; /* Màu Tím */
    border: 1px solid rgba(255,255,255,0.5);
}

/* Style cho vùng chọn Image & HTML */
.iaib-hotspot.type-image {
    stroke: #ff9800; stroke-width: 2px; stroke-dasharray: 5, 3; fill: transparent;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
    cursor: pointer; pointer-events: auto; transition: all 0.2s;
}
.iaib-hotspot.type-image:hover { stroke-width: 3px; stroke-dasharray: none; fill: rgba(255, 152, 0, 0.1); }

.iaib-hotspot.type-html {
    stroke: #9c27b0; stroke-width: 2px; stroke-dasharray: 5, 3; fill: transparent;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
    cursor: pointer; pointer-events: auto; transition: all 0.2s;
}
.iaib-hotspot.type-html:hover { stroke-width: 3px; stroke-dasharray: none; fill: rgba(156, 39, 176, 0.1); }

/* --- CHẾ ĐỘ HIỂN THỊ (DISPLAY MODE) --- */

/* 1. Chế độ "Chỉ Icon": Ẩn hoàn toàn Polygon */
/* Dùng display: none để chuột rê qua không bị dính sự kiện click hay hover */
.iaib-hotspot.hide-area {
    display: none !important; 
}

/* 2. Chế độ "Chỉ Vùng chọn": Icon sẽ không được sinh ra từ PHP, 
   nhưng nếu muốn chắc chắn, ta thêm CSS ẩn icon nếu có lỡ sinh ra */
.iaib-hide-icon {
    display: none !important;
}

/* --- STYLE CHO IMAGE TEXT (VÙNG CHỌN) --- */
.iaib-hotspot.type-imgtext {
    stroke: transparent;
    fill: transparent;
    cursor: pointer; 
    pointer-events: auto;
    transition: all 0.2s;
}

/* [MỚI] Class kích hoạt khi Click (Do JS thêm vào) */
.iaib-hotspot.type-imgtext.active-border {
    stroke: #2196f3 !important;    /* Viền xanh */
    stroke-width: 2px !important;
    stroke-dasharray: 6, 4 !important; /* Nét đứt */
    fill: transparent !important;   /* [Quan trọng] Không hiện nền */
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
}

/* --- STYLE CHO TEXT LABEL (IMAGE TEXT) --- */
.iaib-imgtext-label {
    position: absolute;
    /* Mặc định ở giữa, transform sẽ đè sau */
    transform: translate(-50%, -50%);
    
    background: #2196f3;
    color: #fff;
    font-weight: bold;
    font-family: "Comic Sans MS", "Chalkboard SE", sans-serif;
    font-size: clamp(12px, 2vw, 20px); /* Tăng size tối thiểu lên một chút cho dễ đọc */
    padding: 8px 15px; /* Tăng padding để chữ thoáng hơn */
    
    border-radius: 50px;
    border: 2px solid #fff;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    
    text-align: center;
    
    /* [QUAN TRỌNG] FIX LỖI TRÀN CHỮ */
    width: max-content!important;      /* Buộc khung bao vừa khít nội dung */
    max-width: 90vw!important;         /* Giới hạn không quá 90% màn hình để không bị mất chữ trên điện thoại */
    white-space: nowrap!important;     /* Giữ chữ trên 1 dòng cho đẹp (dạng viên thuốc) */
    
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Khi Active (Hiện lên) */
.iaib-imgtext-label.active {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
    z-index: 110 !important;
    
    /* [CẬP NHẬT] Nếu chữ quá dài vượt quá max-width thì mới cho xuống dòng */
    white-space: normal; 
    line-height: 1.3;
}

/* --- TÙY CHỈNH RIÊNG CHO MOBILE (Dưới 600px) --- */
@media (max-width: 600px) {
    .iaib-imgtext-label {
        /* Giảm độ dày viền và bóng đổ trên mobile cho thanh thoát */
        border-width: 1.5px;
        box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
        
        /* Nếu text dài quá thì cho xuống dòng để không bè ra che hết hình */
        white-space: normal; 
        line-height: 1.2;
        min-width: 30px; /* Đảm bảo không bé quá mức */
    }
}

/* --- IMAGE TEXT ZOOM EFFECT --- */

.iaib-zoom-clone {
    position: absolute;
    z-index: 99; /* Cao hơn ảnh nền, nhưng thấp hơn Text Label (105) */
    
    background-repeat: no-repeat;
    background-color: #fff; /* Nền trắng phòng khi ảnh PNG trong suốt */
    
    /* Hiệu ứng viền sáng lên */
    border: 2px solid #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-radius: 4px;

    /* Animation phóng to mượt mà (kiểu lò xo nhẹ) */
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    
    transform-origin: center center;
    transform: scale(1); /* Mặc định */
    pointer-events: none; /* Để chuột xuyên qua, không che nút khác */
}

/* Khi kích hoạt thì phóng to 1.5 lần */
.iaib-zoom-clone.zoomed {
    transform: scale(1.5);
    z-index: 100 !important; /* Thấp hơn text (110) để text đè lên */
}

/* --- BORDER IMAGE TEXT STYLE --- */
.iaib-hotspot.active-border {
    stroke: red !important; /* Màu đỏ */
    stroke-width: 3px !important;
    stroke-dasharray: 8, 4 !important; /* Nét đứt thưa */
    fill: rgba(255, 255, 255, 0.1) !important; /* Nền trắng mờ cực nhẹ */
    filter: drop-shadow(0 0 3px rgba(255,255,255,0.8));
    transition: all 0.3s ease;
    /* Animation nhấp nháy */
    animation: iaibBorderPulse 1s infinite alternate;
}

@keyframes iaibBorderPulse {
    from { stroke-opacity: 1; stroke-width: 3px; }
    to { stroke-opacity: 0.5; stroke-width: 2px; }
}

.iaib-text-line {
    margin-bottom: 5px;
    color: #d32f2f;
    font-size: 1.1em;
    font-weight: bold;
}

.iaib-ipa-line, .iaib-meaning-line {
    margin-bottom: 3px;
}

#iaib-tooltip-content {
    text-align: center;
    margin-top: 14px;
}

.iaib-text-line sub {font-size: 13px;}

/* --- TÙY CHỈNH VÙNG CHỌN DỊCH CÂU (INFO) - LOGIC MỚI --- */

/* 1. MẶC ĐỊNH: Ẩn hoàn toàn */
.iaib-hotspot.type-info,
.iaib-info-icon {
    display: none !important;
}

/* 2. [THAY ĐỔI] GLOBAL TOGGLE: Hiện trên TOÀN BỘ Wrapper thay vì từng page */
.iaib-wrapper.iaib-show-global-info .iaib-hotspot.type-info {
    display: block !important;
    stroke: transparent;
    fill: transparent;
    pointer-events: auto;
    cursor: pointer;
}

.iaib-wrapper.iaib-show-global-info .iaib-info-icon {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    animation: iaibPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- Style Nút Active trong Toolbar --- */
.iaib-ctrl-btn.active {
    background-color: #2271b1; /* Màu xanh Active */
    color: #fff;
    border-color: #2271b1;
    box-shadow: 0 0 5px rgba(33, 113, 177, 0.5);
}

/* --- STYLE CHO KHUNG TEXT TTS & SCORING (AI) --- */

/* Container chứa cả sao và text kết quả */
.iaib-tts-container {
    display: flex;
    align-items: center;
    gap: 8px; /* Khoảng cách giữa sao và text */
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Khung hiển thị text (kết quả nhận diện) */
.iaib-tts-text {
    flex: 1; /* Chiếm hết khoảng trống còn lại */
    height: 32px; /* Cao bằng audio player chuẩn */
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    
    display: flex;
    align-items: center;
    padding: 0 10px;
    
    font-size: 13px;
    color: #333;
    font-weight: 500;
    
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Cắt chữ thêm dấu ... nếu dài */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

/* Hàng ngôi sao */
.iaib-tts-stars {
    display: flex;
    gap: 1px;
    flex-shrink: 0; /* Không bị co lại */
}

/* Ngôi sao đơn lẻ */
.iaib-star {
    font-size: 18px;
    line-height: 1;
    color: #e0e0e0; /* Màu xám khi chưa đạt */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Ngôi sao khi đạt (Active) */
.iaib-star.active {
    color: #ffc107; /* Màu vàng */
    transform: scale(1.2); /* Phóng to nhẹ */
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Hiệu ứng nút Micro đang ghi âm (Nhấp nháy đỏ) */
.iaib-btn-tts.recording {
    background-color: #d63638 !important; /* Màu đỏ */
    border-color: #d63638 !important;
    color: #fff !important;
    animation: iaibPulseRed 1.5s infinite;
}

@keyframes iaibPulseRed {
    0% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(214, 54, 56, 0); }
    100% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0); }
}

/* Trạng thái đang xử lý (Loading) */
.iaib-tts-text.processing {
    color: #2271b1;
    font-style: italic;
    background-color: #f0f6fc;
}

/* Nút Audio Active (Khi đang ở chế độ Nghe) */
.iaib-btn-audio.active {
    background-color: #2271b1 !important;
    color: #fff !important;
    border-color: #2271b1 !important;
}

/* --- STYLE CHO TOGGLE IMGTEXT (HIỆN VÙNG CHỌN ẢNH) --- */

/* Khi wrapper có class này, hiện viền cho imgtext và bordertext */
.iaib-wrapper.iaib-show-imgtext .iaib-hotspot.type-imgtext,
.iaib-wrapper.iaib-show-imgtext .iaib-hotspot.type-bordertext {
    stroke: red !important; /* Màu cam nổi bật */
    stroke-width: 2px !important;
    stroke-dasharray: 6, 4; /* Nét đứt */
    fill: rgba(255, 152, 0, 0.1) !important; /* Nền mờ nhẹ */
    transition: all 0.3s ease;
    display: block !important;
}

/* --- TEXT SYNC (KARAOKE) --- */
.iaib-text-sync-box {
    position: absolute;
    z-index: 15;
    background-color: #fff; 
    /*border: 1px solid rgba(0,0,0,0.1); 
    border-radius: 4px;*/
    padding: 6px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    
    /* [QUAN TRỌNG] Flexbox để căn giữa cái DIV con */
    display: flex !important;
    align-items: center; /* Căn giữa dọc */
    justify-content: flex-start; /* Căn trái ngang */
    flex-direction: column !important;
    
    overflow-y: auto; 
    overflow-x: hidden;
    
    font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", sans-serif;
    color: #000 !important; 
    text-align: left; 
    line-height: 1.3 !important;
}

/* [MỚI] Style cho wrapper bên trong để kích hoạt lại sự kiện chuột cho từ vựng */
.iaib-text-sync-box .iaib-text-wrapper {
    pointer-events: auto !important; /* Kích hoạt lại click cho các từ bên trong */
}

/* [MỚI] Đảm bảo các từ hiển thị đúng dòng */
.iaib-word {
    display: inline-block; /* Hoặc inline */
    white-space: normal;   /* Cho phép xuống dòng */
}

/* Nếu nội dung dài quá, hover vào mới hiện thanh cuộn (Option) */
.iaib-text-sync-box:hover {
    overflow-y: auto;
    /*box-shadow: 0 2px 5px rgba(0,0,0,0.1);*/
}
/* Scrollbar mảnh */
.iaib-text-sync-box::-webkit-scrollbar { width: 4px; }
.iaib-text-sync-box::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Từ đơn */
.iaib-word {
    cursor: pointer;
    padding: 0 2px;
    border-radius: 3px;
    transition: all 0.1s ease;
    display: inline !important;
    white-space: normal !important;
    font-weight: bold;
}
.iaib-word:hover { background-color: #e3f2fd; color: #1976d2; }

/* Hiệu ứng khi đọc đến */
.iaib-word.active {
    color: #d32f2f;       /* Đỏ */
    background-color: #fff9c4; /* Vàng nhạt */
    font-weight: 700;
    transform: scale(1.05);
}

/* --- QUIZ BOX (EQP INTEGRATION) --- */
.iaib-quiz-box {
    position: absolute;
    z-index: 20; /* Cao nhất */
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px;
    
    /* Responsive & Scroll */
    overflow-y: auto;
    overflow-x: auto;
    
    /* Đảm bảo nội dung Quiz bên trong không bị vỡ */
    display: flex;
    flex-direction: column;
}

/* Tùy chỉnh thanh cuộn cho đẹp */
.iaib-quiz-box::-webkit-scrollbar { width: 6px; }
.iaib-quiz-box::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }

/* --- QUIZ BOX RESPONSIVE & FULLSCREEN --- */

/* Nút phóng to/thu nhỏ - FIX HIỂN THỊ */
.iaib-quiz-toggle-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 36px; /* To hơn chút cho dễ bấm */
    height: 36px;
    background: #2271b1;
    color: #fff;
    border: 2px solid #fff; /* Thêm viền trắng cho nổi bật */
    border-radius: 50%; /* Tròn xoe */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    
    /* [QUAN TRỌNG] Chỉ số cao nhất để luôn nổi lên trên cùng */
    z-index: 2147483647 !important; 
}

.iaib-quiz-toggle-btn:hover {
    background: #135e96;
    transform: scale(1.1);
}

.iaib-quiz-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Chế độ Toàn màn hình */
.iaib-quiz-box.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    
    /* Z-index cực cao để che hết mọi thứ khác */
    z-index: 20 !important; 
    
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    transform: none !important;
    background: #fff;
    padding: 20px 10px; /* Thêm padding */
    box-sizing: border-box;
}

/* Ẩn thanh cuộn web khi đang mở Quiz Fullscreen */
body.iaib-quiz-open {
    overflow: hidden !important;
}

/* 2. Sợi dây (LeaderLine SVG): Ép hiển thị rõ */
.eqp-ldl-line-layer > svg.leader-line {
    z-index: 21 !important; /* Cùng tầng với khung chứa */
    /*position: absolute !important;
    overflow: visible !important;*/
    opacity: 1 !important;
    display: block !important;
}

.iaib-quiz-box .eqp-question {
    /* Tạo ngữ cảnh xếp chồng riêng */
    position: relative !important;
    z-index: 1 !important;
    
    /* [QUAN TRỌNG] Cắt cụt mọi thứ lòi ra khỏi khung câu hỏi (dây, ảnh,...) */
    overflow: hidden !important;
    
    /* Đảm bảo nền trắng */
    background: #fff;
    border-radius: 4px;
    padding: 10px; /* Thêm chút khoảng cách cho đẹp */
}

/* --- ICON YOUTUBE --- */
.iaib-media-icon.icon-youtube {
    background-color: #FF0000; /* Màu đỏ YouTube chuẩn */
    border: 1px solid rgba(255,255,255,0.8);
}

/* Style cho vùng chọn (Polygon) YouTube */
.iaib-hotspot.type-youtube {
    stroke: #FF0000; 
    stroke-width: 2px; 
    stroke-dasharray: 5, 3; 
    fill: transparent;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
    cursor: pointer; pointer-events: auto; transition: all 0.2s;
}
.iaib-hotspot.type-youtube:hover { 
    stroke-width: 3px; 
    stroke-dasharray: none; 
    fill: rgba(255, 0, 0, 0.1); 
}

/* --- POPUP RELOAD (Dành cho Mobile khi chuyển Mic -> Audio) --- */
.iaib-reload-overlay {
    display: none; /* Mặc định ẩn */
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2147483647; /* Cao nhất có thể */
    align-items: center; justify-content: center;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
    color: #fff;
    backdrop-filter: blur(2px);
}

.iaib-reload-overlay.active {
    display: flex !important;
    animation: iaibFadeIn 0.3s ease;
}

.iaib-reload-box {
    background: #fff;
    color: #333;
    max-width: 320px;
    width: 90%;
    padding: 25px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.iaib-reload-title {
    font-size: 18px; font-weight: bold; margin-bottom: 10px; color: #d63638;
}

.iaib-reload-msg {
    font-size: 14px; margin-bottom: 20px; line-height: 1.5; color: #555;
}

.iaib-reload-actions {
    display: flex; gap: 10px; justify-content: center;
}

.iaib-btn-reload-confirm {
    background: #2271b1; color: #fff; border: none; padding: 10px 20px;
    border-radius: 4px; font-weight: bold; cursor: pointer;
}
.iaib-btn-reload-cancel {
    background: #f0f0f1; color: #333; border: 1px solid #ccc; padding: 10px 15px;
    border-radius: 4px; cursor: pointer;
}

/* --- POPUP THÔNG BÁO CHUNG (Thay thế Alert) --- */
.iaib-msg-overlay {
    display: none;
    position: absolute; /* Quan trọng: nằm trong wrapper để hiện đè lên Fullscreen */
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2147483647;
    align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box;
    backdrop-filter: blur(2px);
}
.iaib-msg-overlay.active { display: flex !important; animation: iaibFadeIn 0.3s ease; }
.iaib-msg-box {
    background: #fff; color: #333;
    max-width: 400px; width: 100%;
    padding: 20px; border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
}
.iaib-msg-title { font-size: 18px; font-weight: bold; margin-bottom: 10px; color: #d63638; }
.iaib-msg-content { font-size: 15px; margin-bottom: 20px; line-height: 1.5; }
.iaib-msg-btn {
    background: #2271b1; color: #fff; border: none; padding: 10px 25px;
    border-radius: 4px; font-weight: bold; cursor: pointer;
}

/* Nút xem lại Transcript (cái tai nghe nhỏ) */
.iaib-btn-show-transcript {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 5px;
    margin-left: 5px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.iaib-btn-show-transcript:hover {
    color: #2271b1;
    transform: scale(1.1);
}
.iaib-btn-show-transcript svg {
    width: 16px; 
    height: 16px;
}

/* --- SHOW HTML DIRECT (RESPONSIVE CONTENT) --- */
.iaib-html-direct-box {
    position: absolute;
    z-index: 15;
    overflow: hidden;
    
    /* [QUAN TRỌNG] Flexbox để căn giữa Text/Audio */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    
    /* Màu chữ mặc định */
    color: #333;
    line-height: 1.3;
}

/* 1. Video/Iframe: Dùng CONTAIN để nhìn thấy thanh điều khiển (controls) */
.iaib-html-direct-box video,
.iaib-html-direct-box iframe,
.iaib-html-direct-box embed,
.iaib-html-direct-box object {
    width: 100% !important;
    height: 100% !important;
    
    /* [FIX LỖI VIDEO] Đổi cover -> contain để không bị mất nút Play/Pause */
    object-fit: contain !important; 
    
    border: none;
    display: block;
    background: #000; /* Nền đen cho video nhìn chuyên nghiệp hơn */
}

/* 2. Ảnh thường: Vẫn giữ cover để đẹp (TRỪ Emoji) */
.iaib-html-direct-box img:not(.emoji) {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain; 
    display: block;
}

/* --- STYLE CHO THANH AUDIO GỐC --- */
.iaib-html-direct-box audio {
    /* [QUAN TRỌNG] Bắt buộc hiện lại (xóa display: none cũ nếu có) */
    display: block !important;
    
    /* Chiều cao chuẩn dễ bấm */
    height: 40px !important;
    
    /* 1. Trên PC: Có thể để 100% để co giãn theo ô vẽ (nếu ô to) */
    width: 100% !important;
    
    /* 2. [FIX MOBILE/TABLET] Đặt độ rộng tối thiểu cố định 
       Giúp thanh player KHÔNG bao giờ bị co nhỏ dưới 250px 
       (Dù bạn vẽ ô bé xíu, player vẫn to 250px để bấm được nút Play/Tua) */
    min-width: 250px !important;
    
    /* Style cho đẹp */
    border-radius: 30px;
    
    /* Xóa bỏ mọi transform scale cũ nếu có */
    transform: none !important;
}

/* 4. Text: Reset margin để tính toán JS chuẩn hơn */
.iaib-html-direct-box p, 
.iaib-html-direct-box h1, 
.iaib-html-direct-box h2, 
.iaib-html-direct-box h3, 
.iaib-html-direct-box span, 
.iaib-html-direct-box div {
    margin: 0;
    padding: 0;
    max-width: 100%;
    word-wrap: break-word;
}

/* Emoji giữ nguyên size nhỏ */
.iaib-html-direct-box img.emoji {
    display: inline !important;
    border: none !important;
    box-shadow: none !important;
    height: 1em !important;
    width: 1em !important;
    margin: 0 0.07em !important;
    vertical-align: -0.1em !important;
    background: none !important;
    padding: 0 !important;
}

/* --- STYLE CHO ICON GO TO PAGE (ĐỒNG BỘ VỚI AUDIO) --- */

/* 1. Định nghĩa màu sắc riêng (Màu xanh dương đậm) */
/* Các thuộc tính khác (tròn, bóng đổ, hover phóng to) sẽ tự ăn theo class .iaib-media-icon */
.iaib-media-icon.icon-gotopage {
    background-color: #0073aa; 
    border: 1px solid rgba(255,255,255,0.5);
    color: #fff;
}

/* 2. Style cho Container chứa */
.iaib-gotopage-container {
    cursor: pointer;
    /* Đảm bảo container không bị ẩn click */
    pointer-events: auto; 
}

/* 3. Hiệu ứng Hover vào vùng chọn (Box) */
.iaib-gotopage-hitarea {
    background-color: transparent;
    border: 2px solid transparent; 
    transition: all 0.2s ease;
}

/* Khi di chuột vào container (bao gồm cả box và icon) -> Box hiện viền đỏ */
.iaib-gotopage-container:hover .iaib-gotopage-hitarea {
    border-color: #ff0000;
    background-color: rgba(255, 0, 0, 0.1);
}

/* --- CẤU HÌNH GIAO DIỆN MEDIA BAR (FIX 2 TRANG) --- */

/* Mặc định: Thanh TTS chung ẩn */
.iaib-tts-shared {
    display: none;
    width: 100%;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* Style cho text bên trong thanh chung (giống cũ) */
.iaib-tts-shared .iaib-tts-text {
    width: 100%;
    max-width: 500px; /* Giới hạn chiều rộng cho đẹp */
    justify-content: center;
}

/* --- KHI KÍCH HOẠT CHẾ ĐỘ TTS (.mode-tts) --- */

/* 1. Ẩn 2 thanh Audio trái/phải */
.iaib-media-container.mode-tts .iaib-bar-left,
.iaib-media-container.mode-tts .iaib-bar-right {
    display: none !important;
}

/* 2. Hiện thanh TTS chung */
.iaib-media-container.mode-tts .iaib-tts-shared {
    display: flex !important;
}

/* --- TÙY CHỈNH THANH SCROLL CHO TEXT BOX --- */

/* 1. Cấu hình chung và Firefox */
.iaib-text-sync-box {
    /* Đảm bảo nội dung dài sẽ hiện scroll */
    overflow-y: auto !important; 
    scrollbar-width: none !important; 
}

/* 2. Cấu hình cho Chrome, Edge, Safari (Webkit) */

/* Định nghĩa độ rộng của thanh cuộn */
.iaib-text-sync-box::-webkit-scrollbar {
    width: 14px; /* Độ rộng: 14px là khá to, dễ cầm nắm */
    height: 14px; /* Độ cao (nếu cuộn ngang) */
    display: block; /* Bắt buộc hiển thị */
}

/* Định nghĩa phần nền (Track) - rãnh trượt */
.iaib-text-sync-box::-webkit-scrollbar-track {
    background: #f1f1f1; /* Màu xám nhạt */
    border-radius: 0;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1); /* Đổ bóng nhẹ cho có chiều sâu */
}

/* Định nghĩa phần tay cầm (Thumb) - cục để kéo */
.iaib-text-sync-box::-webkit-scrollbar-thumb {
    background: #888; /* Màu xám đậm dễ nhìn */
    border-radius: 10px; /* Bo tròn 2 đầu cho đẹp */
    border: 3px solid #f1f1f1; /* Tạo viền trắng xung quanh để thanh cuộn trông thanh thoát hơn */
}

/* Hiệu ứng khi di chuột vào tay cầm */
.iaib-text-sync-box::-webkit-scrollbar-thumb:hover {
    background: #555; /* Đổi màu đậm hơn khi hover */
    cursor: pointer;
}

/* [Tùy chọn] Luôn hiện thanh cuộn trên Mobile (iOS/Android) 
   Lưu ý: Một số trình duyệt mobile hiện đại có thể bỏ qua cái này để tối ưu diện tích */
.iaib-text-sync-box::-webkit-scrollbar {
    -webkit-appearance: none;
}

/* --- STYLE CHUNG CHO NÚT GẠT (SWITCH iOS) --- */
.iaib-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.iaib-switch-label {
    font-size: 11px;
    font-weight: 800;
    color: #555;
    text-transform: uppercase;
}
.iaib-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.iaib-switch input { opacity: 0; width: 0; height: 0; }
.iaib-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.iaib-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.iaib-switch input:checked + .iaib-slider { background-color: #2196F3; }
.iaib-switch input:checked + .iaib-slider:before { transform: translateX(16px); }

/* --- ACTIVE ZOOM EFFECT --- */
.iaib-text-sync-box {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}
.iaib-text-sync-box.active-box {
    height: auto !important;
    font-size: 14px !important;
    transform: scale(1.3);
    z-index: 100 !important;
    background-color: #fff !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    border: 1px solid #2196F3 !important;
    padding: 10px !important;
    border-radius: 8px;
    min-width: min-content;
}
/* Zoom lớn hơn trên mobile */
@media (max-width: 767px) {
    .iaib-text-sync-box.active-box {
        /* 1. Reset scale về 1 vì ta sẽ chỉnh width/height thủ công */
        transform: translate(0, -50%) !important; 
        
        /* 2. Căn giữa màn hình tuyệt đối */
        position: fixed !important;
        left: 5% !important;
        top: 50% !important; /* Kết hợp với translate -50% ở trên để căn giữa dọc */
        
        /* 3. Kích thước to rõ */
        width: 90% !important;
        height: auto !important;
        max-height: 60vh !important; /* Không chiếm quá 60% chiều cao màn hình */
        
        /* 4. FONT CHỮ TO (Sửa lỗi chữ nhỏ) */
        font-size: 20px !important; 
        line-height: 1.5 !important;
        text-align: center !important; /* Canh giữa đọc cho sướng */
        
        /* 5. Cho phép cuộn nếu chữ quá dài */
        overflow-y: auto !important; 
        box-shadow: 0 0 0 1000px rgba(0,0,0,0.5) !important; /* Làm tối nền xung quanh để tập trung */
        padding-bottom: 30px !important;
        justify-content: flex-start!important;
    }
}

/* --- RESPONSIVE LOGIC --- */

/* Mặc định (Desktop): Ẩn thanh mobile control */
.iaib-mobile-controls { display: none; }

/* TRÊN MOBILE (< 768px) */
@media (max-width: 767px) {
    /* 1. Ẩn nút trái/phải trên Toolbar chính */
    .iaib-desktop-only { display: none !important; }
    
    /* 3. Hiện thanh điều khiển mobile */
    .iaib-mobile-controls {
        display: flex;
        align-items: center;
        background: #f9f9f9;
        border-top: 1px solid #eee;
        padding: 10px 0;
        margin-top: -5px; /* Dính liền với toolbar trên */
    }
    
    /* Chia đôi 50% */
    .iaib-mobile-btn-half {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    /* Vạch ngăn cách mờ ở giữa */
    .iaib-mobile-divider {
        width: 1px;
        height: 20px;
        background: #ddd;
    }
}

/* --- ẨN THANH SCROLL CHO TEXT BOX --- */

/* Ẩn thanh cuộn cho Firefox */
.iaib-text-sync-box.active-box {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important; /* IE 10+ */
}

/* Ẩn thanh cuộn cho Chrome, Safari, Opera */
.iaib-text-sync-box.active-box::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* 2. Trạng thái FULLSCREEN */
/* Khi wrapper có class .iaib-fullscreen thì font chữ to hơn */
.iaib-fullscreen .iaib-text-sync-box.active-box {
    font-size: 22px !important;
    line-height: 1.6 !important;
}

/* --- FIX ÉP MÀU TRẮNG CHO CHẾ ĐỘ NỀN ĐEN MỜ --- */
/* Đảm bảo chữ mặc định luôn là trắng trên nền đen mờ */
.iaib-text-sync-box.iaib-dark-bg-active,
.iaib-text-sync-box.iaib-dark-bg-active * {
    color: #ffffff !important;
}

/* --- [MỚI] TĂNG CƯỜNG TƯƠNG PHẢN KHI HOVER HOẶC KHI AUDIO ĐANG ĐỌC --- */
/* Áp dụng cho cả rê chuột (:hover) VÀ khi text chạy theo nhạc (.active) */
.iaib-text-sync-box.iaib-dark-bg-active .iaib-word:hover,
.iaib-text-sync-box.iaib-dark-bg-active .iaib-word.active {
    background-color: #ffffff !important; /* Ép nền trắng cho từ đang đọc/hover */
    color: #000000 !important;           /* Ép màu chữ đen cho từ */
    border-radius: 3px;                  /* Bo góc nhẹ highlight cho mềm mại */
    cursor: pointer;
}