/* Trước giờ gửi – trò chơi soát lỗi thư (TOEX English). Chuyển động bằng CSS + Web Animations, không thư viện. */
:root {
  --kem: #FBF6EA; --the: #F6EDDB; --vien: #E2D8C0; --rung: #3A4A32; --olive: #5F6D45;
  --chu: #4A4A3E; --chu-phu: #625E51; --cam: #B25D2A; --cam-dam: #8F4519; --glacier: #86A3BB;
  --giay: #FFFCF4; --xanh-dam: #2F4A62; --do: #A8412A; --vang: #D9A63A;
  --font: "Be Vietnam Pro", system-ui, sans-serif; --serif: "Lora", Georgia, serif;
  --r: 8px; --ease: cubic-bezier(.16, 1, .3, 1); --chan-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #E9DEC3; color: var(--chu); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, .w:focus-visible { outline: 3px solid var(--xanh-dam); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.14); margin-left: 6px; }
@media (hover: none) { kbd { display: none; } }
#app { height: 100dvh; position: relative; overflow: hidden; overflow: clip; }
.view { height: 100dvh; width: 100%; }
.nhan-nho { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--olive); }

/* ---------- nút ---------- */
.nut { min-height: 44px; padding: 10px 20px; border-radius: var(--r); border: 2px solid var(--rung); background: var(--giay); color: var(--rung); font-weight: 700; font-size: 15px; transition: transform .12s var(--ease), background .15s, box-shadow .12s; }
.nut:hover { background: #fff; }
.nut:active { transform: translateY(1px) scale(.98); }
.nut-chinh { background: var(--cam); border-color: var(--cam-dam); color: #fff; box-shadow: 0 3px 0 var(--cam-dam); }
.nut-chinh:hover { background: #BF6730; }
.nut-chinh:active { box-shadow: 0 1px 0 var(--cam-dam); transform: translateY(2px); }
.nut-phu { background: transparent; border-color: var(--vien); }
.nut-phu:hover { background: var(--the); }
.nut-nho { min-height: 44px; min-width: 44px; padding: 6px 14px; font-size: 14px; }
.nut[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.nut-sang { background: rgba(251,246,234,.1); border-color: rgba(251,246,234,.35); color: var(--kem); }
.nut-sang:hover { background: rgba(251,246,234,.22); }

/* ---------- màn chính ---------- */
.chu-cuon { height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 16px 48px; background: radial-gradient(1000px 500px at 10% -10%, #F5EBD2, transparent), #EFE5CC; }
.chu-khung { width: min(980px, 100%); margin: 0 auto; }
.chu-dau h1 { font-family: var(--serif); font-size: clamp(38px, 7vw, 58px); line-height: 1.08; margin: 4px 0 8px; color: var(--rung); }
.chu-gt { margin: 0 0 16px; max-width: 62ch; font-size: 16px; }
.the-cap { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.the-cap > div { background: var(--giay); border: 2px solid var(--vien); border-radius: var(--r); padding: 12px 14px; }
.cap-ten b { display: block; font-family: var(--serif); font-size: 24px; color: var(--rung); line-height: 1.2; margin-top: 2px; }
.cap-so b { font-family: var(--serif); font-size: 30px; color: var(--cam-dam); line-height: 1.1; display: block; }
.cap-so span { font-size: 12.5px; color: var(--chu-phu); line-height: 1.3; display: block; }
.hang-nut { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.sao-nho .sao { font-size: 13px; }
.cap { background: var(--the); border: 2px solid var(--vien); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.cap.khoa { opacity: .62; }
.cap-dau { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cap h2 { font-family: var(--serif); font-size: 22px; margin: 0; color: var(--rung); }
.cap-tien { font-size: 13px; font-weight: 600; color: var(--chu-phu); }
.cap-mt { margin: 2px 0 10px; font-size: 14px; color: var(--chu-phu); }
.luoi-thu { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.o-thu { text-align: left; display: grid; gap: 2px; min-height: 104px; padding: 10px 12px; background: var(--giay); border: 2px solid var(--vien); border-radius: var(--r); transition: transform .18s var(--ease), border-color .15s, box-shadow .18s; }
.o-thu:hover:not([disabled]) { border-color: var(--olive); transform: translateY(-3px); box-shadow: 0 8px 14px -8px rgba(58,74,50,.45); }
.o-thu[disabled] { cursor: not-allowed; }
.o-thu.xong { border-color: var(--olive); }
.o-so { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--cam-dam); line-height: 1; }
.o-ten { font-weight: 700; font-size: 14.5px; line-height: 1.25; color: var(--rung); }
.o-loai { font-size: 12px; color: var(--chu-phu); }
.o-sao { margin-top: auto; }
.sao { color: var(--vien); font-size: 17px; letter-spacing: 1px; }
.sao.co { color: var(--vang); text-shadow: 0 1px 0 rgba(143,69,25,.5); }
.chu-ky { font-size: 13px; color: var(--chu-phu); }
.loi-tai { padding: 14px; background: var(--giay); border: 2px solid var(--do); border-radius: var(--r); }

/* ---------- màn thư ---------- */
#v-thu { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #E3D6B6; }
.thu-bar { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; background: var(--rung); color: var(--kem); padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); }
.thu-ten { font-family: var(--serif); font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thu-gio { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; padding: 6px 10px; border-radius: 6px; background: rgba(251,246,234,.12); white-space: nowrap; }
.thu-gio.gap { background: var(--cam); animation: nhip .9s ease-in-out infinite; }
.thu-gio.qua { background: var(--do); }
.thu-ban { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 12px calc(var(--chan-h) + 70px); background:
  repeating-linear-gradient(90deg, rgba(120,90,50,.045) 0 2px, transparent 2px 9px), linear-gradient(#E9DEC3, #DCCDA8); scroll-behavior: smooth; }
body.co-sheet .thu-ban { padding-bottom: 300px; }
.huong-dan { width: min(720px, 100%); margin: 0 auto 12px; background: var(--giay); border: 2px solid var(--olive); border-radius: var(--r); padding: 12px 16px; font-size: 15px; animation: vao .5s var(--ease) both; }
.huong-dan ol { margin: 6px 0; padding-left: 20px; } .huong-dan p { margin: 0; color: var(--chu-phu); }
.thu { width: min(720px, 100%); margin: 0 auto; background: #FFFDF6; border: 1px solid var(--vien); border-radius: 10px; box-shadow: 0 1px 0 #fff inset, 0 14px 30px -14px rgba(70,50,20,.5); overflow: hidden; transform-origin: 50% 100%; animation: vao .45s var(--ease) both; }
.thu-dau { background: var(--the); border-bottom: 1px solid var(--vien); padding: 10px 16px; font-size: 14px; }
.thu-dau .dong { display: flex; gap: 12px; padding: 2px 0; }
.thu-dau .dong span { flex: none; width: 58px; color: var(--chu-phu); }
.thu-dau .dong b { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.thu-dau .tde b { font-family: var(--serif); font-size: 16px; }
.thu-than { padding: 14px 20px 22px; font-size: 19px; line-height: 2.3; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; color: #3D3D32; }
.doan { margin: 0 0 .7em; padding: 0 6px; border-left: 4px solid transparent; border-radius: 4px; transition: background .3s, border-color .3s; }
.doan.ngan { margin-bottom: .1em; line-height: 2; }
.w { position: relative; display: inline; border-radius: 4px; cursor: pointer; transition: background .15s; }
.w::after { content: ""; position: absolute; inset: -.55em -.32em; }
.w:hover { background: rgba(95,109,69,.16); }
.w.kiem { text-decoration: underline dotted rgba(98,94,81,.7); text-underline-offset: .22em; }
.w.lac { animation: lac .38s; }
.w.goi-y { animation: nhip .9s ease-in-out infinite; background: rgba(217,166,58,.35); border-radius: 6px; }
.cau.soi { background: linear-gradient(transparent 6%, rgba(217,166,58,.32) 6% 94%, transparent 94%); border-radius: 6px; box-decoration-break: clone; -webkit-box-decoration-break: clone; animation: soi .6s var(--ease); }
.doan.tra-lai { border-left-color: var(--do); background: rgba(168,65,42,.08); animation: tra .55s var(--ease); }
.ghi-kem { margin: 16px 0 6px; padding-top: 12px; border-top: 1px dashed var(--vien); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--olive); line-height: 1.4; }

/* bút đỏ: gạch chữ cũ, chữ mới màu rừng */
.da-sua { display: inline; cursor: default; }
.da-sua del { color: var(--do); text-decoration: none; background: linear-gradient(var(--do), var(--do)) 0 58% / 100% 2.5px no-repeat; margin-right: .3em; opacity: .85; }
.da-sua ins { text-decoration: none; font-weight: 700; color: var(--rung); border-bottom: 2px solid rgba(58,74,50,.35); }
.da-sua.moi del { animation: gach .38s var(--ease) both; }
.da-sua.moi ins { animation: viet .55s .22s var(--ease) both; background: linear-gradient(90deg, rgba(168,65,42,.0), rgba(168,65,42,.22) 40%, rgba(168,65,42,0)) no-repeat; background-size: 220% 100%; background-position: 140% 0; animation-name: viet, quet; animation-duration: .55s, .8s; animation-delay: .22s, .22s; }

/* ---------- ghi chú, thanh dưới ---------- */
.ghi-chu { position: absolute; left: 50%; bottom: calc(var(--chan-h) + 10px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(660px, calc(100% - 20px)); background: var(--giay); border: 2px solid var(--vien); border-left-width: 6px; border-radius: var(--r); padding: 10px 14px; font-size: 14.5px; line-height: 1.45; box-shadow: 0 12px 24px -12px rgba(30,40,25,.55); z-index: 5; animation: len .35s var(--ease) both; max-height: 38dvh; overflow: auto; }
.ghi-chu.dung { border-left-color: var(--olive); } .ghi-chu.nham { border-left-color: var(--vang); } .ghi-chu.tra { border-left-color: var(--do); background: #FFF3EC; } .ghi-chu.nhe { border-left-color: var(--glacier); }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--rung); color: var(--kem); font-size: 12px; font-weight: 700; margin-right: 6px; }
.combo { display: inline-block; color: var(--cam-dam); font-weight: 700; margin-left: 6px; }
.thu-chan { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; background: var(--rung); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); min-height: var(--chan-h); position: relative; z-index: 6; }
.con-loi { color: var(--kem); font-size: 15px; } .con-loi b { font-family: var(--serif); font-size: 24px; margin: 0 2px; }
.san-sang { color: #F3D58B; font-weight: 700; }
.nut-soi { background: var(--giay); } .nut-gui { min-width: 110px; }
.nut-gui.san { animation: nhip 1.1s ease-in-out infinite; }

/* ---------- bảng chọn cách sửa ---------- */
.sheet-nen { position: fixed; inset: 0; background: rgba(40,45,30,.2); z-index: 20; animation: hien .2s both; }
.sheet { position: fixed; left: 50%; bottom: 0; width: min(560px, 100%); transform: translate(-50%, 105%); background: var(--giay); border: 2px solid var(--rung); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); z-index: 21; box-shadow: 0 -16px 30px -12px rgba(30,40,25,.5); transition: transform .26s var(--ease); max-height: 92dvh; overflow-y: auto; }
.sheet.mo { transform: translate(-50%, 0); }
.sheet-tay { width: 44px; height: 4px; border-radius: 4px; background: var(--vien); margin: 0 auto 8px; }
.sheet-tt { margin: 0 0 8px; font-size: 16px; }
.sheet-tt b { font-family: var(--serif); color: var(--do); font-size: 19px; }
.sheet-opt { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; text-align: left; background: var(--the); border: 2px solid var(--vien); border-radius: var(--r); font-size: 18px; font-weight: 600; transition: transform .12s var(--ease), border-color .15s, background .15s; }
.opt:hover:not(:disabled), .opt:focus-visible { border-color: var(--olive); background: #fff; }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt-so { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--rung); color: var(--kem); display: grid; place-items: center; font-size: 14px; }
.opt.sai { border-color: var(--do); background: #FBE7DF; color: var(--do); text-decoration: line-through; animation: lac .4s; }
.opt.sai .opt-so { background: var(--do); }
.sheet-bao { margin: 8px 0 0; padding: 8px 12px; border-radius: var(--r); background: #FBE7DF; border-left: 5px solid var(--do); font-size: 14.5px; line-height: 1.45; animation: len .3s var(--ease); }
.sheet-giu { width: 100%; margin-top: 8px; min-height: 44px; }

/* ---------- dấu duyệt ---------- */
.dau-duyet { position: absolute; left: 50%; top: 42%; z-index: 9; pointer-events: none; transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); opacity: 0; font-family: var(--serif); font-weight: 700; font-size: clamp(34px, 9vw, 64px); letter-spacing: .06em; color: var(--do); border: 6px solid var(--do); border-radius: 10px; padding: 4px 22px; background: rgba(255,252,244,.55); mix-blend-mode: multiply; white-space: nowrap; }
.dau-duyet.hien { animation: dap .5s var(--ease) forwards; }
.thu.bay { animation: bay .85s .05s cubic-bezier(.5, 0, .75, 0) forwards; }
.thu.rung { animation: rung .5s; }

/* ---------- hộp thoại ---------- */
.hop-nen { position: fixed; inset: 0; z-index: 40; background: rgba(36,44,30,.78); display: grid; place-items: center; padding: 12px; animation: hien .25s both; }
.hop { width: min(620px, 100%); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; background: var(--kem); border: 2px solid var(--rung); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.4); animation: hop .45s var(--ease) both; overflow: hidden; }
.hop-than { padding: 18px 20px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.hop-chan { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 2px solid var(--vien); background: var(--the); }
.hop-chan .nut { flex: 1 1 160px; }
.hop-nhan { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--olive); }
.hop h2 { font-family: var(--serif); font-size: 28px; margin: 2px 0 8px; color: var(--rung); line-height: 1.15; }
.hop-sao .sao { font-size: 38px; display: inline-block; animation: sao .6s var(--ease) both; animation-delay: calc(var(--n, 0) * .14s + .2s); }
.hop-so { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; list-style: none; padding: 0; margin: 10px 0; }
.hop-so li { background: var(--the); border: 1px solid var(--vien); border-radius: var(--r); padding: 6px 4px; text-align: center; }
.hop-so b { display: block; font-family: var(--serif); font-size: 22px; color: var(--rung); line-height: 1.1; }
.hop-so span { font-size: 11.5px; color: var(--chu-phu); line-height: 1.2; display: block; }
.sep { background: var(--giay); border-left: 5px solid var(--cam); border-radius: 4px; padding: 8px 12px; margin: 0 0 8px; font-size: 14.5px; }
.on-tt { font-family: var(--serif); font-size: 18px; margin: 12px 0 6px; color: var(--rung); }
.on { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.on li { background: var(--giay); border: 1px solid var(--vien); border-radius: var(--r); padding: 10px 12px; animation: len .5s var(--ease) both; animation-delay: calc(var(--n, 0) * .07s + .35s); }
.on p { margin: 6px 0 0; font-size: 15px; line-height: 1.5; }
.c-sai .l, .c-dung .l { display: inline-block; min-width: 62px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }
.c-sai .l { color: var(--do); } .c-dung .l { color: var(--olive); }
.c-sai del { color: var(--do); text-decoration: none; background: linear-gradient(var(--do), var(--do)) 0 58% / 100% 2px no-repeat; }
.c-dung b { color: var(--rung); border-bottom: 2px solid rgba(58,74,50,.4); }
.meo { color: var(--chu-phu); } .meo em { font-style: normal; color: var(--rung); font-weight: 600; }
.tag-sot { font-size: 12px; color: var(--cam-dam); font-weight: 600; }
.hop-ghi { font-size: 14px; color: var(--chu-phu); margin: 10px 0 0; }

/* ---------- sổ điểm yếu ---------- */
.so-dau { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.so-dau h2 { font-family: var(--serif); font-size: 32px; margin: 0; color: var(--rung); }
.so-hang { background: var(--giay); border: 2px solid var(--vien); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; }
.so-hang.yeu { border-color: var(--cam); }
.so-tren { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .so-tren b { font-size: 16px; } .so-tren .nut { margin-left: auto; }
.can { font-size: 12px; font-weight: 700; color: #fff; background: var(--cam-dam); border-radius: 999px; padding: 1px 9px; }
.so-thanh { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--the); margin: 6px 0 4px; }
.so-thanh i { display: block; height: 100%; transform-origin: 0 50%; animation: dai .7s var(--ease) both; }
.so-thanh .d { background: var(--olive); } .so-thanh .s { background: var(--vang); } .so-thanh .b { background: var(--do); }
.so-so { margin: 0; font-size: 13px; color: var(--chu-phu); } .so-meo { margin: 2px 0 0; font-size: 13.5px; }

/* ---------- chuyển động ---------- */
@keyframes vao { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes len { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ghi-chu { animation-name: len-g; }
@keyframes len-g { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes hien { from { opacity: 0; } to { opacity: 1; } }
@keyframes hop { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes nhip { 0%, 100% { box-shadow: 0 0 0 0 rgba(217,166,58,0); } 50% { box-shadow: 0 0 0 5px rgba(217,166,58,.45); } }
@keyframes lac { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
@keyframes gach { from { background-size: 0 2.5px; } to { background-size: 100% 2.5px; } }
@keyframes viet { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes quet { from { background-position: 140% 0; } to { background-position: -40% 0; } }
@keyframes soi { from { background-color: rgba(217,166,58,.7); } to { background-color: transparent; } }
@keyframes tra { 0% { background: rgba(168,65,42,.4); } 100% { background: rgba(168,65,42,.08); } }
@keyframes rung { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-.8deg) translateX(-6px); } 40% { transform: rotate(.7deg) translateX(6px); } 65% { transform: rotate(-.4deg) translateX(-3px); } }
@keyframes bay { 0% { transform: translateY(0) scale(1) rotate(0); opacity: 1; } 25% { transform: translateY(8px) scale(.98) rotate(0); opacity: 1; } 100% { transform: translateY(-120vh) scale(.5) rotate(8deg); opacity: 0; } }
@keyframes dap { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); } 55% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(.92); } 75% { transform: translate(-50%, -50%) rotate(-12deg) scale(1.04); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1); } }
@keyframes sao { from { opacity: 0; transform: scale(.2) rotate(-40deg); } 60% { transform: scale(1.3) rotate(8deg); } to { opacity: 1; transform: none; } }
@keyframes dai { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .thu.bay { opacity: 0; }
  .dau-duyet.hien { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg); }
}

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 640px) {
  .the-cap { grid-template-columns: 1fr 1fr; } .cap-ten { grid-column: 1 / -1; }
  .thu-ban { padding: 10px 8px calc(var(--chan-h) + 70px); }
  .thu-than { font-size: 17.5px; line-height: 2.5; padding: 10px 12px 20px; }
  .thu-ten { font-size: 15px; } .thu-ten .tg, .thu-bar .bt { display: none; } .thu-bar { grid-template-columns: auto 1fr auto; } #b-am2 { display: none; }
  .nut-gui { min-width: 96px; }
  .hop-so { grid-template-columns: repeat(2, 1fr); }
  .hop h2 { font-size: 24px; }
}
@media (max-height: 520px) {
  .huong-dan { padding: 6px 12px; font-size: 14px; } .huong-dan ol { display: flex; gap: 14px; flex-wrap: wrap; list-style-position: inside; padding: 0; margin: 2px 0; } .huong-dan p { display: none; }
  #v-thu .thu-ban { padding-top: 8px; }
  :root { --chan-h: 60px; }
  .thu-dau .dong:not(.tde) { display: none; }
  .thu-dau { padding: 6px 14px; }
  .thu-bar { padding-top: 4px; padding-bottom: 4px; } .thu-bar .nut { min-height: 44px; }
  .thu-chan { padding-top: 5px; padding-bottom: 5px; } .thu-chan .nut { min-height: 44px; padding: 4px 16px; }
  .thu-than { line-height: 2.3; font-size: 17px; }
  .sheet { padding-bottom: 8px; } .sheet-opt { grid-template-columns: repeat(3, 1fr); } .opt { min-height: 48px; font-size: 16px; padding: 6px 10px; }
  .sheet-giu { margin-top: 6px; min-height: 44px; } .sheet-tay { display: none; }
  .hop-so { grid-template-columns: repeat(4, 1fr); } .hop h2 { font-size: 22px; margin-bottom: 4px; } .hop-than { padding-top: 10px; } .hop-sao .sao { font-size: 28px; }
  .hop-chan { padding-top: 8px; padding-bottom: 8px; }
  body.co-sheet .thu-ban { padding-bottom: 190px; }
}

/* ---------- bt2: sếp đọc lại thư, điều kiện sao ---------- */
.thu { position: relative; }
.thu.doc::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56px; pointer-events: none; background: linear-gradient(rgba(217,166,58,0), rgba(217,166,58,.28) 70%, rgba(178,93,42,.55) 100%); border-bottom: 2px solid var(--cam); animation: doc .75s cubic-bezier(.45, 0, .55, 1) both; }
@keyframes doc { from { transform: translateY(-56px); } to { transform: translateY(var(--doc-h, 600px)); } }
.dk-sao { list-style: none; margin: 4px 0 10px; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.dk-sao li { display: flex; gap: 8px; align-items: baseline; }
.dk-sao b { flex: none; min-width: 44px; text-align: center; font-size: 12px; border-radius: 999px; padding: 1px 8px; }
.dk-sao .co b { background: var(--rung); color: var(--kem); }
.dk-sao .khong b { background: var(--the); color: var(--cam-dam); border: 1px solid var(--vien); }
.dk-sao .khong { color: var(--chu-phu); }
.sheet-bao em { font-style: normal; font-weight: 700; color: var(--cam-dam); }
.ghi-chu { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .thu.doc::after { display: none; } }
/* vùng chạm: bien-tap.js chọn từ gần điểm chạm nhất, nên từ ngắn (a, in, on) vẫn dễ trúng */
.w.dang-chon { background: rgba(178,93,42,.18); box-shadow: 0 0 0 2px var(--cam); border-radius: 4px; }
@media (max-width: 640px) {
  .hop-so { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .hop-so li { padding: 5px 2px; } .hop-so b { font-size: 19px; } .hop-so span { font-size: 10.5px; }
  .hop-sao .sao { font-size: 32px; }
  .dk-sao { font-size: 13.5px; }
}
/* hộp thoại: nền phủ kín ngay, hộp chỉ trượt (không mờ dần) để không lộ chữ phía sau */
.hop-nen { animation: none; }
.hop { animation-name: hop-truot; }
@keyframes hop-truot { from { transform: translateY(24px) scale(.96); } to { transform: none; } }
.c-truoc { color: var(--chu-phu); }

/* soát độc lập 20261118dt1: màn nhỏ vẫn có nút tắt/bật tiếng trong màn thư – thu gọn thành biểu tượng loa 44×44 */
@media (max-width: 640px) {
  .thu-bar { grid-template-columns: auto 1fr auto auto; }
  .thu-gio { white-space: normal; max-width: 112px; text-align: center; font-size: 13px; line-height: 1.2; padding: 4px 8px; }
  #b-am2 { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; padding: 0; font-size: 0; }
  #b-am2::before { content: ""; width: 22px; height: 22px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M19 5a10 10 0 0 1 0 14'/%3E%3C/svg%3E") center / contain no-repeat; }
  #b-am2[aria-pressed="true"]::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='m16 9 6 6M22 9l-6 6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='m16 9 6 6M22 9l-6 6'/%3E%3C/svg%3E"); }
}

/* ux1 – sửa theo đánh giá: lối vào rõ, ngữ cảnh trên bảng sửa, lời giải sát chỗ sửa, Gửi trung tính tới khi hết lỗi */
.chu-gt { font-size: 17px; color: #3F3B30; max-width: 56ch; margin-bottom: 14px; }
.nut-dau { min-height: 52px; padding: 12px 28px; font-size: 17px; margin-bottom: 16px; }
.nhan-nho { color: #4F5A36; } .o-loai, .cap-mt, .chu-ky { color: #4F4B3F; } .cap-mt { font-size: 14.5px; } .o-loai { font-size: 12.5px; }
.sheet-cau { margin: 0 0 10px; padding: 8px 12px; border-radius: var(--r); background: var(--the); border: 1px solid var(--vien); font-family: var(--serif); font-size: 16px; line-height: 1.45; color: var(--rung); }
.cau-trong { display: inline-block; min-width: 3.2em; margin: 0 2px; border-bottom: 3px solid var(--cam); color: transparent; line-height: 1; vertical-align: baseline; }
.sheet-cau:empty { display: none; }
.cau-giai { margin: -.2em 0 .9em; padding: 8px 12px; border-radius: var(--r); background: #E9EEDD; border: 1px solid #B9C79B; border-left: 6px solid var(--olive); font-size: 15px; line-height: 1.5; color: #2E3A27; animation: len .3s var(--ease); }
.cau-giai .gi-d { display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 999px; background: var(--olive); color: #fff; font-size: 12.5px; }
.nut-gui:not(.san) { background: var(--giay); color: var(--rung); border-color: #7D8A6B; box-shadow: none; }
.nut-gui.san { background: var(--cam); color: #fff; border-color: var(--cam-dam); box-shadow: 0 3px 0 var(--cam-dam); }
.nut-gui:not(.san) kbd { background: rgba(0,0,0,.1); }
.con-loi { font-size: 16px; font-weight: 600; } .con-loi b { font-size: 28px; color: #FFE7A8; }
.thu-gio { font-size: 14px; }
@media (max-width: 640px) {
  .thu-bar { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px; }
  .thu-ten { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; font-size: 15.5px; }
  .thu-gio { max-width: none; white-space: nowrap; font-size: 13px; padding: 5px 8px; }
  .sheet-cau { font-size: 16px; }
  .nut-dau { width: 100%; }
}
@media (max-height: 520px) { .sheet-cau { display: none; } }
@media (max-width: 640px) {
  .con-loi { white-space: nowrap; font-size: 14.5px; line-height: 1.15; } .con-loi b { font-size: 24px; }
  .thu-chan { gap: 8px; } .thu-chan .nut { padding-left: 12px; padding-right: 12px; } .nut-gui { min-width: 80px; }
}
/* k13: tương phản đo được – viền ô chọn ≥ 3:1 */
.opt { border-color: #8F8569; }
.sheet-giu { border-color: #8F8569; }
.nut-sang { border-color: rgba(251,246,234,.6); }
kbd { font-size: 12px; }

/* ux2 – từ chạm được rõ hơn, lời giải ngay sau câu vừa sửa, bảng đáp án thấp hơn trên điện thoại, thư và bảng rộng hơn trên máy tính */
.cham-goi { margin: 0; padding: 8px 20px; background: #E9EEDD; border-bottom: 1px solid #B9C79B; color: #2E3A27; font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.w:hover { background: rgba(95,109,69,.22); text-decoration: underline; text-decoration-color: var(--olive); text-underline-offset: .2em; }
.gon .w { animation: gon .8s ease-out both; animation-delay: calc(var(--n, 0) * 22ms); }
@keyframes gon { 0% { background: transparent; } 35% { background: rgba(95,109,69,.26); } 100% { background: transparent; } }
.cau-giai { display: block; margin: .2em 0 .5em; line-height: 1.5; }
span.cau-giai { font-size: 15px; }
@media (min-width: 900px) {
  .thu, .huong-dan { width: min(780px, 100%); }
  .thu-than { font-size: 20px; padding: 18px 28px 26px; }
  .thu-dau { font-size: 15px; padding: 12px 20px; }
  .cham-goi { padding: 9px 28px; font-size: 15px; }
  .sheet { width: min(640px, 100%); }
  .sheet-cau { font-size: 17px; } .sheet-bao, .cau-giai { font-size: 15.5px; }
}
@media (max-width: 640px) {
  .sheet { padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }
  .sheet-tay { display: none; }
  .sheet-tt { margin-bottom: 6px; }
  .sheet-cau { margin-bottom: 8px; padding: 6px 10px; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .sheet-opt { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; }
  .opt { min-height: 46px; padding: 6px 10px; font-size: 17px; gap: 8px; }
  .opt-so { width: 24px; height: 24px; font-size: 13px; }
  .sheet-giu { margin-top: 6px; min-height: 44px; }
  .cham-goi { padding: 8px 12px; }
  body.co-sheet .thu-ban { padding-bottom: 220px; }
}

/* ux3: bảng chọn – đáp án dài hoặc màn ≤ 400px thì xếp dọc (mỗi nút cả hàng, ≥ 44px); màn ngang thấp vẫn xếp ngang cho đủ chỗ thấy câu */
@media (min-height: 521px) {
  .sheet-opt.dai { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 400px) and (min-height: 521px) {
  .sheet-opt { grid-template-columns: 1fr; gap: 8px; }
  .opt { min-height: 46px; }
  body.co-sheet .thu-ban { padding-bottom: 360px; }
}
/* ux3: Gửi là hành động chính (hết lỗi: cam đặc, to hơn); Soi là nút phụ dạng viền */
.thu-chan .nut-soi { background: transparent; color: var(--kem); border: 1.5px solid rgba(251,246,234,.7); box-shadow: none; font-weight: 600; }
.thu-chan .nut-soi:hover:not([disabled]) { background: rgba(251,246,234,.12); }
.thu-chan .nut-soi kbd { background: rgba(251,246,234,.18); }
.thu-chan .nut-gui { border-width: 2px; }
.thu-chan .nut-gui:not(.san) { background: var(--giay); color: var(--rung); border-color: var(--giay); }
.thu-chan .nut-gui.san { min-height: 50px; min-width: 132px; padding: 10px 26px; font-size: 17px; font-weight: 800; background: var(--cam); color: #fff; border-color: #D98A55; box-shadow: 0 3px 0 var(--cam-dam), 0 0 0 3px rgba(243,213,139,.35); }
@media (max-width: 640px) { .thu-chan .nut-gui.san { min-width: 104px; padding: 8px 18px; } }

/* ux4: chọn sai – gợi ý gọn tối đa 2 dòng (chạm để mở đủ), bảng thấp để vẫn thấy thân thư; câu đang sửa đã thấy ở thư phía trên nên ẩn khung câu trích trên điện thoại */
.sheet-bao.dai { position: relative; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; padding-right: 34px; cursor: pointer; }
.sheet-bao.dai::after { content: ""; position: absolute; right: 13px; top: 13px; width: 8px; height: 8px; border-right: 2.5px solid var(--do); border-bottom: 2.5px solid var(--do); transform: rotate(45deg); }
.sheet-bao.dai.mo { display: block; -webkit-line-clamp: unset; overflow: visible; }
.sheet-bao.dai.mo::after { transform: rotate(-135deg); top: 17px; }
.sheet-bao.dai:focus-visible { outline: 3px solid var(--cam); outline-offset: 2px; }
@media (max-width: 640px) {
  .sheet.co-sai .sheet-cau { display: none; }
  .sheet.co-sai .sheet-tt { margin-bottom: 4px; }
  .sheet.co-sai .sheet-bao { margin-top: 6px; padding-top: 6px; padding-bottom: 6px; }
}
/* ux4: từ vừa sửa dính với từ kế tiếp trên cùng một dòng (chỉ phần hiển thị) */
.dinh-cum { white-space: nowrap; }
.sheet-bao.dai:not(.mo) { padding-bottom: 0 !important; border-bottom: 7px solid #FBE7DF; }
/* ux5: điện thoại thấp (≤ 400 × ≤ 700) – bảng chọn gọn hơn để khi chọn sai vẫn ≤ 45% màn; nút vẫn ≥ 44px, gợi ý vẫn 2 dòng */
@media (max-width: 400px) and (min-height: 521px) and (max-height: 700px) {
  .sheet { padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .sheet-tt { margin-bottom: 4px; font-size: 15px; line-height: 1.25; } .sheet-tt b { font-size: 18px; }
  .sheet-opt, .sheet-opt.dai { gap: 5px; }
  .opt { min-height: 44px; padding: 4px 10px; }
  .sheet.co-sai .sheet-bao { margin-top: 5px; padding-top: 5px; line-height: 1.35; }
  .sheet-giu { margin-top: 5px; min-height: 44px; }
}

/* b1: máy tính – đáp án xếp ngang để bảng chọn khi sai còn ≤ 45% chiều cao (không đặt max-height cứng: màn thấp hơn thì bảng cao thêm chứ không giấu "Giữ nguyên"), phần giải thích mở ra cuộn riêng */
@media (min-width: 641px) and (min-height: 600px) {
  .sheet-opt:not(.dai) { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
  .sheet-opt:not(.dai) .opt { min-height: 48px; }
  .sheet.co-sai .sheet-bao.dai.mo { max-height: 18dvh; overflow-y: auto; }
}
/* b1: đáp án dài – máy tính rộng (≥ 900px, bảng 640px) cũng xếp ngang 3 cột, chữ 16px */
@media (min-width: 900px) and (min-height: 600px) {
  .sheet-opt.dai { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .sheet-opt.dai .opt { min-height: 48px; padding: 6px 10px; gap: 8px; font-size: 16px; line-height: 1.25; }
  .sheet-opt.dai .opt-so { width: 24px; height: 24px; font-size: 13px; }
}
/* b1: nút cuối lượt chắc chắn ≥ 44px (đệm 2px phòng làm tròn) */
.hop-chan .nut { min-height: 46px; }
