/* Ấy Ơi – giao diện kiểu máy tính Windows XP, messenger 2005–2010 (tự vẽ, không dùng tài sản của hãng nào) */
:root {
  --tim-dam: #3a1470;
  --tim: #5b22b0;
  --tim-vua: #7a3ad6;
  --tim-sang: #a874ee;
  --tim-nhat: #f1eafb;
  --xp-be: #ece9d8;          /* màu nền thanh menu/hộp thoại XP */
  --xp-vien: #aca899;
  --chu: #000;
  --chu-phu: #555;
  --xam: #8c8c8c;
  --xanh: #1a7f37;
  --do: #c00;
  --vang: #ffd21f;
  --link: #3a1470;
  --tb: 34px;                /* chiều cao thanh tác vụ */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 12px/1.4 Tahoma, Verdana, "Segoe UI", sans-serif;
  color: var(--chu);
  background: #fff;
}
button, input, select, textarea { font: inherit; color: inherit; }

/* Màn hình nền tự vẽ: trời tím + đồi */
.desktop-bg {
  background:
    radial-gradient(ellipse 70% 40% at 25% 100%, #8fd18a 0 60%, transparent 61%),
    radial-gradient(ellipse 90% 45% at 85% 105%, #6cbf6a 0 60%, transparent 61%),
    radial-gradient(ellipse 120% 30% at 50% 110%, #4fa84f 0 70%, transparent 71%),
    radial-gradient(circle at 78% 18%, rgba(255,255,255,.55) 0 6%, transparent 18%),
    linear-gradient(180deg, #6b3fc4 0%, #9a74e0 45%, #c9b4f2 75%, #e6dcfa 100%);
  background-attachment: fixed;
  min-height: 100%;
}
.desk { position: relative; min-height: calc(100vh - var(--tb)); padding: 16px; padding-bottom: calc(var(--tb) + 16px); }

/* ===== Cửa sổ ===== */
.win {
  background: var(--xp-be);
  border: 1px solid var(--tim-dam);
  border-radius: 7px 7px 0 0;
  box-shadow: 2px 3px 10px rgba(20,0,50,.45);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.win[hidden] { display: none; }
.win-title {
  display: flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 3px 0 6px;
  background: linear-gradient(180deg, #b48bf2 0%, #7a3ad6 12%, #6528c4 50%, #5b22b0 88%, #4b1a96 100%);
  color: #fff; font-weight: bold; font-size: 12px;
  text-shadow: 1px 1px 0 #2a0b55;
  border-radius: 6px 6px 0 0;
  user-select: none; cursor: default; touch-action: none;
}
.win.inactive .win-title { background: linear-gradient(180deg, #cdb8ef, #9d82cf 50%, #8e72c4); text-shadow: none; }
.win-title img { width: 16px; height: 16px; }
.win-title span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btns { display: flex; gap: 2px; }
.win-btns button {
  width: 21px; height: 21px; padding: 0; cursor: pointer;
  border: 1px solid #fff; border-radius: 3px;
  background: linear-gradient(180deg, #a77ff0, #5b22b0);
  color: #fff; font: bold 11px/17px Tahoma, sans-serif;
}
.win-btns button.x { background: linear-gradient(180deg, #e98d72, #c13b1a); }
.win-btns button:hover { filter: brightness(1.15); }

.menubar { display: flex; gap: 0; white-space: nowrap; background: var(--xp-be); border-bottom: 1px solid #fff; box-shadow: 0 1px 0 var(--xp-vien); padding: 2px 3px; }
.menubar span { padding: 1px 5px; cursor: default; }
.menubar span:hover { background: var(--tim); color: #fff; }

.win-body { background: #fff; padding: 10px; flex: 1; overflow: auto; }

/* Nút xám kiểu XP */
.xp-btn {
  min-width: 72px; padding: 3px 10px; cursor: pointer;
  border: 1px solid #4b1a96; border-radius: 3px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f2ee 45%, #e3dfd6 100%);
  box-shadow: inset 0 -1px 0 #cfc9bb;
}
.xp-btn:hover { box-shadow: inset 0 0 0 2px #f6c46a; }
.xp-btn:active { background: linear-gradient(180deg, #e3dfd6, #f4f2ee); }
.xp-btn.primary { font-weight: bold; box-shadow: inset 0 0 0 1px #b48bf2; }
.xp-btn[disabled] { color: var(--xam); cursor: wait; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn-row.right { justify-content: flex-end; }
.center { text-align: center; margin-top: 6px; }

input:not([type=checkbox]), select, textarea {
  border: 1px solid #7f9db9; background: #fff; padding: 3px 4px; border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--tim-vua); }
textarea { resize: none; width: 100%; }

/* Thông báo */
.notice-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.notice-head svg { width: 40px; height: 40px; flex: 0 0 40px; }
.app-name { font-size: 15px; color: var(--tim); }
.notice p { margin: 6px 0; }
.notice .short { display: none; }
.steps { list-style: none; padding: 6px 8px; margin: 6px 0; background: var(--tim-nhat); border: 1px solid #d7c7f2; }
.steps li { padding: 2px 0; }
.steps b { color: var(--tim); }
.proof { color: var(--tim); font-weight: bold; }

/* Ảnh đại diện vuông */
.avatar { width: 40px; height: 40px; border: 1px solid #888; background: #fff; padding: 1px; flex: 0 0 auto; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar.big { width: 72px; height: 72px; }
.avatar.blank { background: linear-gradient(180deg, #e9e6f2, #cfc8e2); position: relative; overflow: hidden; }
.avatar.blank::before { content: ""; position: absolute; left: 50%; top: 18%; width: 38%; height: 38%; transform: translateX(-50%); border-radius: 50%; background: #9f94bd; }
.avatar.blank::after { content: ""; position: absolute; left: 50%; bottom: -22%; width: 74%; height: 50%; transform: translateX(-50%); border-radius: 50% 50% 0 0; background: #9f94bd; }

/* Đăng nhập */
.login { display: flex; flex-direction: column; align-items: center; background: linear-gradient(180deg, #fff 0%, #f1eafb 100%); }
.login form { width: 100%; max-width: 230px; margin-top: 8px; }
.login .row { display: block; margin-bottom: 6px; }
.login .row input { display: block; width: 100%; margin-top: 2px; }
.chk { display: flex; align-items: center; gap: 4px; margin: 2px 0; }
.links { text-align: center; margin-top: 8px; }
a { color: var(--link); }
.lg-msg { color: var(--do); text-align: center; min-height: 16px; margin: 4px 0 0; }

/* Tạo nick mới */
.form-body { background: var(--xp-be); }
.create-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.create-head p { margin: 0; }
fieldset { border: 1px solid #d0d0bf; border-radius: 4px; padding: 6px 10px 8px; margin: 0 0 8px; background: #fff; }
legend { color: var(--tim); font-weight: bold; padding: 0 3px; }
legend small, label small { font-weight: normal; color: var(--chu-phu); }
fieldset label { display: block; margin-top: 4px; }
fieldset input { width: 100%; margin-top: 2px; }
.hint { font-size: 11px; color: var(--chu-phu); min-height: 15px; }
.hint.ok { color: var(--xanh); font-weight: bold; }
.hint.err { color: var(--do); font-weight: bold; }
.msg { color: var(--do); font-weight: bold; margin: 4px 0 0; min-height: 16px; }
.ts { min-height: 66px; }

.done { text-align: center; }
.done svg { width: 56px; height: 56px; }
.done h2 { font-size: 15px; margin: 6px 0; color: var(--tim-dam); }
.nick-tag { display: inline-block; background: var(--tim-nhat); border: 1px dashed var(--tim); padding: 2px 10px; font-weight: bold; font-size: 15px; color: var(--tim); }
.share-box { text-align: left; border: 1px solid #7f9db9; padding: 6px 8px; margin: 4px 0 6px; background: #fffef2; }
.done .xp-btn { width: 100%; margin-top: 4px; }

/* Danh sách bạn */
.me { display: flex; gap: 6px; padding: 6px; background: linear-gradient(180deg, #fff, #f1eafb); border-bottom: 1px solid #d7c7f2; }
.me-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.me-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info select { font-size: 11px; padding: 0; }
.status-msg { font-size: 11px; font-style: italic; border-color: transparent !important; padding: 0 2px !important; }
.status-msg:hover, .status-msg:focus { border-color: #7f9db9 !important; }
.search { display: flex; gap: 3px; padding: 5px 6px; background: var(--xp-be); }
.search input { flex: 1; min-width: 0; }
.search .xp-btn { min-width: 0; padding: 2px 6px; }
.buddies { flex: 1; overflow: auto; background: #fff; padding: 3px 0; }
.grp { font-weight: bold; padding: 2px 6px; cursor: pointer; user-select: none; color: var(--tim-dam); }
.grp:hover { background: var(--tim-nhat); }
.grp .tri { display: inline-block; width: 12px; font-size: 9px; }
.grp .cnt { font-weight: normal; color: var(--chu-phu); }
.buddy { display: flex; align-items: center; gap: 5px; padding: 1px 6px 1px 20px; cursor: default; }
.buddy:hover { background: #e8ddfb; }
.buddy .st { position: relative; width: 16px; height: 16px; flex: 0 0 16px; }
.buddy .st svg { width: 16px; height: 16px; display: block; }
.buddy .st i { position: absolute; right: -3px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; border: 1px solid #fff; font: bold 7px/7px Tahoma; color: #fff; text-align: center; font-style: normal; }
.buddy .st i.ban { background: var(--do); }
.buddy .st i.vang { background: #e08a00; }
.buddy .st i.com { background: #1f8a3a; }
.buddy .nm { font-weight: bold; white-space: nowrap; }
.buddy .sm { color: var(--chu-phu); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.buddy.off .st svg { filter: grayscale(1); opacity: .45; }
.buddy.off .nm { font-weight: normal; color: var(--xam); }
.demo-note { font-size: 10px; color: var(--chu-phu); text-align: center; padding: 2px; background: var(--xp-be); border-top: 1px solid var(--xp-vien); }

/* Cửa sổ chat */
.win.chat { height: 380px; }
.chat-log { flex: 1; overflow: auto; background: #fff; margin: 4px 4px 0; border: 1px solid #7f9db9; padding: 6px; }
.chat-log p { margin: 0 0 3px; word-wrap: break-word; }
.chat-log .who-a { color: #b00; font-weight: bold; }
.chat-log .who-b { color: #1a3fb0; font-weight: bold; }
.chat-log .buzz-line { color: var(--do); font-weight: bold; font-size: 14px; }
.chat-log .sys { color: var(--chu-phu); font-style: italic; }
.chat-log svg.f { width: 18px; height: 18px; vertical-align: -4px; }
.toolbar { position: relative; display: flex; align-items: center; gap: 3px; padding: 3px 4px; background: var(--xp-be); }
.tool { border: 1px solid transparent; background: transparent; padding: 1px 4px; cursor: pointer; height: 24px; }
.tool:hover { border-color: #b8a8d8; background: #f6f1ff; }
.tool svg { width: 18px; height: 18px; display: block; }
.tool.buzz { font-weight: bold; color: var(--do); font-style: italic; }
.tool-sp { flex: 1; }
.face-pick { position: absolute; bottom: 28px; left: 4px; background: #fff; border: 1px solid var(--tim-dam); box-shadow: 2px 2px 6px rgba(0,0,0,.3); padding: 4px; display: grid; grid-template-columns: repeat(4, 28px); gap: 2px; z-index: 5; }
.face-pick[hidden] { display: none; }
.face-pick button { border: 1px solid transparent; background: none; padding: 2px; cursor: pointer; }
.face-pick button:hover { border-color: var(--tim); }
.face-pick svg { width: 22px; height: 22px; display: block; }
.chat-input { display: flex; gap: 4px; padding: 0 4px 4px; background: var(--xp-be); }
.chat-input textarea { flex: 1; height: 44px; }
.chat-input .xp-btn { min-width: 56px; }

.privacy { margin: 0; padding-left: 18px; }
.privacy li { margin-bottom: 4px; }
.dlg { display: flex; gap: 10px; align-items: center; }
.dlg svg { width: 36px; height: 36px; flex: 0 0 36px; }

/* Thanh tác vụ */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tb); z-index: 99999;
  display: flex; align-items: center; gap: 4px; padding: 0 0 0 0;
  background: linear-gradient(180deg, #8a5ae0 0%, #5b22b0 10%, #5122a4 85%, #3a1470 100%);
  border-top: 1px solid #b48bf2;
}
.start {
  height: 100%; display: flex; align-items: center; gap: 5px; padding: 0 16px 0 10px; cursor: pointer;
  border: 0; border-radius: 0 12px 12px 0; color: #fff; font: bold italic 15px Tahoma, sans-serif;
  text-shadow: 1px 1px 1px #224400;
  background: linear-gradient(180deg, #7fcf6f 0%, #3d9b33 15%, #2f8a28 85%, #1f6a1a 100%);
  box-shadow: inset -2px 0 3px rgba(0,0,0,.3);
}
.start img { width: 20px; height: 20px; }
.tasks { flex: 1; display: flex; gap: 3px; overflow: hidden; }
.task {
  max-width: 160px; min-width: 0; flex: 0 1 160px; height: 24px; padding: 0 8px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  border: 1px solid #3a1470; border-radius: 3px; color: #fff; text-align: left;
  background: linear-gradient(180deg, #9a6ae8, #6a2fc8);
}
.task img { width: 14px; height: 14px; }
.task span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.on { background: linear-gradient(180deg, #3f1385, #5b22b0); box-shadow: inset 1px 1px 2px rgba(0,0,0,.5); }
.tray { height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 12px; color: #fff; background: linear-gradient(180deg, #6d8fe8, #3c5ec9); border-left: 1px solid #22348a; background: linear-gradient(180deg, #8e6fe0, #4a2a9e); }
.tray a { color: #fff; font-size: 11px; }

.shake { animation: shake .5s; }
@keyframes shake {
  0%,100% { translate: 0 0; } 15% { translate: -8px 2px; } 30% { translate: 7px -3px; }
  45% { translate: -6px 3px; } 60% { translate: 5px -2px; } 75% { translate: -3px 1px; }
}
.flash input, input.flash { animation: flash 1.2s; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--vang); } }

/* ===== Màn hình rộng: cửa sổ đặt tự do như trên máy tính ===== */
@media (min-width: 1180px) {
  .desk { height: calc(100vh - var(--tb)); min-height: 660px; padding: 0; }
  .desk > .win { position: absolute; left: var(--x); top: var(--y); width: var(--w); max-height: calc(100% - var(--y) - 8px); }
  .desk > .win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; max-height: none; border-radius: 0; }
}
/* ===== Màn hình vừa: cửa sổ xếp hàng ===== */
@media (min-width: 761px) and (max-width: 1179px) {
  .desk { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
  .desk > .win { width: var(--w); max-width: 100%; }
  .desk > .win[data-win="taonick"] { order: -1; }
}
/* ===== Điện thoại: mỗi lần 1 cửa sổ chiếm toàn màn hình ===== */
@media (max-width: 760px) {
  .two { grid-template-columns: 1fr; gap: 0; }
  body { font-size: 13px; }
  input:not([type=checkbox]), select, textarea { font-size: 16px; }
  .desk { padding: 0; height: calc(100vh - var(--tb)); height: calc(100dvh - var(--tb)); min-height: 0; }
  .desk > .win { display: none; position: absolute; inset: 0; width: 100%; height: 100% !important; border-radius: 0; box-shadow: none; }
  .desk > .win.active:not([hidden]) { display: flex; }
  .win-title { height: 30px; border-radius: 0; }
  .win-btns button[data-act="max"] { display: none; }
  .notice .long { display: none; }
  .notice .short { display: inline; }
  .task { flex-basis: 110px; }
  .tray a { display: none; }
  .start { padding: 0 10px 0 8px; font-size: 13px; }
}

/* ===== Trang quản trị ===== */
.admin-wrap { padding: 16px; padding-bottom: 50px; }
.admin-wrap .win { margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #e3dcf2; vertical-align: top; }
th { background: var(--xp-be); position: sticky; top: 0; border-bottom: 1px solid var(--xp-vien); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stat { flex: 1 1 120px; background: var(--tim-nhat); border: 1px solid #d7c7f2; padding: 6px 8px; }
.stat b { display: block; font-size: 22px; color: var(--tim); }
.table-scroll { overflow-x: auto; max-height: 60vh; border: 1px solid #7f9db9; }
.field { margin-bottom: 8px; }
.field label { display: block; margin-bottom: 2px; }
.field input { width: 100%; }

/* Bổ sung theo bảng chấm */
.menubar u { text-decoration: underline; }
.bl-tools { display: flex; gap: 2px; padding: 2px 4px; background: var(--xp-be); border-top: 1px solid #fff; border-bottom: 1px solid var(--xp-vien); }
.bl-tools .tool { font-size: 11px; height: 20px; }
.chat-head { display: flex; gap: 6px; align-items: center; padding: 4px 6px; background: linear-gradient(180deg, #fff, #f1eafb); border-bottom: 1px solid #d7c7f2; }
.chat-head .avatar { width: 34px; height: 34px; }
.chat-head i { color: var(--chu-phu); font-size: 11px; }
.typing { font-size: 11px; color: var(--chu-phu); padding: 1px 6px; background: var(--xp-be); font-style: italic; }
.tool.fmt { min-width: 22px; font-family: "Times New Roman", serif; font-size: 13px; }
.tool.color span { font-weight: bold; border-bottom: 3px solid #c00; line-height: 12px; display: inline-block; }
.toast { position: fixed; right: 8px; bottom: calc(var(--tb) + 8px); width: 200px; z-index: 99998; background: #fff; border: 1px solid var(--tim-dam); border-radius: 6px 6px 0 0; box-shadow: 2px 3px 10px rgba(0,0,0,.4); overflow: hidden; animation: toastUp .4s ease-out; }
.toast[hidden] { display: none; }
.toast .win-title { height: 20px; font-size: 11px; }
.toast-body { display: flex; gap: 6px; align-items: center; padding: 8px; background: linear-gradient(180deg, #fff, #f1eafb); }
.toast-body svg { width: 28px; height: 28px; flex: 0 0 28px; }
@keyframes toastUp { from { transform: translateY(110%); } }

/* Menu thả xuống */
.menubar .menu { position: relative; }
.menubar .menu > span { display: inline-block; }
.menubar .menu.open > span { background: var(--tim); color: #fff; }
.drop { display: none; position: absolute; left: 0; top: 100%; z-index: 50; min-width: 190px; background: #fff; border: 1px solid #888; box-shadow: 2px 2px 4px rgba(0,0,0,.35); padding: 2px; }
.menu.open .drop { display: block; }
.drop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 3px 18px; cursor: default; white-space: nowrap; }
.drop button:hover { background: var(--tim); color: #fff; }
.drop hr { border: 0; border-top: 1px solid #c8c8c8; margin: 2px 0; }
body:not(.logged) .need-login { display: none !important; }

.list-view { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.list-view[hidden] { display: none; }
.login[hidden] { display: none; }
.seekers { margin: 4px 6px; padding: 5px 7px; background: #fffbd6; border: 1px solid #e3c94a; font-size: 11px; }
.seekers b { color: var(--do); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.small-links { text-align: right; margin: 6px 0 0; font-size: 11px; }
.install-link { margin-top: auto; display: flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--link); text-decoration: underline; cursor: pointer; padding: 10px 0 2px; font-size: 11px; }
.install-link svg { width: 16px; height: 16px; }
.login { padding-top: 14px; }
.install ol { padding-left: 20px; margin: 6px 0; }
.install li { margin-bottom: 8px; }
.install .shot { display: block; margin: 4px 0 0; border: 1px solid #aaa; background: #f3f3f3; padding: 4px 6px; font-size: 11px; border-radius: 3px; }
.install .shot .bar { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #ccc; border-radius: 10px; padding: 2px 8px; }
.install .shot .url { flex: 1; color: #555; }
.install .shot .ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 2px solid #c00; border-radius: 4px; }
.install h3 { font-size: 12px; margin: 10px 0 2px; color: var(--tim-dam); }
.win.tall { height: 620px; }

/* Ứng dụng đã cài (cửa sổ riêng): chỉ hiện cửa sổ chính, đầy khung */
@media (display-mode: standalone), (display-mode: window-controls-overlay) {
  .desktop-bg { background: var(--xp-be); }
}
body.single .desk { padding: 0; height: calc(100vh - var(--tb)); min-height: 0; display: block; }
body.single .desk > .win { display: none; position: absolute; inset: 0; left: 0; top: 0; width: 100%; height: 100% !important; max-height: none; border-radius: 0; box-shadow: none; }
body.single .desk > .win.active:not([hidden]) { display: flex; }
body.single .win-btns button[data-act="max"] { display: none; }
body.single .tray a { display: none; }

/* Điện thoại và app đã cài: bỏ thanh tác vụ cho rộng chỗ (đóng cửa sổ là về cửa sổ chính) */
@media (max-width: 760px) {
  :root { --tb: 0px; }
  .taskbar { display: none; }
  .win-btns button[data-act="min"] { display: none; }
  [data-win="main"] .win-btns button.x { display: none; }
  .toast { bottom: 8px; }
}
body.single { --tb: 0px; }
body.single .taskbar { display: none; }
body.single .win-btns button[data-act="min"], body.single [data-win="main"] .win-btns button.x { display: none; }
/* khung Turnstile không bị cắt */
.ts { overflow: visible; margin-bottom: 4px; }
/* Cửa sổ riêng của app đã cài: hệ điều hành đã có nút thu nhỏ/phóng to */
body.popup .win-btns button[data-act="min"], body.popup .win-btns button[data-act="max"] { display: none; }

/* App đã cài, chế độ "thanh tiêu đề riêng" (Window Controls Overlay):
   thanh tím kiểu cũ thay thanh của trình duyệt, nút _ □ × thật của Windows nằm bên phải */
@media (display-mode: window-controls-overlay) {
  body.single .desk > .win > .win-title {
    height: env(titlebar-area-height, 32px);
    padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 6px);
    border-radius: 0;
    -webkit-app-region: drag; app-region: drag;
  }
  body.single .desk > .win > .win-title .win-btns { display: none; }
}
/* Cửa sổ con của app đã cài: Windows đã có thanh tiêu đề -> bỏ thanh tím trùng */
body.app-popup .desk > .win > .win-title { display: none; }
body.app-popup .desk > .win { border-top: 0; }

/* Nút trạng thái gộp (biểu tượng + chữ + ▼) */
.status-pick { position: relative; }
.status-btn { display: flex; align-items: center; gap: 4px; width: 100%; padding: 1px 3px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; font-size: 11px; }
.status-btn:hover, .status-btn[aria-expanded="true"] { border-color: #7f9db9; background: #fff; }
.status-btn .st-ico { width: 16px; height: 16px; flex: 0 0 16px; }
.status-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
.status-btn .caret { font-size: 8px; color: #555; }
.status-menu { position: absolute; left: 0; top: 100%; z-index: 60; min-width: 100%; width: max-content; max-width: 240px; background: #fff; border: 1px solid #888; box-shadow: 2px 2px 4px rgba(0,0,0,.35); padding: 2px; }
.status-menu[hidden] { display: none; }
.status-menu button { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 3px 8px; text-align: left; cursor: default; font-size: 11px; }
.status-menu button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-menu button:hover { background: var(--tim); color: #fff; }
.status-menu .st-ico { width: 16px; height: 16px; flex: 0 0 16px; }
.status-menu .pen { width: 16px; text-align: center; }
.status-menu hr { border: 0; border-top: 1px solid #c8c8c8; margin: 2px 0; }
.status-edit[hidden] { display: none; }
.status-edit input:not([type=checkbox]) { width: 100%; font-size: 11px; }
.status-edit .chk { font-size: 10px; }
.me .avatar.dim svg { filter: grayscale(1); opacity: .5; }
.buddy .st .st-ico { width: 16px; height: 16px; display: block; }
@media (max-width: 760px) { .status-btn, .status-menu button { font-size: 14px; } .status-btn .st-ico, .status-menu .st-ico { width: 20px; height: 20px; flex-basis: 20px; } }

/* Bảng mặt cười nhiều hơn */
.face-pick { grid-template-columns: repeat(6, 30px); }
.face-pick svg { width: 24px; height: 24px; }

/* Menu chỉ hiện khi đã / chưa đăng nhập */
body:not(.logged) .need-in { display: none !important; }
body.logged .need-out { display: none !important; }

/* Danh sách bạn có nhóm */
.buddy[draggable="true"] { cursor: grab; }
.buddy.pending .sm { color: #b26a00; font-style: italic; }
.buddy .tag { white-space: nowrap; font-size: 9px; color: var(--tim); border: 1px solid #d7c7f2; border-radius: 3px; padding: 0 3px; background: var(--tim-nhat); }
.grp.drop-on { background: #fff3b0; outline: 1px dashed var(--tim); }
.ctx { position: fixed; z-index: 100000; min-width: 180px; background: #fff; border: 1px solid #888; box-shadow: 2px 2px 4px rgba(0,0,0,.35); padding: 2px; }
.ctx[hidden] { display: none; }
.ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 3px 14px; cursor: default; white-space: pre; font-size: 11px; }
.ctx button:hover:not([disabled]) { background: var(--tim); color: #fff; }
.ctx button[disabled] { color: #888; }
.ctx hr { border: 0; border-top: 1px solid #c8c8c8; margin: 2px 0; }
.radio-row { display: flex; gap: 12px; margin: 3px 0 0; }
.grp-pick { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.grp-pick select { width: 100%; }
.grp-pick input[hidden] { display: none; }
@media (max-width: 760px) { .ctx button { font-size: 14px; padding: 6px 14px; } .face-pick { grid-template-columns: repeat(6, 38px); } .face-pick svg { width: 30px; height: 30px; } }

/* ===== Chat thật ===== */
.buddy .unread { background: var(--do); color: #fff; border-radius: 8px; font-size: 10px; font-weight: bold; padding: 0 5px; line-height: 15px; }
.buddy .lock { font-size: 10px; }
.buddy.hidden-name .nm { font-style: italic; color: #666; }
.buddy.req { cursor: pointer; background: #fffbd6; }
.buddy.req:hover { background: #fff1a0; }
.grp.req-grp { color: var(--do); }
.buddy.room-row .nm { color: var(--tim-dam); }
.tag.ok { color: #fff; background: var(--xanh); border-color: var(--xanh); }
.task.flash { animation: taskFlash 1s steps(2) infinite; }
@keyframes taskFlash { 50% { background: linear-gradient(180deg, #ffb347, #e07a00); } }
.chat-head .avatar img, .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-who { min-width: 0; }
.c-status { display: inline-flex; align-items: center; gap: 3px; }
.st-ico.mini { width: 13px; height: 13px; }
.chat-log .warn { display: block; margin: 2px 0 4px 10px; padding: 3px 6px; background: #fff4cc; border: 1px solid #e3b400; color: #6b4a00; font-size: 11px; }
.chat-log .sys.err { color: var(--do); }
.chat-log .who-bot { color: #1a7f37; font-weight: bold; }
.tool.fmt.on { border-color: #b8a8d8; background: #e8ddfb; }
.req-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
/* Phòng chat */
.win.room { height: 460px; }
.room-topic { background: #fffbd6; border-bottom: 1px solid #e3c94a; padding: 3px 8px; font-size: 11px; }
.room-main { flex: 1; display: flex; min-height: 0; }
.room-left { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.room-members { width: 150px; border-left: 1px solid var(--xp-vien); background: #fff; display: flex; flex-direction: column; margin: 4px 4px 4px 0; border: 1px solid #7f9db9; }
.rm-head { background: var(--xp-be); padding: 2px 6px; font-weight: bold; font-size: 11px; }
.rm-list { flex: 1; overflow: auto; }
.rm-list .buddy { padding-left: 6px; cursor: default; }
.room-note { font-size: 10px; color: var(--chu-phu); }
@media (max-width: 760px) {
  .room-members { display: none; }
  .win.chat .toolbar .fmt, .win.chat .toolbar .color { display: none; }
}
body.popup .desk > .win.chat, body.popup .desk > .win.room { height: 100% !important; }

@media (max-width: 760px) { .toast { top: 8px; bottom: auto; right: 8px; left: 8px; width: auto; } }
.chk.agree { margin-top: 6px; }

.countdown { font-weight: bold; color: var(--do); margin: 4px 0; }
.countdown[hidden] { display: none; }
.link-btn { border: 0; background: none; color: var(--link); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; font-weight: bold; }
#pfVerify, #pfClaim { margin: 6px 0; }

#sk2Msg.default-msg { color: #888; font-style: italic; }
.c-as { font-size: 11px; max-width: 118px; margin-left: 4px; }
.toolbar .tool { white-space: nowrap; }
.c-as[hidden] { display: none; }
.who-alias { font-size: 9px; color: #888; font-weight: normal; }

.menu.open .drop { z-index: 100001; }

.grp.vault-grp { color: #7a1fa0; background: #f6eefc; }
.vault-close { font-size: 10px; margin-left: 6px; font-weight: normal; }
#skInput { font-size: 14px; letter-spacing: 2px; }

.room-pin { display: flex; align-items: flex-start; gap: 4px; background: #fff0c2; border-bottom: 1px solid #e3b400; padding: 4px 8px; font-size: 12px; font-weight: bold; color: #5a3a00; }
.room-pin[hidden] { display: none; }
.room-pin .pin-text { flex: 1; font-weight: normal; }
.room-pin svg.f { width: 16px; height: 16px; vertical-align: -3px; }
.pin-x { font-size: 10px; }

/* Nút con mắt cuối ô mật khẩu */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 28px !important; }
.pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 14px; padding: 0 4px; line-height: 1; opacity: .7; }
.pw-eye:hover { opacity: 1; }
.reset-box { background: #fff7d6; border: 1px solid #e3b400; padding: 8px; margin-bottom: 10px; }
.reset-box code { font-size: 16px; font-weight: bold; background: #fff; padding: 2px 8px; border: 1px solid #ccc; letter-spacing: 1px; }

.room-pins { border-bottom: 1px solid #e3b400; max-height: 110px; overflow: auto; }
.room-pins[hidden] { display: none; }
.room-pins .room-pin { border-bottom: 1px dashed #e8cf7a; }
.room-pins .room-pin:last-child { border-bottom: 0; }
.pin-admin { margin-top: 8px; }
.pin-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.pin-row input { flex: 1; }
.pin-done { color: #1a7f37; font-weight: bold; font-size: 11px; white-space: nowrap; }

.pin-admin .pin-row select { flex: 0 0 auto; }
#pinRows .pin-row { padding-left: 20px; }
a.pin-goto { font-size: 11px; color: #7a4a00; text-decoration: none; }
a.pin-goto:hover { text-decoration: underline; }

/* 2 nút nhỏ trên dòng tên nick: khoá chat, ẩn nick */
.buddy .row-acts { margin-left: auto; display: none; gap: 2px; flex: 0 0 auto; }
.buddy:hover .row-acts, .buddy:focus-within .row-acts { display: inline-flex; }
.buddy .ra { border: 1px solid transparent; background: none; cursor: pointer; padding: 0 3px; font-size: 12px; line-height: 16px; border-radius: 3px; }
.buddy .ra:hover { border-color: #b8a8d8; background: #fff; }
@media (max-width: 760px) { .buddy .row-acts { display: inline-flex; } .buddy .ra { font-size: 15px; padding: 2px 5px; } }
body.single .buddy .row-acts { display: inline-flex; }

/* ===== Kéo to / thu nhỏ cửa sổ (màn hình máy tính) – có kích thước nhỏ nhất ===== */
@media (min-width: 1180px) {
  .desk > .win { resize: both; min-width: 260px; min-height: 180px; max-width: calc(100vw - 8px); max-height: calc(100vh - var(--tb) - 8px); }
  .desk > .win[data-win="main"] { min-width: 240px; min-height: 420px; }
  .desk > .win[data-kind="chat"], .desk > .win[data-win="chat"] { min-width: 340px; min-height: 300px; }
  .desk > .win[data-kind="room"], .desk > .win[data-win="room"] { min-width: 480px; min-height: 340px; }
  .desk > .win.dialog { resize: none; }
  .desk > .win.max { resize: none; }
  /* góc kéo kiểu Windows */
  .desk > .win::after { content: ""; position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; pointer-events: none;
    background: linear-gradient(135deg, transparent 0 45%, #9a8fb5 45% 52%, transparent 52% 62%, #9a8fb5 62% 69%, transparent 69% 79%, #9a8fb5 79% 86%, transparent 86%); }
  .desk > .win.dialog::after, .desk > .win.max::after { display: none; }
  .desk > .win > .win-body, .desk > .win > .list-view, .desk > .win > .chat-log, .desk > .win .room-main { min-height: 0; }
}

.buddy .sm.room-cd { color: #c00000; font-style: normal; font-weight: bold; }

/* Nhóm chat */
.cb-list { max-height: 260px; overflow: auto; border: 1px solid #7f9db9; background: #fff; padding: 2px 0; }
.cb-list label { display: flex; align-items: center; gap: 6px; padding: 2px 6px; cursor: pointer; }
.cb-list label:hover { background: var(--tim-nhat); }
.grp.groups-grp { color: #1a5c9e; }
.buddy.group-row .nm { color: #1a5c9e; }
.grp .grp-add { font-size: 10px; margin-left: 6px; font-weight: normal; }
.rm-list .role { font-size: 9px; border-radius: 3px; padding: 0 3px; color: #fff; }
.rm-list .role.owner { background: #c07a00; }
.rm-list .role.deputy { background: #5b22b0; }

.pin-head { display: flex; gap: 6px; margin: 8px 0 2px 20px; font-size: 11px; font-weight: bold; color: var(--chu-phu); }
.pin-head span:first-child, .pin-room { flex: 0 0 150px; width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-room { font-weight: bold; color: var(--tim-dam); }

/* Bảng phòng trong trang quản trị: không chồng chữ */
#roomRows td { vertical-align: top; }
#roomRows input[data-rn], #roomRows input[data-rt] { width: 100%; min-width: 110px; }
#roomRows input[type=time] { width: 90px; }
#roomRows input[type=datetime-local] { width: 185px; display: block; }
#roomRows [data-ropennow] { margin-top: 3px; }
#roomRows td:nth-child(5) { min-width: 195px; }
#roomRows td:nth-child(6) { min-width: 120px; }
#nrTime { width: 90px; }
#nrOpen { width: 190px; }

/* Thanh gạt bật / tắt phòng */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: #c9c3d6; border-radius: 22px; transition: .2s; border: 1px solid #9a8fb5; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: #1a9a46; border-color: #137a37; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.sw-txt { font-size: 11px; margin-left: 2px; }
.sw-txt.on { color: #1a7f37; } .sw-txt.off { color: #888; }
/* chia độ rộng cột bảng phòng */
#roomRows { }
table:has(#roomRows) { table-layout: fixed; }
table:has(#roomRows) th:nth-child(1) { width: 15%; }
table:has(#roomRows) th:nth-child(2) { width: 22%; }
table:has(#roomRows) th:nth-child(3) { width: 175px; }
table:has(#roomRows) th:nth-child(4) { width: 80px; }
table:has(#roomRows) th:nth-child(5) { width: 205px; }
table:has(#roomRows) th:nth-child(6) { width: 140px; }
table:has(#roomRows) th:nth-child(7) { width: 60px; }
#roomRows td:nth-child(5), #roomRows td:nth-child(6) { min-width: 0; }
#roomRows td:nth-child(6) a.pin-goto { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#roomRows select { max-width: 72px; }

/* Thông báo chung: chữ xanh lá nháy nhẹ */
.ann-bar { display: flex; align-items: center; gap: 4px; background: #effbe9; border-bottom: 1px solid #9fd38a; padding: 3px 8px; font-size: 12px; }
.ann-bar[hidden] { display: none; }
.ann-bar .ann-text { flex: 1; color: #138a2e; font-weight: bold; animation: annBlink 2.4s ease-in-out infinite; }
.ann-main { margin: 4px 6px 0; border: 1px solid #9fd38a; }
@keyframes annBlink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* Lời nhắn gửi trước khi người ấy nhận lời */
.chat-log .sys.held { display: block; color: #1a5c9e; background: #eef5ff; border: 1px dashed #9cb9e0; padding: 3px 6px; margin: 2px 0; font-style: normal; }

/* Trang quản trị: gộp lời nhắn chờ */
.m-group { cursor: pointer; background: #f6f1ff; }
.m-group:hover { background: #ece2ff; }
.m-count { display: inline-block; background: #5b22b0; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; margin-right: 4px; }
.m-child td:nth-child(3) { padding-left: 14px; }
