/*!
 * Fomo! Messenger — giao diện. © 2026 Fomo! Messenger (ndhgrp.com). Bảo lưu mọi quyền.
 */
:root {
  --title-a: #7b3fa0;
  --title-b: #4b1f6f;
  --panel: #f2eef6;
  --line: #b9a6c9;
  --accent: #6a2c91;
  font-family: Tahoma, Verdana, "Segoe UI", sans-serif;
  font-size: 13px;
}
* { box-sizing: border-box; }
body { margin: 0; background: #d9d2e0; color: #1d1226; min-height: 100vh; }
.hidden { display: none !important; }

.win { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 2px 3px 0 rgba(75, 31, 111, .25); overflow: hidden; display: flex; flex-direction: column; }
.titlebar { background: linear-gradient(var(--title-a), var(--title-b)); color: #fff; padding: 5px 8px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.body { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }

.login { max-width: 360px; margin: 10vh auto 0; }
.login label { display: flex; flex-direction: column; gap: 4px; }
.notice { margin: 0; padding: 6px 8px; background: #fff3cd; border: 1px solid #e0c36a; border-radius: 4px; }

input, select, button { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
button { background: linear-gradient(#fff, #e6dcee); cursor: pointer; }
button:hover:not(:disabled) { background: #efe5f6; }
button:disabled { opacity: .5; cursor: default; }
button.tiny { padding: 1px 6px; font-size: 11px; }

.app { display: grid; grid-template-columns: 260px 1fr; gap: 10px; padding: 10px; height: 100vh; }
.buddy { height: calc(100vh - 20px); }
.chat { height: calc(100vh - 20px); }
@media (max-width: 700px) { .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .buddy { height: auto; max-height: 40vh; } .chat { height: auto; } }

.mystatus { display: flex; flex-direction: column; gap: 4px; }
#rooms { overflow-y: auto; flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 3px; }
.group-h { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; background: #e6dcee; cursor: pointer; font-weight: bold; border-bottom: 1px solid var(--line); }
.group-h.active { background: #cbb3dd; }
.badge { background: #d33; color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 6px; }
.member { display: flex; justify-content: space-between; align-items: center; padding: 2px 6px 2px 18px; }
.member.off { color: #8b8394; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #aaa; }
.dot.online { background: #2fae3f; } .dot.busy { background: #d33; } .dot.away { background: #e9a21b; }
.mtext { color: #6d6479; font-size: 11px; margin-left: 4px; }
.snd { font-size: 12px; }
.redeem { display: flex; gap: 4px; } .redeem input { flex: 1; min-width: 0; }

.disclaimer { margin: 0; font-size: 11px; color: #6d5a00; background: #fff8d6; border: 1px solid #e3d48a; padding: 3px 6px; border-radius: 3px; }
.messages { flex: 1; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 6px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.line { word-break: break-word; }
.line .t { color: #8b8394; font-size: 11px; margin-right: 4px; }
.line .n { font-weight: bold; color: #1f5fb4; } .line.mine .n { color: #b4281f; }
.line.sys { color: #7a6f86; font-style: italic; }
.ticker { background: #ece2f4; border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; font-weight: bold; color: var(--accent); }
.typing { min-height: 16px; color: #7a6f86; font-size: 11px; }
.send { display: flex; gap: 6px; } .send input { flex: 1; }

/* BUZZ! shake */
@keyframes buzz { 0%,100% { transform: translate(0,0); } 10% { transform: translate(-9px,3px); } 20% { transform: translate(8px,-4px); } 30% { transform: translate(-8px,-3px); } 40% { transform: translate(7px,4px); } 50% { transform: translate(-6px,2px); } 60% { transform: translate(5px,-2px); } 70% { transform: translate(-4px,3px); } 80% { transform: translate(3px,-2px); } 90% { transform: translate(-2px,1px); } }
.shake { animation: buzz .7s linear; }
@media (prefers-reduced-motion: reduce) { .shake { animation: none; outline: 3px solid #d33; } }

/* ---------- admin panel ---------- */
.adminpage .admin { max-width: 980px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.adminpage .login { margin-top: 12vh; }
.adminpage .stats { font-weight: normal; font-size: 12px; flex: 1; text-align: center; }
.adminpage .win { overflow: visible; }
.adminpage table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.adminpage th, .adminpage td { text-align: left; padding: 5px 7px; border-bottom: 1px solid #e3daea; vertical-align: middle; }
.adminpage th { background: #e6dcee; font-size: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: inline-flex; gap: 3px; align-items: center; }
.row input[type="number"] { width: 64px; }
.linkbox { word-break: break-all; font-family: Consolas, monospace; font-size: 12px; }
.muted { color: #8b8394; }
button.danger { color: #a3221a; border-color: #d9a29d; }
.badge { margin-left: 6px; }

/* ---------- Yahoo-style polish ---------- */
body { background: linear-gradient(#e9e3f0, #cfc4dc); }
.titlebar { background: linear-gradient(#9a5bc2, #7b3fa0 45%, #4b1f6f); text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.logo { color: #ffd23f; font-size: 17px; font-style: italic; font-weight: 900; letter-spacing: -.5px; margin-right: 2px; text-shadow: 1px 1px 0 #4b1f6f; }
@media (min-width: 701px) {
  .app { max-width: 1000px; margin: 0 auto; height: auto; align-items: start; padding-top: 2vh; }
  .buddy, .chat { height: min(720px, calc(96vh - 20px)); }
}

.me { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.av { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 6px; color: #fff; font-weight: bold; font-size: 20px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); flex: none; }
.av.sm { width: 18px; height: 18px; font-size: 11px; border-width: 1px; border-radius: 3px; box-shadow: none; }
.a0 { background: #d9534f; } .a1 { background: #e8912d; } .a2 { background: #c9a400; } .a3 { background: #3c9a4d; }
.a4 { background: #2a9d9d; } .a5 { background: #3b78c4; } .a6 { background: #7b3fa0; } .a7 { background: #c0488e; }

.group-h { background: linear-gradient(#f0e8f6, #d9c9e6); }
.arrow { width: 14px; cursor: pointer; user-select: none; }
.glabel { flex: 1; }
.member { padding: 3px 6px 3px 12px; border-bottom: 1px dotted #eadff2; }
.mleft { display: flex; align-items: center; gap: 5px; min-width: 0; }
.mname { font-weight: bold; }
.member.off .mname { font-weight: normal; }
.member.off .av { filter: grayscale(1); opacity: .6; }
.si { font-size: 13px; width: 16px; text-align: center; }
.mtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { font-size: 14px; line-height: 1.45; }
.line { padding: 1px 0; }
.line .n.u0 { color: #c62828; } .line .n.u1 { color: #d9731a; } .line .n.u2 { color: #8a7600; } .line .n.u3 { color: #2e7d32; }
.line .n.u4 { color: #00797a; } .line .n.u5 { color: #1f5fb4; } .line .n.u6 { color: #6a2c91; } .line .n.u7 { color: #ad1457; }
.line.sys { background: #f6f1fa; border-left: 3px solid var(--accent); padding-left: 6px; }
.emo-i { font-size: 18px; line-height: 1; vertical-align: -2px; }

.toolbar { display: flex; gap: 6px; }
.tool { padding: 3px 10px; font-weight: bold; }
.tool.buzz { color: #8a1c14; }
.emo { display: block; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 4px; max-height: 168px; overflow-y: auto; }
.emo-tabs { display: flex; gap: 4px; margin-bottom: 4px; position: sticky; top: -4px; background: #fff; padding: 2px 0; z-index: 1; }
.emo-tab { padding: 3px 12px; font-weight: bold; border-radius: 3px; }
.emo-tab.on { background: #6b2c91; color: #fff; border-color: #6b2c91; }
.emo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px; }
.emo-grid.big { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.emo-grid.big .emo-b .fi { width: 46px; height: 46px; }
.emo-b { font-size: 20px; padding: 2px 0; line-height: 1.2; background: transparent; border-color: transparent; }
.emo-b:hover { background: #efe5f6; border-color: var(--line); }
.send input { padding: 6px 8px; }
@media (min-width: 701px) { .send input { font-size: 14px; } }

/* ---------- send button, mobile fixed layout ---------- */
.send { align-items: center; }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; padding: 0; border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sendbtn:hover:not(:disabled) { background: #5a2380; }
.sendbtn:disabled { background: #b9a6c9; opacity: 1; }
.tbtns { display: inline-flex; gap: 6px; }
.mobile-only { display: none; }

@media (max-width: 700px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  input, select, button, textarea { font-size: 16px; }          /* 16px+ stops iOS zooming the page on focus */
  .mobile-only { display: inline-block; }
  .app { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100dvh); display: block; padding: 0; }
  .chat { height: 100%; border-radius: 0; border: 0; box-shadow: none; }
  .chat .body { padding: 6px; gap: 6px; }
  .disclaimer { font-size: 11px; }
  .emo { max-height: 26%; flex: none; }
  .buddy { display: none; position: absolute; inset: 0; z-index: 5; height: auto; max-height: none; border-radius: 0; border: 0; box-shadow: none; }
  body.buddy-open .buddy { display: flex; }
  .login { margin: 4vh 10px 0; max-width: none; }
}

/* ---------- open access ---------- */
.pub { border: 1px solid var(--line); background: #fff; border-radius: 3px; max-height: 32%; overflow-y: auto; flex: none; }
.pub .member { justify-content: space-between; padding-left: 8px; }
#guest-form { display: flex; flex-direction: column; gap: 8px; }
#guest-form details { font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
#guest-form details input { width: 100%; margin: 6px 0; }
#recovery { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; font-size: 12px; }
#recovery.hidden { display: none; }

/* ---------- member kind tags ---------- */
.tag { display: inline-block; font-size: 10px; line-height: 14px; padding: 0 6px; border-radius: 8px; border: 1px solid; white-space: nowrap; font-weight: normal; font-style: normal; vertical-align: 1px; }
.tag.guest { background: #fff0e0; color: #9a5200; border-color: #e8b878; }
.tag.member { background: #e4f4e6; color: #1f6b2c; border-color: #9fd0a6; }
.line .tag { margin-right: 4px; }
.mwho { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.member.off .tag { opacity: .6; }

/* ---------- touch targets ---------- */
button, summary, .group-h, .member button { touch-action: manipulation; -webkit-tap-highlight-color: rgba(106, 44, 145, .25); } /* no double-tap delay, no swallowed taps on iOS */
@media (max-width: 700px) {
  .titlebar { min-height: 56px; padding: 6px 10px; }
  #chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; font-size: 16px; }
  /* icon-only buttons on the purple bar: no white box, just a big tap area */
  .titlebar button.tiny { min-width: 48px; min-height: 48px; padding: 0; font-size: 22px; line-height: 1; background: transparent; border: 0; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
  .titlebar button.tiny:active { background: rgba(255,255,255,.2); border-radius: 8px; }
  #btn-buddy { font-size: 26px; }
  .member button.tiny, .pub button.tiny { min-height: 36px; min-width: 56px; }
  .group-h { min-height: 44px; }
  .arrow { width: 28px; text-align: center; }
}

/* message actions, quotes, private chat tools */
.line { position: relative; }
.acts { display: none; margin-left: 8px; white-space: nowrap; }
.line:hover .acts, .line.sel .acts { display: inline; }
.act { background: transparent; border: 0; padding: 0 6px; font-size: 16px; line-height: 1; cursor: pointer; min-height: 28px; min-width: 28px; }
.quote { display: block; margin: 2px 0; padding: 2px 8px; border-left: 3px solid #b99ad1; background: #f3ecf9; color: #5a4a6b; font-size: .92em; border-radius: 0 3px 3px 0; }
.member.active { background: #efe5f6; }

.fi.st { width: 2.8em; height: 2.8em; vertical-align: -.9em; }

/* compact kind badge (app only; admin keeps full text) */
.tag.ic { width: 18px; height: 18px; padding: 0; line-height: 16px; text-align: center; border-radius: 50%; font-size: 11px; cursor: pointer; vertical-align: middle; flex: none; }
.tag.ic.open { width: auto; padding: 0 8px 0 4px; border-radius: 9px; }
.tag.ic.open::after { content: ' ' attr(data-label); font-size: 10px; }
.line .tag.ic { margin-right: 6px; }
.mwho { flex-direction: row; align-items: center; gap: 5px; }
.mname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* funny badge: tiny FOMO Emoji, still until hovered */
.tag.ic { width: 22px; height: 22px; line-height: 0; border: 0; background: none; overflow: visible; }
.tag.ic .fi { width: 22px; height: 22px; vertical-align: top; }
.tag.ic .fi, .tag.ic .fi * { animation: none !important; }
.tag.ic:hover .fi.roll, .tag.ic.open .fi.roll { animation: fi-roll .9s ease-in-out infinite !important; }
.tag.ic:hover .fi .k1, .tag.ic.open .fi .k1 { animation: fi-k1 .35s ease-in-out infinite !important; }
.tag.ic:hover .fi .k2, .tag.ic.open .fi .k2 { animation: fi-k2 .35s ease-in-out infinite !important; }
.tag.ic.open { width: auto; display: inline-flex; align-items: center; gap: 3px; padding: 0 8px 0 0; border: 1px solid; border-radius: 11px; line-height: 20px; height: 22px; }
.tag.ic.open .fi { width: 20px; height: 20px; }
.tag.ic.guest.open { background: #fff0e0; color: #9a5200; border-color: #e8b878; }
.tag.ic.member.open { background: #e4f4e6; color: #1f6b2c; border-color: #9fd0a6; }
.tag.ic.member { width: 18px; height: 18px; line-height: 16px; border: 1px solid #9fd0a6; background: #e4f4e6; color: #1f6b2c; border-radius: 50%; text-align: center; font-size: 11px; }
.tag.ic.member.open { width: auto; height: 20px; padding: 0 8px 0 4px; border-radius: 10px; }

/* room members: 💬 and BUZZ line up in two columns */
#rooms .member.mrow { display: grid; grid-template-columns: minmax(0, 1fr) 30px; column-gap: 4px; align-items: center; justify-content: stretch; }
#rooms .member.mrow > .mleft { grid-column: 1; }
#rooms .member.mrow > button { width: 100%; min-width: 0; padding-left: 0; padding-right: 0; justify-self: stretch; }
@media (max-width: 700px) { #rooms .member.mrow { grid-template-columns: minmax(0, 1fr) 44px; column-gap: 8px; } }

/* badge label is a floating bubble under the icon: it never pushes or hides the name */
.tag.ic, .tag.ic.open, .tag.ic.guest.open, .tag.ic.member.open { position: relative; display: inline-block; }
.tag.ic.guest, .tag.ic.guest.open { width: 22px; height: 22px; padding: 0; border: 0; background: none; border-radius: 0; }
.tag.ic.member, .tag.ic.member.open { width: 18px; height: 18px; padding: 0; line-height: 16px; border: 1px solid #9fd0a6; background: #e4f4e6; border-radius: 50%; }
.tag.ic.open::after { position: absolute; top: calc(100% + 4px); left: -4px; z-index: 20; white-space: nowrap; content: attr(data-label); padding: 3px 10px; font-size: 12px; line-height: 16px; font-weight: bold; border: 1px solid; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.tag.ic.guest.open::after { background: #fff0e0; color: #9a5200; border-color: #e8b878; }
.tag.ic.member.open::after { background: #e4f4e6; color: #1f6b2c; border-color: #9fd0a6; }

/* floating label bubble (replaces the old ::after) */
.tag.ic.open::after { content: none; }
.tagpop { position: fixed; z-index: 50; white-space: nowrap; padding: 4px 12px; font-size: 13px; line-height: 18px; font-weight: bold; border: 1px solid; border-radius: 12px; box-shadow: 0 3px 10px rgba(0,0,0,.25); pointer-events: none; }
.tagpop.hidden { display: none; }
.tagpop.guest { background: #fff0e0; color: #9a5200; border-color: #e8b878; }
.tagpop.member { background: #e4f4e6; color: #1f6b2c; border-color: #9fd0a6; }

/* moderator menu */
.modmenu { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3); padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 210px; }
.modmenu.hidden { display: none; }
.modtitle { font-weight: bold; padding: 4px 8px; color: #4b1f6f; border-bottom: 1px solid #eadff2; }
.moditem { text-align: left; background: transparent; border: 0; padding: 8px 10px; font-size: 14px; border-radius: 6px; cursor: pointer; }
.moditem:hover, .moditem:active { background: #efe5f6; }
.moditem.danger { color: #a01818; }

/* long member names slide left on hover / tap */
.mname > span { display: inline-block; transition: transform 1.4s linear; }
.mname.run { text-overflow: clip; }
.mname.run > span { transform: translateX(var(--d, 0)); }
@media (prefers-reduced-motion: reduce) { .mname > span { transition: none; } }

.modsep { height: 1px; background: var(--line); margin: 3px 2px; }
.namepop { position: fixed; z-index: 55; max-width: min(92vw, 360px); padding: 5px 10px; font-size: 14px; font-weight: bold; background: #fff; color: #1a1030; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 12px rgba(0,0,0,.3); pointer-events: none; }
.namepop.hidden { display: none; }

/* gender icons: FOMO Emoji faces, same 22px size as the kind badge */
.gd { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; line-height: 0; flex: none; vertical-align: middle; }
.gd .fi { width: 22px; height: 22px; vertical-align: top; }
.gd .fi, .gd .fi * { animation: none !important; }
.gd:hover .fi { animation: fi-bob .6s ease-in-out infinite !important; }
.line .gd { margin-right: 6px; }
.gpick { border: 0; padding: 0; margin: 6px 0; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.gpick legend { padding: 0; font-size: 12px; margin-bottom: 3px; }
.gpick label { display: inline-flex; align-items: center; gap: 4px; }
.me { display: flex; align-items: center; gap: 6px; }
.gsel { margin-left: auto; display: inline-flex; gap: 3px; }
.gsel .tiny { width: 30px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.gsel .tiny.on { background: #cfc0e6; border-color: #7a4fb0; }
.gsel .gd, .gsel .gd .fi { width: 20px; height: 20px; }

/* ticker pills carry the trend when the feed is on */
.ticker.up { background: #dcf7e5; border-color: #1fa855; color: #12743a; }
.ticker.down { background: #ffe1e1; border-color: #d33; color: #a31515; }
.ticker.base { background: #fff3d1; border-color: #d6a21a; color: #8a6200; }
.ticker.flat { background: #ececf2; border-color: #a9a3b8; color: #5b5470; }

/* unread rooms in the public list: red bold name + count */
#public-list .mname.unread { color: #d33; }
#public-list .badge { margin-left: auto; margin-right: 6px; flex: none; }

a.ticker { text-decoration: none; cursor: pointer; }
a.ticker:hover { filter: brightness(.95); text-decoration: none; }

/* pinned room announcement */
.pinbox { margin: 0 0 6px; padding: 7px 10px; border: 1px solid #e0a82e; border-left: 4px solid #e0a82e; background: #fff6d6; color: #5a3d00; border-radius: 4px; font-size: 14px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow: auto; }
.adminpage textarea { width: 100%; box-sizing: border-box; font: inherit; }
.maxin { width: 12em; }

/* admin: feedback stays visible while scrolled, and the saved cap is shown next to its button */
.adminpage #a-msg { position: sticky; top: 8px; z-index: 30; box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.maxstatus { color: #12743a; }

#rec-new { position: sticky; top: 8px; z-index: 31; }

.chip { display: inline-flex; align-items: center; gap: 2px; background: #ece2f4; border: 1px solid var(--line); border-radius: 10px; padding: 1px 4px 1px 8px; margin: 0 4px 2px 0; }

#tr-status.bad { background: #ffe1e1; border-color: #d33; color: #7a1010; }

a.weblink { color: #1a5fd0; text-decoration: underline; overflow-wrap: anywhere; word-break: break-all; }

/* =====================================================================
   Giao diện hiện đại (body.modern): phẳng, nhiều khoảng thở, 3 cột
   Phòng | Chat | Đang online. Chỉ đổi giao diện, không đổi hành vi.
   ===================================================================== */
.modern {
  --panel: #ffffff; --line: #e7e4f2; --accent: #5b3fe0;
  --ink: #1b1730; --muted: #5f5b78; --ground: #f4f3fa;
  font-family: "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; background: var(--ground); color: var(--ink);
}
.modern .win { border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(27, 23, 48, .04), 0 8px 24px rgba(27, 23, 48, .06); }
.modern .titlebar { background: var(--accent); text-shadow: none; padding: 14px 18px; font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.modern .logo { color: #fff; font-style: normal; font-weight: 800; text-shadow: none; font-size: 18px; letter-spacing: -.02em; }
.modern .logo::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ffd23f; margin-left: 3px; vertical-align: 2px; }
.modern .body { padding: 14px; gap: 12px; }
.modern input, .modern select, .modern button { border-color: #d5d0ea; border-radius: 10px; padding: 8px 11px; color: var(--ink); }
.modern input::placeholder { color: #6b6785; }
.modern input:focus-visible, .modern select:focus-visible, .modern button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.modern button { background: #fff; }
.modern button:hover:not(:disabled) { background: #f4f3fa; }
.modern button.tiny { padding: 3px 9px; border-radius: 8px; }
.modern .titlebar button.tiny { background: rgba(255, 255, 255, .16); border: 0; color: #fff; }
.modern .titlebar button.tiny:hover { background: rgba(255, 255, 255, .28); }
.modern .notice { border-radius: 12px; }
.modern .disclaimer { background: #fff6df; border: 1px solid #f3dda3; color: #5c3c07; border-radius: 12px; padding: 8px 12px; font-size: 12.5px; line-height: 1.5; }

/* desktop: 3 columns */
@media (min-width: 701px) {
  .modern .app { max-width: 1480px; grid-template-columns: 300px minmax(0, 1fr) 280px; gap: 14px; padding: 16px; height: 100vh; align-items: stretch; margin: 0 auto; }
  .modern .sidewrap { display: contents; }
  .modern .buddy, .modern .chat, .modern .online { height: calc(100vh - 32px); }
  .modern .buddy { order: 1; } .modern .chat { order: 2; } .modern .online { order: 3; }
}

/* left: profile + public rooms */
.modern .me { padding: 10px 12px; background: var(--ground); border-radius: 14px; font-size: 15px; }
.modern .me .av { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.modern .mystatus select, .modern .mystatus input { width: 100%; }
.modern .pub { flex: 1; max-height: none; border: 0; background: transparent; border-radius: 0; overflow-y: auto; min-height: 120px; }
.modern .pub .group-h { background: transparent; border: 0; cursor: default; padding: 6px 8px 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.modern #public-list .member { padding: 8px 10px; border: 0; border-radius: 12px; gap: 8px; }
.modern #public-list .member:hover { background: var(--ground); }
.modern #public-list .member.active { background: #efebff; }
.modern #public-list .mname { font-weight: 600; white-space: normal; }
.modern #public-list .mname.unread { color: #d6293e; font-weight: 700; }
.modern #public-list .member button { background: #efebff; border-color: transparent; color: #3f27b8; font-weight: 600; }
.modern #public-list .member button:hover { background: #e2dcff; }
.modern .badge { background: #d6293e; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.modern .snd { color: var(--muted); }
.modern .redeem input { border-style: dashed; }

/* right: who is online */
.modern .online { background: #fff; }
.modern #rooms { border: 0; background: transparent; border-radius: 0; padding: 10px; overflow-y: auto; flex: 1; }
.modern #rooms .group-h { background: transparent; border: 0; cursor: default; padding: 8px 10px 10px; font-size: 15px; font-weight: 700; color: var(--ink); justify-content: flex-start; gap: 8px; }
.modern #rooms .member { border: 0; border-radius: 12px; padding: 7px 10px; }
.modern #rooms .member:hover { background: var(--ground); }
.modern .av { border: 0; box-shadow: none; border-radius: 12px; }
.modern .av.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 10px; }

/* chat: bubbles on a soft ground */
.modern .chat { background: var(--ground); }
.modern .chat .body { padding: 14px 18px; }
.modern .messages { background: transparent; border: 0; padding: 4px 0; gap: 10px; font-size: 14.5px; line-height: 1.5; }
.modern .line { align-self: flex-start; max-width: min(78%, 640px); background: #fff; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 8px 14px 9px; display: flow-root; }
.modern .line.mine { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 16px 4px 16px 16px; }
.modern .line .t { float: right; margin: 2px 0 0 12px; font-size: 11px; color: var(--muted); }
.modern .line.mine .t { color: rgba(255, 255, 255, .78); }
.modern .line .n { font-weight: 700; }
.modern .line.mine .n { color: #fff; }
.modern .line.mine a.weblink { color: #fff; }
.modern .line.mine .quote { background: rgba(255, 255, 255, .16); border-left-color: rgba(255, 255, 255, .6); color: #fff; }
.modern .line.sys { align-self: center; max-width: 90%; background: #eae7f5; border: 0; border-radius: 999px; padding: 3px 14px; font-style: normal; font-size: 12.5px; color: var(--muted); text-align: center; }
.modern .quote { border-radius: 0 8px 8px 0; }
.modern .ticker { border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.modern .pinbox { border-radius: 14px; border: 1px solid #f3dda3; border-left: 4px solid #e0a82e; }
.modern .typing { color: var(--muted); padding-left: 2px; }
.modern .toolbar { gap: 8px; flex-wrap: wrap; }
.modern .tool { border-radius: 10px; font-weight: 600; padding: 6px 12px; }
.modern .tool.buzz { background: #fff0d9; border-color: transparent; color: #7a3f06; }
.modern .tool.buzz:hover:not(:disabled) { background: #ffe5bf; }
.modern .send { background: #fff; border: 1px solid #d5d0ea; border-radius: 18px; padding: 6px 6px 6px 8px; gap: 8px; }
.modern .send input { border: 0; outline: 0; background: transparent; font-size: 14.5px; padding: 8px 8px; }
.modern .send:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 63, 224, .14); }
.modern .sendbtn { width: 42px; height: 42px; border-radius: 13px; }
.modern .sendbtn:hover:not(:disabled) { background: #4a30c4; }
.modern .sendbtn:disabled { background: #c9c3e6; }
.modern .emo { border-radius: 14px; }
.modern .modmenu, .modern .namepop { border-radius: 14px; }

/* login card */
.modern .login { max-width: 400px; }
.modern .login .titlebar { border-radius: 0; }

/* phone: Home overlay = profile + rooms + online, scrollable */
@media (max-width: 700px) {
  .modern .titlebar { min-height: 60px; padding: 8px 14px; }
  .modern .titlebar button.tiny { background: transparent; }
  .modern .win { border-radius: 0; box-shadow: none; }
  .modern .sidewrap { display: none; }
  body.modern.buddy-open .sidewrap { display: flex; flex-direction: column; position: absolute; inset: 0; z-index: 5; overflow-y: auto; background: var(--ground); gap: 10px; padding-bottom: 12px; }
  .modern .buddy { display: flex; position: static; inset: auto; height: auto; max-height: none; z-index: auto; border-radius: 0; flex: none; }
  .modern .online { flex: none; margin: 0 10px; border-radius: 16px; }
  .modern #rooms { max-height: none; overflow: visible; }
  .modern .pub { min-height: 0; max-height: none; overflow: visible; }
  .modern .chat .body { padding: 8px 10px; }
  .modern .line { max-width: 88%; }
  #btn-buddy { font-size: 24px; }
}
.modern .sendbtn { background: var(--accent); color: #fff; border: 0; }
.modern .sendbtn:hover:not(:disabled) { background: #4a30c4; }
.modern .sendbtn:disabled { background: #c9c3e6; }
.modern a.weblink { word-break: normal; overflow-wrap: anywhere; }

/* emoticon picker: no frame around each icon, no sideways scroll */
.modern .emo { overflow-x: hidden; }
.modern .emo-b { border: 0; background: transparent; padding: 2px 0; border-radius: 10px; min-width: 0; }
.modern .emo-b:hover:not(:disabled) { background: #efebff; }
.modern .emo-tab { border-radius: 10px; }
.modern .emo-tab.on { background: var(--accent); border-color: var(--accent); }

/* "Đang online" header is a purple bar like the other panels */
.modern #rooms { padding: 0 0 10px; }
.modern #rooms .group-h { background: var(--accent); color: #fff; padding: 14px 18px; font-size: 15px; margin-bottom: 8px; }
.modern #rooms .member { margin: 0 10px; }

/* end-to-end encryption notes */
.e2ebar { margin: 0; padding: 6px 12px; border-radius: 12px; background: #e3f6ec; border: 1px solid #b6e3c9; color: #0b4f2b; font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.line .lg { margin-left: 8px; font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: #fff0d9; color: #8a4b08; white-space: nowrap; }
.line.locked { opacity: .75; font-style: italic; }

/* sidebar: Kênh (read-only, open to all) above Phòng chat */
.modern .pub .group-h.sec { padding-top: 12px; }
.modern .pub .group-h.sec:first-child { padding-top: 4px; }
.modern #public-list .member.chan .mname { color: #8a4b08; }
.modern #public-list .member.chan .mname.unread { color: #d6293e; }
.modern #public-list .member.chan button { background: #fff0d9; color: #7a3f06; }
.modern #public-list .member.chan button:hover { background: #ffe5bf; }

/* public list rows are the buttons now */
.modern #public-list .member.clickable { cursor: pointer; }
.modern #public-list .member.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.modern #public-list .mfull { margin-left: auto; font-size: 11px; color: var(--muted); }
.modern #public-list .member .badge { margin-left: auto; }

/* channel = reading page: article cards, no sender */
.modern #messages.reader { align-items: center; gap: 14px; padding: 20px 16px; }
.modern #messages.reader .line.post { align-self: center; width: min(100%, 760px); max-width: 760px; box-sizing: border-box; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 22px 18px; }
.modern .line.post .pdate { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); margin-bottom: 8px; }
.modern .line.post .pbody { font-size: 16px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink, #1b1730); }
.modern #messages.reader .line.sys { align-self: center; }
#fd-status { white-space: pre-line; }

/* =====================================================================
   Giao diện tối (body.modern.dark): bật bằng nút 🌙/☀️, nhớ trong trình duyệt;
   chưa chọn thì theo cài đặt của thiết bị.
   ===================================================================== */
body.modern.dark {
  color-scheme: dark;
  --panel: #1c1930; --line: #2f2a4a; --accent: #6d58ee;
  --ink: #ece9f8; --muted: #a8a3c4; --ground: #13111f;
}
.dark .win { box-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); }
.dark.modern input, .dark.modern select, .dark.modern button { background: #26223e; border-color: #3a3560; color: var(--ink); }
.dark.modern button:hover:not(:disabled) { background: #302b4e; }
.dark.modern input::placeholder { color: #8e89ab; }
.dark.modern .titlebar button.tiny { background: rgba(255, 255, 255, .16); color: #fff; }
.dark.modern .disclaimer { background: #2e2610; border-color: #5a4818; color: #f1d9a0; }
.dark.modern .notice { background: #3a3014; border-color: #7a6420; color: #f1d9a0; }
.dark.modern .online { background: var(--panel); }
.dark.modern #public-list .member:hover, .dark.modern #rooms .member:hover { background: #25203d; }
.dark.modern #public-list .member.active, .dark.modern .member.active { background: #2a2450; }
.dark.modern #public-list .mname.unread { color: #ff6b7d; }
.dark.modern #public-list .member.chan .mname { color: #f2b361; }
.dark.modern #public-list .member.chan .mname.unread { color: #ff6b7d; }
.dark.modern .mtext { color: var(--muted); }
.dark.modern .member.off { color: #7e799a; }
.dark.modern .line { background: #221e3a; border-color: var(--line); }
.dark.modern .line.mine { background: var(--accent); border-color: var(--accent); color: #fff; }
.dark.modern .line.sys { background: #2a2548; color: var(--muted); }
.dark.modern .line .n.u0 { color: #ff8a80; } .dark.modern .line .n.u1 { color: #ffb061; } .dark.modern .line .n.u2 { color: #e2c64a; } .dark.modern .line .n.u3 { color: #7bd48a; }
.dark.modern .line .n.u4 { color: #4fd1d1; } .dark.modern .line .n.u5 { color: #7db4ff; } .dark.modern .line .n.u6 { color: #c39bff; } .dark.modern .line .n.u7 { color: #ff8ec4; }
.dark.modern .line.mine .n { color: #fff; }
.dark.modern .line:not(.mine) .quote { background: #2a2548; border-left-color: #7a63c8; color: #cfc8ea; }
.dark.modern .line .lg { background: #3a2a14; color: #ffc98a; }
.dark.modern .ticker { background: #2a2548; border-color: var(--line); color: #b9a8ff; }
.dark.modern .ticker.up { background: #12351f; border-color: #1fa855; color: #6fe3a0; }
.dark.modern .ticker.down { background: #3a1518; border-color: #d33; color: #ff9a9a; }
.dark.modern .ticker.base { background: #3a2d0c; border-color: #d6a21a; color: #f2c75c; }
.dark.modern .ticker.flat { background: #2a2840; border-color: #5b5470; color: #c0bad8; }
.dark.modern a.weblink { color: #8ab4ff; }
.dark.modern .line.mine a.weblink { color: #fff; }
.dark.modern .pinbox { background: #2e2610; border-color: #5a4818; border-left-color: #e0a82e; color: #f1d9a0; }
.dark.modern .tool.buzz { background: #3a2a14; color: #ffc98a; }
.dark.modern .tool.buzz:hover:not(:disabled) { background: #4a3419; }
.dark.modern .send { background: #1f1b36; border-color: #3a3560; }
.dark.modern .send input { background: transparent; border: 0; }
.dark.modern .sendbtn { background: var(--accent); color: #fff; border: 0; }
.dark.modern .sendbtn:hover:not(:disabled) { background: #5b46dc; }
.dark.modern .sendbtn:disabled { background: #3a3560; }
.dark.modern .emo, .dark.modern .emo-tabs { background: #1f1b36; }
.dark.modern .emo-b { background: transparent; }
.dark.modern .emo-b:hover:not(:disabled) { background: #2a2548; }
.dark.modern .emo-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dark.modern .modmenu, .dark.modern .namepop { background: #26223e; color: var(--ink); border-color: #3a3560; }
.dark.modern .modtitle { color: #c3b5ff; border-bottom-color: #3a3560; }
.dark.modern .moditem { background: transparent; }
.dark.modern .moditem:hover, .dark.modern .moditem:active { background: #302b4e; }
.dark.modern .moditem.danger { color: #ff8a8a; }
.dark.modern .e2ebar { background: #10301f; border-color: #1f6b45; color: #8be0b2; }
.dark.modern #messages.reader .line.post { background: #1f1b36; border-color: var(--line); }
.dark.modern .gsel .tiny.on { background: #3b3270; border-color: #6d58ee; }
.dark.modern .tagpop { box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.btn-theme { font-size: 14px; }

/* admin rooms table: group rows */
.adminpage tr.grp td { background: #d9c9e6; font-weight: bold; padding: 6px 8px; letter-spacing: .02em; }

/* Bánh bao stickers have a caption above: taller viewBox */
.fi.st.bn { width: 3.3em; height: 3.3em; vertical-align: -1.1em; }
.emo-grid.big .emo-b .fi.bn { width: 50px; height: 50px; }

