:root {
    --primary: #FF6B6B;
    --secondary: #4ECDC4;
    --yellow: #FFE66D;
    --dark: #2F3542;
    --light: #F7F1E3;
    --radius: 20px;
}

body {
    margin: 0; padding: 20px;
    font-family: 'Comic Sans MS', 'Varela Round', sans-serif;
    background-color: #f0f8ff;
    background-image: radial-gradient(#dfe6e9 1px, transparent 1px);
    background-size: 20px 20px;
}

.main-wrapper { max-width: 600px; margin: 0 auto; }

/* HEADER & TOGGLE */
.header-section { text-align: center; margin-bottom: 20px; }
h1 { color: var(--primary); font-size: 2rem; text-shadow: 2px 2px 0px #fff; margin-bottom: 10px; }

.ai-toggle-wrapper {
    display: flex; justify-content: center; align-items: center; gap: 10px;
    background: #fff; padding: 10px 20px; border-radius: 30px;
    display: inline-flex; margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.toggle-label { font-weight: bold; color: var(--dark); font-size: 0.9rem; }

/* SWITCH CSS */
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--secondary); }
input:checked + .slider:before { transform: translateX(24px); }

/* SEARCH & SUGGESTIONS */
.search-container { position: relative; }
.search-box { display: flex; gap: 10px; }
input[type="text"] {
    flex: 1; padding: 15px; border-radius: 50px; border: 3px solid var(--secondary);
    font-size: 1.2rem; outline: none; font-weight: bold; color: var(--dark);
}
button#btn-search {
    width: 60px; border-radius: 50%; border: none; background: var(--primary);
    color: white; font-size: 1.5rem; cursor: pointer; box-shadow: 0 5px 0 #c0392b;
    transition: transform 0.1s;
}
button#btn-search:active { transform: translateY(4px); box-shadow: none; }

.suggestion-list {
    position: absolute; top: 110%; left: 10px; right: 10px;
    background: white; border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    z-index: 100; overflow: hidden; max-height: 200px; overflow-y: auto;
}
.suggestion-item {
    padding: 12px 20px; cursor: pointer; border-bottom: 1px solid #eee;
    font-size: 1.1rem; text-align: left; display: flex; justify-content: space-between;
}
.suggestion-item:hover { background-color: #f1f2f6; color: var(--primary); }
.suggestion-item span.hint { font-size: 0.8rem; color: #aaa; }

/* MEDIA */
.media-window {
    width: 100%; aspect-ratio: 1; background: #000; border-radius: var(--radius);
    overflow: hidden; border: 4px solid white; box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    position: relative; margin-bottom: 15px;
}
.media-window video, .media-window img { width: 100%; height: 100%; object-fit: contain; }
.click-shield { position: absolute; inset: 0; z-index: 10; }

/* INFO CARD & AUDIO BUTTONS */
.info-card { background: white; padding: 20px; border-radius: var(--radius); text-align: center; }

.word-row {
    display: flex; justify-content: center; align-items: center; gap: 15px;
}
.word-display { font-size: 3rem; font-weight: 800; color: var(--dark); text-transform: capitalize; }

/* --- 1. CHỈNH SỬA NÚT LOA CHÍNH (TO) --- */
.btn-audio {
    /* Kích thước */
    width: 60px; /* Tăng nhẹ lên cho cân đối */
    height: 60px;
    border-radius: 50%;
    
    /* Màu sắc */
    background: var(--yellow);
    color: #d35400;
    border: none;
    box-shadow: 0 4px 0 #e67e22;
    
    /* CĂN GIỮA TUYỆT ĐỐI (FIX LỆCH ICON) */
    display: flex;             /* Bắt buộc dùng flex */
    justify-content: center;   /* Căn giữa ngang */
    align-items: center;       /* Căn giữa dọc */
    padding: 0;                /* Xóa padding mặc định của browser mobile */
    
    /* Font & Effect */
    font-size: 1.8rem;
    cursor: pointer;
    transition: 0.1s;
    flex-shrink: 0; /* Không bị méo khi màn hình nhỏ */
}

.btn-audio:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* --- 2. CHỈNH SỬA NÚT LOA NHỎ (CÂU VÍ DỤ) --- */
.btn-audio-mini {
    /* Tăng kích thước để bé dễ bấm hơn (Chuẩn tối thiểu 44px của Apple) */
    width: 45px; 
    height: 45px; 
    
    /* Giao diện */
    background: white; 
    border: 2px solid #eee;
    border-radius: 50%;
    color: var(--secondary);
    
    /* CĂN GIỮA TUYỆT ĐỐI */
    display: inline-flex;      /* Dùng inline-flex để nằm cùng dòng với chữ */
    justify-content: center;
    align-items: center;
    padding: 0;
    
    /* Spacing */
    margin-left: 10px;
    font-size: 1.2rem; /* Icon to hơn xíu */
    cursor: pointer;
    flex-shrink: 0; /* Quan trọng: Giữ nút tròn vo, không bị bẹp khi câu dài */
}

.btn-audio-mini:hover, 
.btn-audio-mini:active {
    background: var(--secondary); 
    color: white;
    border-color: var(--secondary);
    transform: scale(1.1); /* Hiệu ứng phóng to nhẹ khi bấm */
}

.phonics-badge { font-style: italic; color: #888; margin-bottom: 15px; font-weight: bold; }

/* SENTENCE BOXES */
.sentence-box {
    background: #f8f9fa; border-radius: 15px; padding: 15px; margin-top: 15px; text-align: left;
    border-left: 5px solid #ccc;
}
.sentence-box.book-style { border-color: var(--secondary); background: #e0f7fa; }
.sentence-box.ai-style { border-color: var(--primary); background: #fff0f3; }

.box-header { font-size: 0.85rem; font-weight: bold; text-transform: uppercase; margin-bottom: 8px; opacity: 0.7; }
.line-item { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.text-en { font-size: 1.3rem; font-weight: 600; color: var(--dark); }
.text-vi { font-size: 1.1rem; color: #636e72; font-style: italic; }

/* RELATED WORDS CHIPS */
.divider { text-align: center; margin: 25px 0 15px; color: #b2bec3; font-weight: bold; letter-spacing: 1px; }
.chips-container { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.chip {
    background: white; padding: 8px 15px; border-radius: 25px; border: 2px solid var(--secondary);
    font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 8px;
    transition: 0.2s;
}
.chip:hover { transform: scale(1.1); background: var(--secondary); color: white; }
.chip .emoji { font-size: 1.2rem; }

/* EMPTY STATE */
#empty-state { text-align: center; margin-top: 40px; opacity: 0.6; }
.mascot { font-size: 5rem; animation: float 3s infinite ease-in-out; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}


/* Nút Dịch */
.btn-translate {
    background: #FF9F43; color: white; border: none; padding: 5px 15px;
    border-radius: 15px; cursor: pointer; font-weight: bold; margin-left: auto;
    display: flex; align-items: center; gap: 5px; box-shadow: 0 3px 0 #e67e22;
}
.btn-translate:active { transform: translateY(3px); box-shadow: none; }

/* Khu vực kết quả dịch */
.translation-result {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; padding: 10px; margin-top: 10px; border-radius: 10px;
    border: 1px dashed #FF9F43;
}
.translation-result span { color: #d35400; font-weight: bold; font-style: italic; }

/* Unit Badge */
.unit-badge {
    background: #54a0ff; color: white; display: inline-block;
    padding: 5px 15px; border-radius: 20px; font-size: 0.9rem; margin-bottom: 10px;
}

/* Chip Styles */
.chip { 
    padding: 8px 15px; border-radius: 20px; font-weight: bold; cursor: pointer; 
    margin: 5px; display: inline-flex; align-items: center; gap: 5px; transition: 0.2s;
}
.unit-chip { background: #c7ecee; color: #22a6b3; border: 2px solid #22a6b3; }
.unit-chip:hover { background: #22a6b3; color: white; }

.ai-chip { background: #ffcccc; color: #ff6b6b; border: 2px solid #ff6b6b; }
.ai-chip:hover { background: #ff6b6b; color: white; }

.unit-section { margin-top: 15px; border-top: 2px dashed #eee; padding-top: 10px; }


/* --- 1. POPUP THÔNG BÁO (MODAL) --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Nền tối mờ */
    display: none; /* Ẩn mặc định */
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Luôn nằm trên cùng */
    backdrop-filter: blur(5px); /* Làm mờ hậu cảnh */
}

.modal-box {
    background: white;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    border-radius: 25px;
    text-align: center;
    border: 5px solid #ff7675; /* Viền đỏ cam cảnh báo */
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    animation: bounceIn 0.4s ease;
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 10px;
    display: block;
}

.modal-text {
    font-size: 1.8rem; /* Chữ to */
    font-weight: 900;  /* Chữ đậm */
    color: #d63031;    /* Màu đỏ */
    text-transform: uppercase; /* Viết hoa toàn bộ */
    line-height: 1.4;
    margin-bottom: 20px;
    font-family: 'Quicksand', sans-serif;
}

.btn-close-modal {
    background: #74b9ff;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 0 #0984e3;
}
.btn-close-modal:active {
    transform: translateY(4px);
    box-shadow: none;
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

/* --- 2. CĂN GIỮA MEDIA (VIDEO/ẢNH) --- */
.media-window video, 
.media-window img {
    width: 100%;
    height: 100%;
    /* Fill đầy khung hình nhưng không làm méo tỉ lệ */
    object-fit: cover; 
    /* Luôn ưu tiên hiển thị phần trung tâm của video/ảnh */
    object-position: center center; 
}