:root {
  /* Tông xanh lá: đậm (khung, nút chính), nhạt (điểm nhấn), xanh trắng (nền) */
  --ok: #2f8a4f;
  --tab-on: #b9e6c6;
  --ink: #1b4d35;
  --ink-2: #215c40;
  --ink-3: #2c6e4e;
  --paper: #f2f9f4;
  --paper-2: #e0f0e5;
  --card: #ffffff;
  --line: #cde3d4;
  --text: #173126;
  --muted: #5b7366;
  --gold: #9ad8ac;
  --gold-2: #cdf0d7;
  --red: #b23b2a;
  --mine: #d8efdf;
  --mine-line: #b3dcbf;
  --lv1: #8a918c; --lv2: #4f8a5b; --lv3: #2f7f7a; --lv4: #7a4fa0; --lv5: #a2412f; --lv6: #b8892c;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --serif: "Noto Serif", Georgia, serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--text); background: var(--ink); font-size: 15px; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
.hidden { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───── Khung ứng dụng: điện thoại là chính, máy tính thì canh giữa ───── */
.app, .login { position: fixed; inset: 0; max-width: 480px; margin: 0 auto; }
@media (min-width: 520px) { body { background: #0f2c1e; } .app, .login { box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0,0,0,.5); } }

/* ───── Đăng nhập ───── */
.login { display: grid; place-items: center; padding: 24px; background:
  radial-gradient(120% 70% at 50% 0%, #2d7350 0%, var(--ink) 62%); }
.login-card { width: 100%; max-width: 340px; color: var(--paper); text-align: center; }
.seal { width: 64px; height: 64px; margin: 0 auto 14px; display: grid; place-items: center;
  color: var(--ink); background: var(--gold); border-radius: 12px; box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 5px var(--gold-2); transform: rotate(-4deg); }
.seal.red { background: var(--red); color: #fff3e6; box-shadow: inset 0 0 0 3px #fff3e6; }
.login h1 { font-family: var(--serif); font-size: 30px; margin: 0; letter-spacing: .5px; color: var(--gold-2); }
.login-sub { margin: 6px 0 22px; color: #b5d6c0; font-size: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--ink-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.seg-btn { background: none; border: 0; padding: 10px; border-radius: 9px; color: #b5d6c0; font-weight: 600; }
.seg-btn.active { background: var(--ink-3); color: var(--gold-2); }
#login-form { display: grid; gap: 12px; text-align: left; }
#login-form label { display: grid; gap: 6px; font-size: 13px; color: #cfe6d6; font-weight: 500; }
#login-form input { background: var(--ink-2); border: 1px solid var(--ink-3); border-radius: 12px; padding: 13px 14px; color: #fff; font-size: 16px; outline: none; }
#login-form input:focus { border-color: var(--gold); }
#l-pin, #l-pin2 { letter-spacing: 6px; }
.form-err { min-height: 18px; margin: 0; color: #f0a08c; font-size: 13px; }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; background: var(--paper-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-block { width: 100%; padding: 14px; font-size: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ───── Thanh tab trên cùng ───── */
.app { display: flex; flex-direction: column; background: var(--paper); border: 1px solid #000; }
.tabbar { flex-shrink: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; padding: 6px 5px; padding-top: max(6px, env(safe-area-inset-top)); background: var(--ink); position: relative; z-index: 2; }
.tab-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 54px; border: 0; border-radius: 10px; background: transparent; color: #e6f4ea; font-size: 11.5px; font-weight: 600; padding: 7px 1px; white-space: nowrap; transition: background .15s, color .15s; }
.tab-btn svg { width: 22px; height: 22px; stroke-width: 1.6; }
.tab-btn:active { background: rgba(255,255,255,.06); }
.tab-btn.active { background: var(--tab-on); color: var(--ink); }
.tab-btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.tab-ic { position: relative; display: grid; place-items: center; }
.tab-dot { position: absolute; top: -2px; right: -5px; width: 9px; height: 9px; border-radius: 50%; background: #e0563d; box-shadow: 0 0 0 2px var(--ink); }
.tab-btn.active .tab-dot { box-shadow: 0 0 0 2px var(--tab-on); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat-head { flex-shrink: 0; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.icon-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: inherit; flex-shrink: 0; }
.icon-btn:active { background: rgba(0,0,0,.06); }
.icon-btn.sm { width: 34px; height: 34px; }
.room-head { flex: 1; min-width: 0; }
.room-title { font-family: var(--serif); font-weight: 700; font-size: 16.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #cfe6d6; padding: 0 4px; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: #7ee39a; }
.tk-right { position: absolute; right: 0; top: 0; bottom: 0; display: flex; align-items: center; gap: 2px; padding: 0 4px 0 18px; background: linear-gradient(90deg, transparent, var(--ink-2) 16px); }
.bell { width: 34px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: #e6f4ea; padding: 0; }
.bell svg { width: 17px; height: 17px; stroke-width: 1.7; }
.bell:active { background: rgba(255,255,255,.1); }
.bell.off { color: #8fb39c; opacity: .75; }

/* ───── Dải thông báo chạy ───── */
.ticker { flex-shrink: 0; background: var(--ink-2); color: #d3ecd9; font-size: 11px; height: 28px; overflow: hidden; position: relative; border-bottom: 1px solid #163f2b; }
.ticker-track { position: absolute; top: 0; left: 0; white-space: nowrap; line-height: 28px; padding-left: 100%; letter-spacing: .1px; animation: tick linear infinite; animation-duration: var(--dur, 30s); }
.ticker-track b { color: #87b597; font-weight: 400; margin: 0 12px; }
.ticker-track.idle { animation: none; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* ───── Luồng tin nhắn ───── */
.feed { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 10px 6px; background:
  linear-gradient(var(--paper), var(--paper)), repeating-linear-gradient(0deg, transparent 0 22px, rgba(0,0,0,.015) 22px 23px); }
.older { display: block; margin: 4px auto 10px; border: 0; background: var(--paper-2); color: var(--muted); font-size: 12.5px; padding: 6px 12px; border-radius: 99px; }
.messages { display: flex; flex-direction: column; gap: 2px; }
.day { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--paper-2); padding: 3px 10px; border-radius: 99px; margin: 10px 0 6px; }
.sys { align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--red); background: #f7e4dc; border: 1px solid #ecc6b8; padding: 6px 10px; border-radius: 10px; margin: 6px 0; }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 8px; padding: 5px 2px; }
.msg.cont { padding-top: 0; }
.msg.cont .avw, .msg.cont .meta { visibility: hidden; height: 0; }
.av { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--paper-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; border: 0; padding: 0; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 3px; }
.name { font-weight: 600; font-size: 13.5px; color: var(--text); background: none; border: 0; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; text-align: left; }
.time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.bubble { justify-self: start; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 8px 11px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.cont .bubble { border-radius: 14px; }
.msg.mine { grid-template-columns: 1fr; justify-items: end; }
.msg.mine .avw { display: none; }
.msg.mine .meta { justify-content: flex-end; }
.msg.mine .bubble { background: var(--mine); border-color: var(--mine-line); border-radius: 14px 4px 14px 14px; justify-self: end; }
.msg.mine.cont .bubble { border-radius: 14px; }
.bubble.deleted { color: var(--muted); font-style: italic; background: transparent; }
.bubble a { color: #2c6a8f; }


.new-pill { position: absolute; left: 50%; bottom: calc(76px + var(--safe-b)); z-index: 3; transform: translateX(-50%); border: 0; background: var(--ink); color: var(--gold-2); padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* ───── Khung soạn tin ───── */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 130px; border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 10px 14px; font-size: 16px; line-height: 1.35; outline: none; }
.composer textarea:focus { border-color: var(--gold); }
.send-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; flex-shrink: 0; }
.send-btn svg { fill: currentColor; stroke-width: 1.2; }
.send-btn:disabled { opacity: .45; }
.readonly-bar { padding: 12px 14px calc(12px + var(--safe-b)); background: var(--paper-2); border-top: 1px solid var(--line); text-align: center; font-size: 13.5px; color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(8,14,10,.55); z-index: 20; }
.lock { font-size: 12px; opacity: .8; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #e0563d; color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.stone { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; }

/* ───── Các màn danh sách (Cá nhân, Phòng, Thư viện) ───── */
.panel { overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px calc(24px + var(--safe-b)); gap: 8px; }
.sec { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 2px 4px; font-size: 12px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sec:first-child { margin-top: 2px; }
.sec .btn { text-transform: none; letter-spacing: 0; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; background: none; text-align: left; font-size: 15px; color: var(--text); min-height: 58px; }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: var(--paper); }
.item .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.item .ic svg { width: 19px; height: 19px; }
.item .ic img { width: 100%; height: 100%; object-fit: cover; }
.item .ic .av { width: 38px; height: 38px; border-radius: 10px; }
.item .lbl { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .lbl small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.item.locked .lbl { color: var(--muted); }
.item.locked .ic { background: var(--paper-2); color: var(--muted); }
.item .chev { color: var(--line); width: 18px; height: 18px; flex-shrink: 0; }
.item .tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--paper-2); color: var(--muted); flex-shrink: 0; }
.empty { padding: 14px; font-size: 13.5px; color: var(--muted); text-align: center; line-height: 1.5; }

.me-card { background: var(--ink); color: var(--paper); border-radius: 16px; padding: 16px; display: grid; gap: 14px; }
.me-row { display: flex; gap: 14px; align-items: center; }
.me-row .av { width: 60px; height: 60px; border-radius: 16px; font-size: 24px; }
.me-name { font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--gold-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-user { font-size: 12.5px; color: #93a69a; margin: 1px 0 6px; }
.me-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--ink-2); border-radius: 11px; padding: 9px 11px; font-size: 12px; color: #93a69a; }
.stat b { display: flex; align-items: center; gap: 6px; font-size: 17px; color: var(--paper); margin-top: 2px; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--ink-3); border-radius: 9px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 9px; }
.prog-text { font-size: 12px; color: #93a69a; margin-top: 6px; }
.me-card .btn { background: var(--ink-3); color: var(--gold-2); }

/* ───── Bảng trượt từ dưới ───── */
#sheet-scrim { z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; max-height: 88vh; background: var(--paper); border-radius: 18px 18px 0 0; z-index: 31; transform: translateY(105%); transition: transform .22s ease; display: flex; flex-direction: column; }
.sheet.open { transform: none; }
.sheet-grip { width: 38px; height: 4px; border-radius: 9px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 18px; }
.sheet-head h2 { font-family: var(--serif); font-size: 18px; margin: 0; }
.sheet-body { overflow-y: auto; padding: 4px 18px calc(20px + var(--safe-b)); display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #4b574f; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 11px 12px; font-size: 16px; font-weight: 400; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--gold); }
.field small { font-weight: 400; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.err { color: var(--red); font-size: 13px; margin: 0; min-height: 0; }
.profile-top { display: flex; gap: 14px; align-items: center; }
.profile-top .av { width: 72px; height: 72px; border-radius: 18px; font-size: 28px; }
.profile-top .pname { font-family: var(--serif); font-size: 20px; font-weight: 700; }
.profile-top .puser { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.list { display: grid; gap: 8px; }
.li { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.li .av { width: 34px; height: 34px; border-radius: 9px; }
.li .btn { padding: 7px 12px; font-size: 13px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tab { border: 0; background: var(--paper-2); padding: 7px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tab.active { background: var(--ink); color: var(--gold-2); }
.mini { font-size: 12px; padding: 5px 9px !important; border-radius: 8px !important; }
.log { font-size: 12.5px; line-height: 1.5; border-bottom: 1px dashed var(--line); padding: 6px 0; }

/* ───── Thông báo nổi ───── */
.toast { position: fixed; left: 50%; top: calc(78px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 50; max-width: min(92vw, 420px); background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 26px rgba(0,0,0,.3); border-left: 3px solid var(--gold); animation: pop .18s ease; }
.toast.warn { border-left-color: #e0563d; background: #3a1e18; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -6px); } }
.kicked { position: fixed; inset: 0; z-index: 60; background: rgba(8,14,10,.92); display: grid; place-items: center; padding: 24px; }
.kicked-card { background: var(--paper); border-radius: 18px; padding: 24px; max-width: 340px; text-align: center; }
.kicked-card p { line-height: 1.5; }


/* ───── Phòng, thư viện ───── */
.sec-actions { display: flex; gap: 6px; }
.foot-note { margin: 6px 4px 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.code-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; background: var(--card); border: 1px dashed var(--gold); border-radius: 12px; padding: 10px 12px; }
.code-box small { display: block; font-size: 11.5px; color: var(--muted); }
.code-box b { font-family: var(--serif); font-size: 22px; letter-spacing: 5px; }
.code-box .hint { font-size: 12px; }

/* ───── Kệ tài liệu: cuộn ngang trong phòng riêng ───── */
.shelf { flex-shrink: 0; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.shelf-head { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--text); text-align: left; }
.shelf-head small { flex: 1; font-weight: 400; color: var(--muted); }
.shelf-head svg { width: 16px; height: 16px; color: var(--muted); }
.shelf-track { display: flex; gap: 8px; overflow-x: auto; padding: 0 14px 10px; scroll-padding-inline: 14px; scroll-snap-type: x proximity; scrollbar-width: none; }
.shelf-track::-webkit-scrollbar { display: none; }
.slot { flex: 0 0 82px; height: 82px; scroll-snap-align: start; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; position: relative; overflow: hidden; }
.slot.filled { background: var(--card); border: 1px solid var(--line); }
.slot.filled img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot.filled img + .slot-t { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(10,16,12,.8)); color: #fff; padding: 12px 6px 5px; }
.slot-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; }
.slot-ic svg { width: 17px; height: 17px; }
.slot-t { font-size: 11px; line-height: 1.25; font-weight: 600; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; width: 100%; }
.slot.empty-slot { background: transparent; border: 1.5px dashed #9fcdb0; color: var(--muted); }
.slot.empty-slot:active { background: var(--card); }
.plus { font-size: 26px; line-height: 1; font-weight: 300; color: #4f9a6c; }
.pick3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; font-size: 13px; font-weight: 600; }
.pick svg { width: 24px; height: 24px; color: var(--ink-3); }
.pick:active { background: var(--paper-2); }
.doc-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.doc-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14.5px; line-height: 1.6; max-height: 50vh; overflow-y: auto; }

.field > * { min-width: 0; width: 100%; }
.field input[type=file] { font-size: 14px; padding: 9px; }
.sheet-body > * { min-width: 0; }

.seal svg { width: 36px; height: 36px; stroke: var(--ink); stroke-width: 1.6; }
.seal.red svg { stroke: #fff3e6; }

/* ───── Ảnh đại diện: sao (cấp 1–4), chấm đỏ (Chấp sự 1, Admin 2) ───── */
.avw { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; padding: 0; flex-shrink: 0; }
.stars { font-size: 8.5px; line-height: 1; letter-spacing: -.5px; color: #c49a3a; white-space: nowrap; }
.rdots { display: inline-flex; gap: 3px; line-height: 1; }
.rdots i { width: 6px; height: 6px; border-radius: 50%; background: #d63b2b; display: block; }
.msg .avw { margin-top: 2px; }
.item .ic:has(.avw) { background: none; overflow: visible; }
.item .ic .stars, .item .ic .rdots { display: none; }
.lv-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: var(--paper-2); color: var(--text); }
.lt-stars { color: #b8892c; font-size: 11px; letter-spacing: -.5px; }

/* ───── Tình trạng phòng ───── */
.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; vertical-align: 1px; }
.s-green { background: #3fa45b; } .s-yellow { background: #e0b12e; } .s-red { background: #d63b2b; }
.r-name { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.legend { display: flex; gap: 14px; margin: 8px 4px 0; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.alerts { display: grid; gap: 8px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid; }
.alert .grow { flex: 1; min-width: 0; }
.alert b { display: block; font-size: 14px; }
.alert small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.al-yellow { background: #fbf2d3; border-color: #ead48a; }
.al-red { background: #f9e1dc; border-color: #ebb5a9; }

/* ───── Ví ───── */
.stat-btn { border: 0; text-align: left; color: #93a69a; font: inherit; font-size: 12px; cursor: pointer; }
.stat-btn.open { box-shadow: inset 0 0 0 1px var(--gold); }
.stat-l { display: flex; align-items: center; justify-content: space-between; }
.stat-l svg { width: 14px; height: 14px; }
.wallet { background: var(--ink-2); border-radius: 12px; overflow: hidden; }
.w-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; background: none; color: var(--paper); text-align: left; font-size: 14px; font-weight: 600; }
.w-row + .w-row { border-top: 1px solid var(--ink-3); }
.w-row svg { width: 20px; height: 20px; color: var(--gold-2); flex-shrink: 0; }
.w-row > span:not(.tag) { flex: 1; min-width: 0; }
.w-row small { display: block; font-weight: 400; font-size: 12px; color: #93a69a; margin-top: 1px; }
.w-row .tag { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--ink-3); color: var(--gold-2); }
.w-hist { border-top: 1px solid var(--ink-3); padding: 10px 12px 12px; display: grid; gap: 8px; }
.w-hist-t { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #6f8577; }
.w-tx { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #dfe6e1; }
.w-tx .grow { flex: 1; min-width: 0; }
.w-tx small { display: block; font-size: 11px; color: #7f9487; }
.w-tx b { font-variant-numeric: tabular-nums; }
.w-tx b.plus { color: #7ed39a; } .w-tx b.minus { color: #f0a08c; }
.w-empty { font-size: 12.5px; color: #7f9487; }
.me-note { margin: -4px 0 0; font-size: 11.5px; color: #7f9487; }
.confirm-box { display: grid; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: 15px; }
.confirm-box .stone { width: 20px; height: 20px; }
.warn-hint { color: #8a5a10; background: #fbf2d3; border-radius: 10px; padding: 10px 12px; }

/* ───── Giải trí ───── */
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.game-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: left; min-height: 120px; }
.game-card:active { background: var(--paper-2); }
.game-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; }
.game-name { font-weight: 600; font-size: 14.5px; flex: 1; }
.game-empty { border: 1.5px dashed #9fcdb0; background: transparent; align-items: center; justify-content: center; color: var(--muted); }
.game-empty .game-name { flex: 0; font-weight: 500; font-size: 13px; }
.game-card .tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--paper-2); color: var(--muted); }

.panel > * { flex-shrink: 0; }

.shelf-bar { display: flex; align-items: center; padding-right: 10px; }
.shelf-bar .shelf-head { flex: 1; }
.ro-item { padding: 8px 6px 8px 10px; }
.ro-num { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0; }
.ro-item .icon-btn { color: var(--text); }
.ro-item .icon-btn:disabled { opacity: .25; }

/* ───── Báo cáo, rút tiền, công tắc ───── */
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reason { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 12px; font-size: 13.5px; }
.reason.on { background: var(--red); border-color: var(--red); color: #fff; }
.quote { font-size: 13px; background: var(--paper-2); border-left: 3px solid var(--line); padding: 7px 10px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.report-card { display: grid; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.report-card input { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 15px; width: 100%; }
.rp-items { display: grid; gap: 8px; font-size: 13px; }
.rp-item .s { font-size: 12px; color: var(--muted); }
.tag-red { background: #f9e1dc; color: var(--red); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; }
.toggle-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px; text-align: left; font-weight: 600; font-size: 14px; }
.toggle-row > span:first-child { flex: 1; }
.toggle-row small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { width: 42px; height: 24px; border-radius: 99px; background: #c4d6ca; position: relative; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(18px); }

/* ───── Logo, tạo tài khoản ───── */
.logo { display: block; width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 22px; box-shadow: 0 0 0 1px rgba(226,194,122,.25), 0 10px 30px rgba(0,0,0,.45); }
.form-ok { margin: 0; color: #8fdca6; font-size: 14px; font-weight: 600; }

/* ───── Đính kèm trong chat ───── */
.attach-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--paper-2); color: var(--text); display: grid; place-items: center; flex-shrink: 0; }
.attach-btn svg { width: 21px; height: 21px; }
.bubble.media { padding: 4px; background: var(--card); }
.bubble.media img { display: block; max-width: min(240px, 100%); max-height: 260px; border-radius: 10px; cursor: zoom-in; }
.bubble.media .cap { padding: 6px 7px 3px; }
.filecard { display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 280px; padding: 4px 2px; text-align: left; border: 0; background: none; cursor: pointer; }
.filecard .fic { width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--gold-2); display: grid; place-items: center; flex-shrink: 0; }
.filecard .fic svg { width: 20px; height: 20px; }
.filecard .fn { flex: 1; min-width: 0; }
.filecard .fn b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filecard .fn small { display: block; font-size: 12px; color: var(--muted); }
.price-chip { flex-shrink: 0; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: #f4e6bf; color: #6b4f0e; white-space: nowrap; }
.price-chip.free { background: #dcefe0; color: #1f6a3a; }
.price-chip.own { background: var(--paper-2); color: var(--muted); }
.viewer-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }

/* ───── Admin xem theo vai ───── */
.viewas-bar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #3a2a06; color: #f3dca0; font-size: 12.5px; }
.viewas-bar b { flex: 1; font-weight: 600; }
.viewas-bar button { border: 0; background: var(--gold); color: var(--ink); font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 99px; }
.roles { display: flex; flex-wrap: wrap; gap: 6px; }
.roles button { border: 1px solid var(--ink-3); background: var(--ink-2); color: #dfe6e1; border-radius: 99px; padding: 6px 11px; font-size: 12.5px; }
.roles button.on { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 700; }
.bubble .cap { font-size: 14px; }
.pick small { display: block; font-size: 11.5px; }

/* ───── Tổng quan ban quản trị ───── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { display: grid; gap: 2px; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile small { font-size: 12px; color: var(--muted); }
.tile.warn { background: #fbf2d3; border-color: #ead48a; }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-strip > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-strip b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-strip small { font-size: 12px; color: var(--muted); }
.stat-strip .warn { background: #fbf2d3; border-color: #ead48a; }
.s-off { background: #b9b4a6; }

/* ───── Bản 2: điểm, ghim phòng, sách, phong chức ───── */
.topup-note { font-size: 11px; color: var(--muted); opacity: .55; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pin-wrap { position: relative; }
.pin-wrap + .pin-wrap { border-top: 1px solid var(--line); }
.pin-wrap .item { padding-right: 56px; }
.pin-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: #a7c2b1; display: grid; place-items: center; }
.pin-btn svg { width: 19px; height: 19px; }
.pin-btn.on { color: var(--ink); background: var(--paper-2); }
.book-desc { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; padding: 10px 12px; max-height: 40vh; overflow-y: auto; }
.earn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.earn b { display: block; font-size: 14.5px; color: var(--ink); margin-bottom: 4px; }
.earn p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text); }
.cat-li .grow input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 15px; background: var(--paper); }
.role-box { display: grid; gap: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.role-box select, .role-box input { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.pin-wrap .item > svg { display: none; }
