:root {
  --nen: #fbf6f4; --nen2: #ffffff; --chu: #2b2430; --nhat: #7a6f7d; --vien: #eadde3;
  --hong: #e0607e; --hong-dam: #c2445f; --hong-nhat: #fde8ee; --xanh: #e6f1fb; --xanh-dam: #3c7cc0;
  --xanh-la: #e7f6ee; --la-dam: #2f8a57; --vang: #fff6dc;
  --bo: 18px; --bong: 0 6px 24px rgba(120, 60, 80, .10);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--chu); background: var(--nen);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: linear-gradient(180deg, #fbeff3 0%, #f2f6fc 100%) fixed; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.man { max-width: 560px; margin: 0 auto; min-height: 100%; }

/* ---------- Màn vào ---------- */
.vao { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 22px calc(32px + env(safe-area-inset-bottom)); text-align: center; }
.vao-anh { width: 168px; height: 168px; border-radius: 50%; object-fit: cover; border: 5px solid #fff; box-shadow: var(--bong); }
.vao h1 { font-family: Lora, Georgia, serif; font-size: 40px; margin: 14px 0 0; color: var(--hong-dam); }
.vao-phu { margin: 4px 0 22px; color: var(--nhat); }
#formVao { width: 100%; max-width: 340px; display: grid; gap: 10px; text-align: left; }
#formVao label { font-weight: 600; font-size: 14px; }
#formVao input { width: 100%; padding: 14px 16px; border: 2px solid var(--vien); border-radius: 14px; font-size: 22px; letter-spacing: 3px; text-align: center; background: #fff; }
#formVao input:focus { outline: none; border-color: var(--hong); }
.vao-chu { color: var(--nhat); font-size: 14px; margin-top: 22px; }
.loi { color: #c0392b; min-height: 1.2em; margin: 0; font-size: 14px; text-align: center; }

.nut-chinh { background: var(--hong); color: #fff; border: 0; border-radius: 14px; padding: 13px 20px; font-weight: 600; font-size: 17px; box-shadow: 0 4px 14px rgba(224, 96, 126, .35); }
.nut-chinh:active { transform: scale(.98); }
.nut-chinh.nho { padding: 10px 16px; font-size: 15px; }
.nut-chinh:disabled { opacity: .6; }
.nut-phu { background: #fff; border: 1.5px solid var(--vien); border-radius: 12px; padding: 9px 14px; font-weight: 500; }
.nut-tron { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--bong); font-size: 20px; display: grid; place-items: center; }

/* ---------- Màn chính ---------- */
.chinh { display: flex; flex-direction: column; height: 100dvh; height: 100vh; height: 100dvh; }
.dau { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 8px; }
.dau-anh { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: var(--bong); transition: box-shadow .3s; }
.dau-chu { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.dau-chu b { font-family: Lora, Georgia, serif; font-size: 20px; color: var(--hong-dam); }
#trangThai { font-size: 13px; color: var(--nhat); }
body.dang-noi .dau-anh { box-shadow: 0 0 0 4px var(--hong-nhat), 0 0 0 8px rgba(224, 96, 126, .25); animation: noi 1s ease-in-out infinite; }
@keyframes noi { 50% { box-shadow: 0 0 0 4px var(--hong-nhat), 0 0 0 12px rgba(224, 96, 126, .12); } }

.the { display: flex; gap: 6px; padding: 4px 12px 8px; }
.the button { flex: 1; border: 0; background: rgba(255,255,255,.6); padding: 9px 4px; border-radius: 12px; font-size: 14px; font-weight: 500; color: var(--nhat); }
.the button[aria-selected="true"] { background: #fff; color: var(--hong-dam); font-weight: 600; box-shadow: var(--bong); }

.khung-the { flex: 1; overflow-y: auto; padding: 6px 14px 12px; -webkit-overflow-scrolling: touch; }

/* Bong bóng chat */
.dong-chat { display: flex; flex-direction: column; gap: 10px; }
.bong { max-width: 88%; padding: 11px 14px; border-radius: var(--bo); line-height: 1.5; font-size: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.04); position: relative; }
.bong.sophia { background: #fff; border-bottom-left-radius: 6px; align-self: flex-start; }
.bong.toi { background: var(--hong); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.bong.toi.vi { background: #a27ab3; }
.bong .en { display: block; }
.bong .vi { display: block; color: #6b4a78; font-size: 15px; background: #f6effa; border-radius: 10px; padding: 7px 10px; margin: 6px 0; }
.bong .an { filter: blur(5px); user-select: none; cursor: pointer; }
.bong-nut { display: flex; gap: 6px; margin-top: 6px; }
.bong-nut button { border: 0; background: var(--xanh); color: var(--xanh-dam); border-radius: 10px; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.bong.cho { color: var(--nhat); font-style: italic; }
.ba-cham span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hong); margin: 0 2px; animation: cham 1.2s infinite; }
.ba-cham span:nth-child(2) { animation-delay: .15s; } .ba-cham span:nth-child(3) { animation-delay: .3s; }
@keyframes cham { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.sua { align-self: flex-end; max-width: 88%; background: var(--xanh-la); border: 1px solid #c8e9d6; border-radius: 14px; padding: 9px 12px; font-size: 14px; line-height: 1.45; }
.sua b { color: var(--la-dam); }
.sua s { color: #b0505e; }
.the-tu { align-self: flex-start; max-width: 88%; background: var(--vang); border: 1px solid #f3e2a8; border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.the-tu .tu { font-size: 18px; font-weight: 700; color: #8a5a00; }
.the-tu .doc { color: var(--nhat); }
.the-tu .meo { display: block; margin-top: 4px; }
.the-tu button { border: 0; background: #fff; border-radius: 8px; padding: 2px 8px; margin-left: 6px; }
.he-thong { align-self: center; font-size: 13px; color: var(--nhat); text-align: center; padding: 4px 10px; }
.he-thong.loi-to { color: #c0392b; background: #fdecec; border-radius: 10px; }

/* Phiên dịch */
.dich-chon { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; }
.dich-chon label { font-weight: 600; font-size: 15px; }
.dich-chon select { flex: 1; padding: 9px 10px; border-radius: 12px; border: 1.5px solid var(--vien); background: #fff; }
.dich-huong { font-size: 14px; color: var(--nhat); margin: 4px 0 12px; line-height: 1.5; }
.dong-dich { display: flex; flex-direction: column-reverse; gap: 12px; }
.the-dich { background: #fff; border-radius: var(--bo); padding: 12px 14px; box-shadow: var(--bong); }
.the-dich .goc { font-size: 14px; color: var(--nhat); }
.the-dich .dich { font-size: 24px; font-weight: 600; line-height: 1.35; margin: 6px 0; color: var(--chu); }
.the-dich.ve-viet .dich { color: #6b4a78; }
.the-dich .doc { font-size: 15px; color: var(--xanh-dam); }

/* Sổ từ */
.tu-dau { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.tu-dau p { margin: 0; color: var(--nhat); font-size: 14px; }
.ds-tu { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ds-tu li { background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.ds-tu li b { font-size: 17px; }
.ds-tu li span { flex: 1; color: var(--nhat); font-size: 14px; }
.ds-tu li button { border: 0; background: var(--xanh); border-radius: 10px; padding: 6px 10px; }

/* Thanh điều khiển */
.day { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.75); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--vien); }
.hang-chip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.hang-chip::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--vien); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 14px; white-space: nowrap; }
.chip:active { background: var(--hong-nhat); }
.hang-mic { display: flex; align-items: center; justify-content: center; gap: 28px; padding-top: 4px; }
.nut-tron.nho { width: 46px; height: 46px; font-size: 19px; }
.mic { position: relative; width: 82px; height: 82px; border-radius: 50%; border: 0; background: linear-gradient(145deg, #ee7d97, var(--hong-dam)); box-shadow: 0 8px 22px rgba(194, 68, 95, .40); display: grid; place-items: center; }
.mic-icon { font-size: 34px; position: relative; z-index: 1; }
.mic-vong { position: absolute; inset: 0; border-radius: 50%; }
.mic.nghe { background: linear-gradient(145deg, #ff6b6b, #d63031); }
.mic.nghe .mic-vong { animation: vong 1.3s ease-out infinite; box-shadow: 0 0 0 0 rgba(214, 48, 49, .5); }
.mic.nghe.co-tieng .mic-vong { animation-duration: .6s; }
.mic.nghi { background: linear-gradient(145deg, #b9a4c9, #8e6fa8); }
.mic:disabled { opacity: .7; }
@keyframes vong { 0% { box-shadow: 0 0 0 0 rgba(214, 48, 49, .5); } 100% { box-shadow: 0 0 0 26px rgba(214, 48, 49, 0); } }
.goi-y-mic { text-align: center; font-size: 13px; color: var(--nhat); margin: 6px 0 0; min-height: 1.3em; }
.form-go { display: flex; gap: 8px; margin-top: 8px; }
.form-go input { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--vien); background: #fff; font-size: 16px; }

/* Hộp thoại */
.hop { border: 0; border-radius: 22px; padding: 20px; width: min(92vw, 460px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.hop::backdrop { background: rgba(40, 20, 35, .45); }
.hop h2 { margin: 0 0 12px; font-family: Lora, Georgia, serif; color: var(--hong-dam); }
.hang { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--vien); font-size: 15px; }
.hang small { color: var(--nhat); }
.hang select { padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--vien); background: #fff; max-width: 55%; }
.hang input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--hong); }
.hop-nut { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.cai-ten { color: var(--nhat); font-size: 14px; margin: 12px 0 0; }
.cai-cai { font-size: 13px; color: var(--nhat); margin: 14px 0 0; line-height: 1.5; }
#tkNoiDung { font-size: 15px; line-height: 1.55; max-height: 60vh; overflow-y: auto; }
#tkNoiDung h3 { font-size: 15px; margin: 12px 0 4px; color: var(--hong-dam); }
#tkNoiDung p { margin: 0; white-space: pre-line; }

.chu-to { position: fixed; inset: 0; background: #fff; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.chu-to p { font-size: clamp(30px, 8vw, 56px); font-weight: 700; line-height: 1.3; margin: 0 0 20px; }
.chu-to small { color: var(--nhat); }
