:root {
  --nen: #0e1311; --mat: #141b18; --mat2: #1a2420; --mat3: #212d28; --vien: #26332d; --vien2: #33443c;
  --chu: #e8eee9; --phu: #93a39a; --mo: #66766d;
  --dong: #d39b62; --dong2: #e9b882; --dong-nen: rgba(211, 155, 98, .13);
  --xanh: #52b78c; --xanh-nen: rgba(82, 183, 140, .13); --do: #e5675c; --do-nen: rgba(229, 103, 92, .12);
  --bk: 14px; --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--nen); color: var(--chu); font: 15px/1.6 var(--font); }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.an { display: none !important; }

/* ---------- Dang nhap ---------- */
.man { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(211,155,98,.16), transparent 60%), radial-gradient(700px 500px at 100% 110%, rgba(82,183,140,.10), transparent 60%), var(--nen); }
.dn-the { width: min(380px, 100%); text-align: center; animation: len .5s ease both; }
.dn-logo { width: 76px; height: 76px; border-radius: 22px; box-shadow: 0 18px 50px rgba(211,155,98,.25); }
.dn-the h1 { margin: 18px 0 4px; font-size: 24px; letter-spacing: -.01em; }
.dn-the p { margin: 0 0 26px; color: var(--phu); font-size: 14px; }
#fDangNhap { display: flex; gap: 8px; }
#fDangNhap input { flex: 1; min-width: 0; padding: 13px 15px; border-radius: 13px; border: 1px solid var(--vien2); background: var(--mat); outline: none; transition: border-color .2s, box-shadow .2s; }
#fDangNhap input:focus { border-color: var(--dong); box-shadow: 0 0 0 4px var(--dong-nen); }
.dn-loi { min-height: 22px; margin-top: 12px; color: var(--do); font-size: 13.5px; }

/* ---------- Nut ---------- */
.nut { padding: 12px 20px; border-radius: 13px; font-weight: 600; white-space: nowrap; transition: transform .15s, filter .2s, background .2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.nut.chinh { background: linear-gradient(180deg, var(--dong2), var(--dong)); color: #21160a; box-shadow: 0 8px 22px rgba(211,155,98,.28), inset 0 1px 0 rgba(255,255,255,.35); }
.nut.chinh:active { transform: scale(.97); }
.nut.chinh:disabled { filter: grayscale(.6) brightness(.7); cursor: default; }
.nut.phu { background: var(--mat3); border: 1px solid var(--vien2); }
.nut.nguy { background: var(--do-nen); color: var(--do); border: 1px solid rgba(229,103,92,.35); }
.nut-tron { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--phu); transition: background .2s, color .2s; flex: none; }
.nut-tron:hover, .nut-tron:active { background: var(--mat3); color: var(--chu); }
.nut-tron.nho { width: 38px; height: 38px; }
.nut-chu { color: var(--phu); font-size: 13.5px; padding: 6px 8px; border-radius: 8px; }
.nut-chu:hover { color: var(--chu); background: var(--mat3); }
.vong { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--dong); animation: quay .8s linear infinite; display: inline-block; flex: none; }
.dang-nap { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--phu); font-size: 14px; padding: 40px 0; }

/* ---------- Bo cuc ---------- */
#app { position: fixed; inset: 0; display: flex; }
#ngan { width: 300px; flex: none; background: var(--mat); border-right: 1px solid var(--vien); display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); z-index: 20; }
.ngan-dau { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; font-size: 16px; }
.ngan-logo { width: 30px; height: 30px; border-radius: 9px; }
.ngan-moi { display: flex; gap: 8px; margin-bottom: 12px; }
.nut-moi { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 6px; border-radius: 12px; background: var(--mat2); border: 1px solid var(--vien); font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: background .2s, border-color .2s, transform .15s; }
.nut-moi:hover { border-color: var(--vien2); background: var(--mat3); }
.nut-moi:active { transform: scale(.97); }
.cham { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cham.chat { background: var(--xanh); box-shadow: 0 0 0 3px var(--xanh-nen); }
.cham.lam { background: var(--dong); box-shadow: 0 0 0 3px var(--dong-nen); }
.ds-ht { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nhom-ht { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--mo); padding: 12px 8px 6px; font-weight: 600; }
.muc-ht { width: 100%; text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px; border-radius: 12px; transition: background .15s; position: relative; }
.muc-ht:hover { background: var(--mat2); }
.muc-ht.dang { background: var(--mat3); }
.muc-ht .cham { margin-top: 8px; }
.muc-ht .nd { min-width: 0; flex: 1; }
.muc-ht b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muc-ht small { display: block; color: var(--mo); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muc-ht .chay { position: absolute; right: 10px; top: 13px; }
.ngan-cuoi { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--vien); padding-top: 8px; margin-top: 6px; color: var(--mo); font-size: 12px; }
#mo { display: none; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.dau { display: flex; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--vien); background: rgba(14,19,17,.86); backdrop-filter: blur(14px); z-index: 5; }
.tieu-de { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 8px; border-radius: 10px; }
.tieu-de:hover { background: var(--mat2); }
#tTen { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.chip-cd { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; flex: none; }
.chip-cd.chat { color: var(--xanh); background: var(--xanh-nen); }
.chip-cd.lam { color: var(--dong2); background: var(--dong-nen); }

/* ---------- Tin nhan ---------- */
.khung { flex: 1; overflow-y: auto; padding: 18px 14px 10px; scroll-behavior: smooth; overscroll-behavior: contain; }
.dong-tin { max-width: 780px; margin: 0 auto 18px; animation: len .28s ease both; }
.dong-tin.nguoi { display: flex; flex-direction: column; align-items: flex-end; }
.bong { background: linear-gradient(180deg, #24332c, #1f2b26); border: 1px solid var(--vien2); padding: 9px 14px; border-radius: 18px 18px 6px 18px; max-width: 86%; white-space: pre-wrap; word-wrap: break-word; }
.tep-gui { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; max-width: 86%; }
.tep-gui img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--vien2); background: var(--mat2); }
.tep-gui .tep-ten { font-size: 12.5px; padding: 6px 10px; border-radius: 10px; background: var(--mat2); border: 1px solid var(--vien); color: var(--phu); }
.dong-tin.claude { display: flex; gap: 11px; }
.av { width: 28px; height: 28px; border-radius: 9px; flex: none; margin-top: 2px; }
.than { min-width: 0; flex: 1; }
.nd-md { word-wrap: break-word; overflow-wrap: anywhere; }
.nd-md > :first-child { margin-top: 0; }
.nd-md p { margin: 0 0 10px; }
.nd-md h2, .nd-md h3, .nd-md h4 { margin: 16px 0 8px; line-height: 1.35; font-size: 16.5px; }
.nd-md h3, .nd-md h4 { font-size: 15.5px; }
.nd-md ul, .nd-md ol { margin: 0 0 10px; padding-left: 22px; }
.nd-md li { margin: 3px 0; }
.nd-md li::marker { color: var(--dong); }
.nd-md a { color: var(--dong2); }
.nd-md strong { color: #fff; font-weight: 600; }
.nd-md code { font: 13px var(--mono); background: var(--mat3); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--vien); }
.nd-md blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid var(--dong); color: var(--phu); background: var(--mat); border-radius: 0 10px 10px 0; }
.nd-md hr { border: 0; border-top: 1px solid var(--vien2); margin: 14px 0; }
.bang { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--vien); border-radius: 12px; }
.bang table { border-collapse: collapse; width: 100%; font-size: 14px; }
.bang th, .bang td { padding: 7px 11px; border-bottom: 1px solid var(--vien); text-align: left; vertical-align: top; }
.bang th { background: var(--mat2); font-weight: 600; white-space: nowrap; }
.bang tr:last-child td { border-bottom: 0; }
.ma { margin: 0 0 12px; border: 1px solid var(--vien); border-radius: 12px; overflow: hidden; background: #0a0f0d; }
.ma-dau { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px 5px 12px; background: var(--mat2); font-size: 12px; color: var(--phu); }
.chep-ma { font-size: 12px; padding: 3px 10px; border-radius: 7px; color: var(--phu); }
.chep-ma:hover { background: var(--mat3); color: var(--chu); }
.ma pre { margin: 0; padding: 11px 13px; overflow-x: auto; }
.ma code { font: 12.8px/1.55 var(--mono); background: none; border: 0; padding: 0; white-space: pre; }
.con-tro::after { content: ''; display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--dong); border-radius: 2px; animation: nhay 1s steps(2) infinite; }
.chan-tin { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--mo); font-size: 12px; }
.chan-tin button { padding: 4px 8px; border-radius: 8px; color: var(--mo); display: inline-flex; gap: 5px; align-items: center; }
.chan-tin button:hover { background: var(--mat2); color: var(--chu); }
.chan-tin svg { width: 15px; height: 15px; }
.loi-tin { margin: 6px 0 8px; padding: 9px 12px; border-radius: 12px; background: var(--do-nen); border: 1px solid rgba(229,103,92,.3); color: #f3a59d; font-size: 14px; }

/* cong cu */
.cc-nhom { margin: 0 0 10px; border: 1px solid var(--vien); border-radius: 12px; background: var(--mat); overflow: hidden; }
.cc-nhom > summary { list-style: none; cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--phu); display: flex; align-items: center; gap: 8px; }
.cc-nhom > summary::-webkit-details-marker { display: none; }
.cc-nhom > summary::after { content: '›'; margin-left: auto; transition: transform .2s; font-size: 16px; }
.cc-nhom[open] > summary::after { transform: rotate(90deg); }
.cc { display: flex; gap: 9px; padding: 7px 12px; border-top: 1px solid var(--vien); font-size: 13px; align-items: flex-start; }
.cc .ten { color: var(--dong2); white-space: nowrap; font-weight: 500; }
.cc .mt { font: 12.3px/1.5 var(--mono); color: var(--phu); white-space: pre-wrap; word-break: break-all; min-width: 0; max-height: 7.5em; overflow: hidden; }
.cc.loi .ten { color: var(--do); }
.cc-dang { display: flex; align-items: center; gap: 9px; color: var(--phu); font-size: 13.5px; margin: 2px 0 10px; }
.cc-dang .mt { font: 12.3px var(--mono); color: var(--mo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dang-nghi { display: inline-flex; gap: 4px; padding: 6px 0 10px; }
.dang-nghi i { width: 7px; height: 7px; border-radius: 50%; background: var(--dong); animation: nay 1.2s infinite ease-in-out; }
.dang-nghi i:nth-child(2) { animation-delay: .15s; } .dang-nghi i:nth-child(3) { animation-delay: .3s; }

/* xin phep */
.xin { margin: 4px 0 12px; border-radius: 14px; border: 1px solid rgba(211,155,98,.45); background: linear-gradient(180deg, rgba(211,155,98,.12), rgba(211,155,98,.04)); padding: 12px; animation: len .25s ease both; }
.xin-dau { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--dong2); margin-bottom: 8px; }
.xin-dau svg { width: 17px; height: 17px; }
.xin pre { margin: 0 0 8px; padding: 9px 11px; background: #0a0f0d; border: 1px solid var(--vien); border-radius: 10px; font: 12.6px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; }
.xin details { margin-bottom: 8px; font-size: 13px; color: var(--phu); }
.xin details pre { margin-top: 6px; }
.xin .mota-phu { font-size: 13px; color: var(--phu); margin: -2px 0 8px; }
.hang-nut { display: flex; gap: 8px; }
.hang-nut .nut { flex: 1; padding: 10px 8px; font-size: 14px; }
.xin .kq { font-size: 13.5px; font-weight: 600; }
.xin .kq.cho { color: var(--xanh); } .xin .kq.khong { color: var(--do); }
.xin.xong { border-color: var(--vien2); background: var(--mat); }

/* man trong */
.trong { max-width: 560px; margin: 8vh auto 0; text-align: center; padding: 0 8px; animation: len .4s ease both; }
.trong img { width: 64px; height: 64px; border-radius: 19px; box-shadow: 0 14px 40px rgba(211,155,98,.2); }
.trong h2 { margin: 16px 0 6px; font-size: 21px; }
.trong p { margin: 0 auto 20px; color: var(--phu); font-size: 14px; max-width: 420px; }
.chon-cd { display: inline-flex; background: var(--mat); border: 1px solid var(--vien); border-radius: 13px; padding: 4px; gap: 4px; margin-bottom: 20px; }
.chon-cd button { padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--phu); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; transition: background .2s, color .2s; }
.chon-cd button.bat { background: var(--mat3); color: var(--chu); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.goi-y { display: grid; gap: 8px; text-align: left; }
.goi-y button { padding: 12px 14px; border-radius: 13px; background: var(--mat); border: 1px solid var(--vien); font-size: 14px; color: var(--chu); transition: border-color .2s, background .2s, transform .15s; }
.goi-y button:hover { border-color: var(--vien2); background: var(--mat2); }
.goi-y button:active { transform: scale(.985); }
.goi-y small { display: block; color: var(--mo); font-size: 12.5px; }

/* ---------- O soan ---------- */
.soan { padding: 8px 12px max(10px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(14,19,17,0), var(--nen) 30%); }
.o-soan { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; background: var(--mat2); border: 1px solid var(--vien2); border-radius: 22px; padding: 5px 5px 5px 6px; transition: border-color .2s, box-shadow .2s; }
.o-soan:focus-within { border-color: rgba(211,155,98,.55); box-shadow: 0 0 0 4px var(--dong-nen); }
#oSoan { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: none; padding: 8px 4px; max-height: 168px; line-height: 1.5; }
#oSoan::placeholder { color: var(--mo); }
.nut-gui { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(180deg, var(--dong2), var(--dong)); color: #21160a; transition: transform .15s, filter .2s, opacity .2s; }
.nut-gui:active { transform: scale(.92); }
.nut-gui:disabled { opacity: .35; }
.nut-gui svg { width: 19px; height: 19px; stroke-width: 2.4; }
.nut-gui .i-dung { display: none; fill: currentColor; stroke: none; }
.soan.dang-chay .nut-gui { background: var(--mat3); color: var(--chu); border: 1px solid var(--vien2); }
.soan.dang-chay .i-gui { display: none; } .soan.dang-chay .i-dung { display: block; }
.ds-tep { max-width: 780px; margin: 0 auto; display: flex; gap: 6px; flex-wrap: wrap; }
.ds-tep:not(:empty) { margin-bottom: 7px; }
.tep { display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 4px; border-radius: 11px; background: var(--mat2); border: 1px solid var(--vien); font-size: 12.5px; max-width: 220px; }
.tep img, .tep .bt { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: none; background: var(--mat3); display: grid; place-items: center; font-size: 10px; color: var(--phu); font-weight: 600; }
.tep span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tep button { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--mo); flex: none; }
.tep button svg { width: 14px; height: 14px; }
.tep.loi { border-color: rgba(229,103,92,.5); }

/* ---------- Tam (bottom sheet) + bao ---------- */
.tam { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: hien .2s ease both; }
.tam-the { width: min(520px, 100%); background: var(--mat); border: 1px solid var(--vien2); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); animation: truot .25s cubic-bezier(.2,.8,.2,1) both; }
.tam-the h3 { margin: 0 0 12px; font-size: 16px; }
.tam-the input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--vien2); background: var(--mat2); outline: none; margin-bottom: 12px; }
.tam-the input:focus { border-color: var(--dong); }
.tam-the .hang-nut { margin-bottom: 10px; }
.bao { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: var(--mat3); border: 1px solid var(--vien2); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 70; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.bao.hien { opacity: 1; transform: translateX(-50%) translateY(0); }
.bao.loi { border-color: rgba(229,103,92,.5); color: #f3a59d; }

@keyframes quay { to { transform: rotate(360deg); } }
@keyframes len { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes hien { from { opacity: 0; } to { opacity: 1; } }
@keyframes truot { from { transform: translateY(100%); } to { transform: none; } }
@keyframes nhay { 50% { opacity: 0; } }
@keyframes nay { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

@media (max-width: 899px) {
  #ngan { position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  #app.mo-ngan #ngan { transform: none; }
  #app.mo-ngan #mo { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 15; animation: hien .2s ease both; }
}
@media (min-width: 900px) {
  #nMenu { display: none; }
  .khung { padding: 26px 24px 10px; }
}
