:root {
    --blue: #3390ec;
    --blue-dark: #2a7fd6;
    --blue-soft: rgba(51, 144, 236, .1);
    --text: #000;
    --text-2: #707579;
    --border: #dfe1e5;
    --hover: #f4f4f5;
    --danger: #e53935;
    --own: #eeffde;
    --own-meta: #4fae4e;
    --in-meta: #a1aab3;
    --online: #0ac630;
    --pill: rgba(64, 98, 60, .42);
    --shadow-sm: 0 1px 2px rgba(16, 35, 47, .15);
    --shadow: 0 6px 24px rgba(0, 0, 0, .16);
    --sidebar: 420px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 15px/1.4 var(--font); color: var(--text); background: #fff; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; }
ul { list-style: none; }
.ic { width: 24px; height: 24px; flex-shrink: 0; }
.ic.inline { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.accent { color: var(--blue) !important; }
.muted { color: var(--text-2); font-weight: 400; }

.sb-body, .scroller, .ip-scroll, .modal-body, .emoji-panel, .drawer-items { scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .18) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 10px;
    background: var(--blue); color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none !important;
    transition: background .15s, opacity .15s, box-shadow .15s; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .55; }
.btn .ic { width: 20px; height: 20px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 14px; border-radius: 8px; gap: 6px; }
.btn.sm .ic { width: 16px; height: 16px; }
.btn.lg { height: 54px; font-size: 16px; border-radius: 12px; }
.btn.block { display: flex; width: 100%; }
.btn.outline { background: transparent; color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue); }
.btn.outline:hover { background: var(--blue-soft); }
.btn.text { background: transparent; color: var(--blue); }
.btn.text:hover { background: var(--blue-soft); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c62828; }
.btn.green { background: #34a853; }
.btn.green:hover { background: #2b8f46; }
.btn.orange { background: #f29b30; }
.btn.orange:hover { background: #d9861f; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; color: var(--blue); font-weight: 600; }
.link-btn:hover { background: var(--blue-soft); }
.link-btn .ic { width: 18px; height: 18px; }
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { background: #fdeceb; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text-2);
    flex-shrink: 0; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ic { width: 20px; height: 20px; }

/* ------------------------------------------------------------ avatars */
.avatar { --a: #72d5fd; --b: #2a9ef1; position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(var(--a), var(--b)); color: #fff; font-weight: 600; font-size: 16px; flex-shrink: 0; user-select: none; }
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar > span { line-height: 1; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 54px; height: 54px; font-size: 20px; }
.avatar.xl { width: 120px; height: 120px; font-size: 44px; }
.online-dot { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--online); border: 2px solid #fff; }
.avatar.lg .online-dot { right: 1px; bottom: 1px; }

/* ------------------------------------------------------------ layout */
.app-body { overflow: hidden; }
.app { position: relative; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { position: relative; display: flex; flex-direction: column; width: var(--sidebar); min-width: 300px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border); }
.sb-header { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px 0 8px; flex-shrink: 0; }
.menu-dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; }
.search-box { position: relative; flex: 1; display: flex; align-items: center; }
.search-box > .ic { position: absolute; left: 12px; width: 20px; height: 20px; color: var(--text-2); pointer-events: none; transition: color .15s; }
.search-box:focus-within > .ic { color: var(--blue); }
.search-box input { width: 100%; height: 42px; padding: 0 40px 0 44px; border: 2px solid transparent; border-radius: 22px; background: var(--hover); outline: none; font-size: 15px; transition: border-color .15s, background .15s; }
.search-box input:focus { background: #fff; border-color: var(--blue); }
.search-box.in-modal { margin: 4px 0 8px; }
.search-clear { position: absolute; right: 6px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--text-2); }
.search-clear:hover { background: rgba(0, 0, 0, .06); }
.search-clear .ic { width: 18px; height: 18px; }
.sb-body { flex: 1; overflow-x: hidden; overflow-y: auto; padding: 0 8px 88px; }

/* ------------------------------------------------------------ chat list */
.chat-item { display: flex; align-items: center; gap: 12px; height: 72px; padding: 9px; border-radius: 12px; cursor: pointer; user-select: none; transition: background .12s; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--blue); }
.chat-item.active .ci-title, .chat-item.active .ci-time, .chat-item.active .ci-preview, .chat-item.active .who,
.chat-item.active .draft, .chat-item.active .tick, .chat-item.active .ic { color: #fff !important; }
.chat-item.active .badge { background: #fff; color: var(--blue); }
.chat-item.active .online-dot { border-color: var(--blue); }
.ci-body { flex: 1; min-width: 0; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 6px; }
.ci-top { justify-content: space-between; margin-bottom: 3px; }
.ci-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-title .ic { color: var(--text-2); }
.ci-time { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 12px; color: var(--text-2); }
.ci-time .tick { display: inline-flex; color: var(--own-meta); }
.ci-time .tick .ic { width: 17px; height: 17px; }
.ci-bottom { justify-content: space-between; }
.ci-preview { flex: 1; min-width: 0; font-size: 15px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-preview .who { color: var(--text); }
.ci-preview .draft { color: var(--danger); }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.chat-skeleton { height: 72px; margin-bottom: 2px; border-radius: 12px; background: linear-gradient(90deg, #f3f4f6 25%, #e8eaed 37%, #f3f4f6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.list-empty { padding-top: 24px; }
.section-label { padding: 14px 10px 6px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.search-hint { padding: 18px 12px; text-align: center; font-size: 14px; color: var(--text-2); }

/* ------------------------------------------------------------ people rows */
.person { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 10px; border-radius: 12px; transition: background .12s; }
.person:hover { background: var(--hover); }
.person.clickable, .person.pick, .pick-list .person, .search-view .person { cursor: pointer; }
.person-body { flex: 1; min-width: 0; }
.person-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-actions { display: flex; gap: 6px; flex-shrink: 0; }
.person .role { font-size: 13px; color: var(--text-2); }
.check-circle { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c4c9cc; color: transparent; flex-shrink: 0; transition: all .15s; }
.check-circle .ic { width: 14px; height: 14px; stroke-width: 3; }
.person.checked .check-circle { background: var(--blue); border-color: var(--blue); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 2px; border-radius: 14px; background: #e8f1fd; color: var(--blue); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip:hover { background: #d6e7fb; }
.chip .ic { width: 14px; height: 14px; }

/* ------------------------------------------------------------ floating button & menus */
.fab { position: absolute; right: 20px; bottom: 20px; z-index: 3; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
    background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(51, 144, 236, .45); transition: transform .15s, background .15s; }
.fab:hover { background: var(--blue-dark); transform: scale(1.05); }
.pop-menu { position: absolute; z-index: 45; min-width: 210px; padding: 6px 0; border-radius: 12px; background: rgba(255, 255, 255, .97);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .2); backdrop-filter: blur(10px); animation: pop .12s ease-out; }
.pop-menu button { display: flex; align-items: center; gap: 16px; width: 100%; padding: 9px 18px; font-size: 15px; font-weight: 500; text-align: left; white-space: nowrap; }
.pop-menu button:hover { background: rgba(0, 0, 0, .05); }
.pop-menu button .ic { width: 20px; height: 20px; color: var(--text-2); }
.pop-menu button.danger, .pop-menu button.danger .ic { color: var(--danger); }
.fab-menu { right: 20px; bottom: 86px; transform-origin: bottom right; }
.ctx-menu { position: fixed; transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }

/* ------------------------------------------------------------ chat area */
.chat-area { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden;
    background: radial-gradient(circle at 12% 18%, #dbddbb 0, transparent 52%), radial-gradient(circle at 88% 24%, #d5d88d 0, transparent 55%),
        radial-gradient(circle at 18% 88%, #88b884 0, transparent 55%), radial-gradient(circle at 85% 82%, #6ba587 0, transparent 55%), #a8c79a; }
.wallpaper { position: absolute; inset: 0; background: url(assets/pattern.png) 0 0 / 300px auto repeat; opacity: .14; pointer-events: none; }
.no-chat { position: relative; z-index: 1; margin: auto; }
.no-chat span { display: inline-block; padding: 5px 14px; border-radius: 16px; background: var(--pill); color: #fff; font-weight: 500; backdrop-filter: blur(6px); }
.chat-view { position: relative; z-index: 1; flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-head { z-index: 2; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px 0 16px; background: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.back-btn { display: none !important; }
.chat-head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.chat-head-main > span { display: contents; }
.head-text { min-width: 0; }
.head-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub.accent { color: var(--blue); }
.head-sub.typing::after { content: ''; display: inline-block; width: 14px; animation: dots 1.2s steps(1) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.scroller { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 0 16px; }
.messages { display: flex; flex-direction: column; width: 100%; max-width: 728px; margin: 0 auto; }
#messages { margin-top: auto; padding-top: 10px; }
#messages:has(.chat-placeholder), #messages:has(.chat-loading) { flex: 1; }
.messages.pending { padding-bottom: 6px; }
.messages.pending:empty { padding-bottom: 6px; }

/* ------------------------------------------------------------ bubbles */
.msg { position: relative; display: flex; align-items: flex-end; margin-top: 2px; }
.msg.first { margin-top: 8px; }
.msg.out { justify-content: flex-end; }
.msg.grouped { padding-left: 44px; }
.msg-avatar { position: absolute; left: 0; bottom: 0; }
.bubble { position: relative; max-width: min(480px, 85%); padding: 6px 10px 7px; border-radius: 6px 12px 12px 6px; background: #fff;
    font-size: 15px; line-height: 1.38; overflow-wrap: anywhere; filter: drop-shadow(0 1px .6px rgba(16, 35, 47, .2)); }
.msg.in.first .bubble { border-top-left-radius: 12px; }
.msg.in.last .bubble { border-bottom-left-radius: 0; }
.msg.out .bubble { border-radius: 12px 6px 6px 12px; background: var(--own); }
.msg.out.first .bubble { border-top-right-radius: 12px; }
.msg.out.last .bubble { border-bottom-right-radius: 0; }
.msg.last .bubble::before { content: ''; position: absolute; bottom: 0; width: 9px; height: 19px; background: inherit; }
.msg.in.last .bubble::before { left: -9px;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 19'%3E%3Cpath d='M3 19h6V2c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 0 0 3 19z'/%3E%3C/svg%3E") no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 19'%3E%3Cpath d='M3 19h6V2c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 0 0 3 19z'/%3E%3C/svg%3E") no-repeat; }
.msg.out.last .bubble::before { right: -9px;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 19'%3E%3Cpath d='M6 19H0V2c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 0 1 6 19z'/%3E%3C/svg%3E") no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 19'%3E%3Cpath d='M6 19H0V2c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 0 1 6 19z'/%3E%3C/svg%3E") no-repeat; }
.msg.last .bubble.photo-only::before, .msg.jumbo .bubble::before { display: none; }
.msg.last .bubble.photo-only { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }

.sender { margin-bottom: 1px; font-size: 14px; font-weight: 600; }
.text { white-space: pre-wrap; }
.text a { color: var(--blue); text-decoration: underline; text-decoration-color: rgba(51, 144, 236, .4); }
.meta-spacer { display: inline-block; width: 38px; height: 10px; }
.meta-spacer.out { width: 58px; }
.meta { position: absolute; right: 8px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; font-size: 12px; line-height: 1;
    color: var(--in-meta); white-space: nowrap; user-select: none; pointer-events: none; }
.msg.out .meta { color: var(--own-meta); }
.meta .tick { display: inline-flex; }
.meta .tick .ic { width: 18px; height: 18px; }

.reply-quote { display: flex; flex-direction: column; max-width: 100%; margin: 2px 0 4px; padding: 3px 8px 3px 9px; overflow: hidden; border-left: 3px solid var(--blue);
    border-radius: 4px; background: rgba(51, 144, 236, .08); font-size: 14px; line-height: 1.3; cursor: pointer; }
.reply-quote:hover { background: rgba(51, 144, 236, .14); }
.reply-quote b { color: var(--blue); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.out .reply-quote { border-left-color: var(--own-meta); background: rgba(79, 174, 78, .12); }
.msg.out .reply-quote b { color: #3a9a3a; }

.bubble.has-photo { padding: 0; }
.photo { position: relative; overflow: hidden; background: rgba(0, 0, 0, .08); cursor: zoom-in;
    border-top-left-radius: inherit; border-top-right-radius: inherit; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble.photo-only .photo { border-radius: inherit; }
.bubble.named .photo, .reply-quote + .photo { border-top-left-radius: 0; border-top-right-radius: 0; }
.has-photo .sender { padding: 6px 10px 2px; }
.has-photo .reply-quote { margin: 6px 8px; }
.has-photo .text { padding: 6px 10px 7px; }
.photo-only .meta, .jumbo .meta { right: 6px; bottom: 6px; padding: 3px 6px; border-radius: 10px; background: rgba(0, 0, 0, .4); color: #fff !important; }
.msg.jumbo .bubble { display: flex; flex-direction: column; align-items: flex-end; padding: 0; background: none; filter: none; }
.msg.jumbo .text { font-size: 46px; line-height: 1.15; }
.msg.jumbo .meta-spacer { display: none; }
.msg.jumbo .meta { position: static; margin-top: 2px; background: var(--pill); }

.day-sep, .service { display: flex; justify-content: center; margin: 10px 0 4px; }
.day-sep { position: sticky; top: 8px; z-index: 2; pointer-events: none; }
.day-sep span, .service span { max-width: 85%; padding: 4px 11px; border-radius: 14px; background: var(--pill); color: #fff; font-size: 14px; font-weight: 500;
    line-height: 1.3; text-align: center; backdrop-filter: blur(6px); }
.unread-sep { margin: 10px -16px 4px; padding: 4px 0; background: rgba(255, 255, 255, .7); color: var(--text-2); font-size: 14px; font-weight: 500; text-align: center; }

.quick-reply { align-self: center; display: grid; place-items: center; width: 32px; height: 32px; margin: 0 8px; border-radius: 50%;
    background: var(--pill); color: #fff; opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.quick-reply .ic { width: 18px; height: 18px; }
.msg:hover .quick-reply { opacity: 1; }
.msg.out .quick-reply { order: -1; }
.pending-msg .quick-reply { display: none; }
.send-failed { display: none; align-self: flex-end; place-items: center; width: 28px; height: 28px; margin: 0 8px 4px; border-radius: 50%;
    background: var(--danger); color: #fff; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.send-failed .ic { width: 20px; height: 20px; }
.pending-msg.failed .send-failed { display: grid; }
.pending-msg.failed .bubble { opacity: .75; }
.pending-msg.failed .photo .progress, .pending-msg.failed .meta .tick { display: none; }
.net-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 8px 6px; padding: 7px 12px; border-radius: 10px;
    background: #fff4e5; color: #8a5a00; font-size: 14px; font-weight: 500; flex-shrink: 0; }
.net-bar[hidden] { display: none; }
.net-bar .spinner.sm { width: 16px; height: 16px; border-width: 2px; border-color: rgba(138, 90, 0, .25); border-top-color: #8a5a00; }
@media (hover: none) { .quick-reply { display: none; } }
.msg.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(51, 144, 236, .5); } 100% { box-shadow: 0 0 0 0 rgba(51, 144, 236, 0); } }

.photo.uploading img { filter: blur(2px) brightness(.85); }
.photo .progress { position: absolute; inset: 0; display: grid; place-items: center; }
.progress svg { width: 54px; height: 54px; border-radius: 50%; background: rgba(0, 0, 0, .35); transform: rotate(-90deg); }
.progress circle { fill: none; stroke-width: 3; }
.progress .track { stroke: rgba(255, 255, 255, .25); }
.progress .bar { stroke: #fff; stroke-linecap: round; stroke-dasharray: 125.66; stroke-dashoffset: 125.66; transition: stroke-dashoffset .2s; }
.progress span { position: absolute; color: #fff; font-weight: 600; }

.chat-placeholder { flex: 1; display: grid; place-items: center; padding: 40px 0; }
.placeholder-card { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 270px; padding: 22px 26px; border-radius: 20px;
    background: var(--pill); color: #fff; text-align: center; backdrop-filter: blur(6px); }
.ph-emoji { font-size: 60px; line-height: 1.1; }
.placeholder-card span { font-size: 14px; opacity: .9; }
.placeholder-card .btn { margin-top: 8px; background: rgba(255, 255, 255, .25); }
.placeholder-card .btn:hover { background: rgba(255, 255, 255, .35); }

.loading-box { display: grid; place-items: center; padding: 24px; }
.loading-box.sm { padding: 12px; }
.loading-box.chat-loading { flex: 1; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(51, 144, 236, .2); border-top-color: var(--blue); animation: spin .8s linear infinite; }
.loading-box.sm .spinner, .spinner.sm { width: 22px; height: 22px; border-width: 2.5px; }
.scroller .spinner { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
.history-loader { display: grid; place-items: center; padding: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.to-bottom { position: absolute; right: 20px; bottom: 88px; z-index: 3; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
    background: #fff; color: var(--text-2); box-shadow: 0 1px 4px rgba(0, 0, 0, .22); animation: pop .15s; }
.to-bottom:hover { color: var(--blue); }
.to-bottom .badge { position: absolute; top: -6px; right: -3px; }

/* ------------------------------------------------------------ composer */
.composer-wrap { position: relative; display: flex; align-items: flex-end; gap: 8px; width: 100%; max-width: 760px; margin: 0 auto;
    padding: 4px 16px max(16px, env(safe-area-inset-bottom)); flex-shrink: 0; }
.composer { position: relative; flex: 1; min-width: 0; border-radius: 18px; background: #fff; box-shadow: var(--shadow-sm); }
.composer-row { display: flex; align-items: flex-end; min-height: 54px; padding: 0 6px; }
.composer-row .icon-btn { margin-bottom: 7px; }
.composer-row .icon-btn:hover { color: var(--blue); background: transparent; }
.composer textarea { flex: 1; min-width: 0; max-height: 180px; padding: 15px 6px; border: 0; outline: none; resize: none; background: transparent; font-size: 16px; line-height: 1.5; }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 0 14px; color: var(--blue); }
.reply-bar > .ic { width: 22px; height: 22px; }
.reply-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 8px; border-left: 2px solid var(--blue); font-size: 14px; line-height: 1.3; }
.reply-bar-text b { color: var(--blue); }
.reply-bar-text span { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--blue); color: #fff; flex-shrink: 0;
    box-shadow: var(--shadow-sm); transition: transform .1s, background .15s; }
.send-btn:hover { background: var(--blue-dark); }
.send-btn:active { transform: scale(.93); }
.send-btn .ic { width: 26px; height: 26px; margin-left: 3px; }
.composer-blocked { width: calc(100% - 32px); max-width: 728px; margin: 4px auto 16px; padding: 14px 18px; border-radius: 16px; background: #fff;
    color: var(--text-2); text-align: center; box-shadow: var(--shadow-sm); }
.emoji-panel { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 10; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
    width: 360px; max-width: calc(100vw - 24px); max-height: 300px; padding: 8px; overflow-y: auto; border-radius: 14px; background: #fff; box-shadow: var(--shadow); animation: pop .12s; transform-origin: bottom left; }
.emoji-panel button { height: 40px; border-radius: 8px; font-size: 26px; line-height: 1; }
.emoji-panel button:hover { background: var(--hover); }
.drop-zone { position: absolute; inset: 0; z-index: 20; padding: 16px; background: rgba(255, 255, 255, .35); backdrop-filter: blur(2px); }
.drop-zone > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 100%; border: 3px dashed var(--blue);
    border-radius: 18px; background: rgba(255, 255, 255, .92); color: var(--blue); pointer-events: none; }
.drop-zone .ic { width: 56px; height: 56px; }
.drop-zone b { font-size: 20px; }
.drop-zone span { color: var(--text-2); }

/* ------------------------------------------------------------ info panel */
.info-panel { display: flex; flex-direction: column; width: 400px; flex-shrink: 0; background: #fff; border-left: 1px solid var(--border); animation: slideIn .2s ease-out; }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.ip-head { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px; flex-shrink: 0; }
.ip-head h3 { flex: 1; font-size: 19px; font-weight: 600; }
.ip-scroll { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.ip-profile { display: flex; flex-direction: column; align-items: center; padding: 8px 24px 20px; text-align: center; }
.ip-profile h2 { margin-top: 14px; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.ip-profile p { font-size: 14px; color: var(--text-2); }
.ip-row { display: flex; align-items: flex-start; gap: 28px; padding: 10px 24px; }
.ip-row > .ic { margin-top: 2px; color: var(--text-2); }
.ip-value { overflow-wrap: anywhere; white-space: pre-wrap; }
.ip-label { font-size: 14px; color: var(--text-2); }
.ip-section { margin-top: 8px; padding: 8px 8px 0; border-top: 8px solid var(--hover); }
.ip-section-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-weight: 600; color: var(--text-2); }
.ip-actions { padding: 12px 24px; }
.ip-actions .btn { width: 100%; height: 40px; }
.ip-danger { margin-top: 8px; padding: 8px; border-top: 8px solid var(--hover); }
.ip-danger button { display: flex; align-items: center; gap: 24px; width: 100%; padding: 12px 16px; border-radius: 10px; color: var(--danger); font-weight: 500; text-align: left; }
.ip-danger button:hover { background: #fdeceb; }

/* ------------------------------------------------------------ drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .3); animation: fade .2s; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 51; display: flex; flex-direction: column; width: 300px; max-width: 85vw; background: #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, .2); transform: translateX(-104%); transition: transform .25s cubic-bezier(.4, 0, .2, 1); }
.drawer.open { transform: none; }
.drawer-head { padding: 22px 20px 16px; background: linear-gradient(135deg, #3390ec, #5fb3f5); color: #fff; }
.drawer-head .avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.drawer-name { margin-top: 12px; font-size: 16px; font-weight: 600; }
.drawer-username { font-size: 14px; opacity: .85; }
.drawer-items { flex: 1; overflow-y: auto; padding: 8px; }
.drawer-items > button, .drawer-items > a, .drawer-toggle { display: flex; align-items: center; gap: 24px; width: 100%; padding: 11px 14px; border-radius: 10px;
    color: var(--text); font-weight: 500; text-align: left; text-decoration: none !important; cursor: pointer; }
.drawer-items > *:hover { background: var(--hover); }
.drawer-items .ic { color: var(--text-2); }
.drawer-items .badge { margin-left: auto; }
.drawer-items .danger, .drawer-items .danger .ic { color: var(--danger); }
.drawer-toggle input { display: none; }
.drawer-toggle .switch { position: relative; width: 34px; height: 14px; margin-left: auto; border-radius: 7px; background: #c4c9cc; transition: background .2s; }
.drawer-toggle .switch::after { content: ''; position: absolute; top: -3px; left: -2px; width: 20px; height: 20px; border: 2px solid #c4c9cc; border-radius: 50%;
    background: #fff; box-sizing: border-box; transition: transform .2s, border-color .2s; }
.drawer-toggle input:checked + .switch { background: #a3cdf6; }
.drawer-toggle input:checked + .switch::after { border-color: var(--blue); transform: translateX(18px); }
.drawer-foot { padding: 12px 22px 16px; font-size: 13px; color: var(--text-2); }

/* ------------------------------------------------------------ modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .35); animation: fade .15s; }
.modal-backdrop.closing { animation: fadeOut .16s forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal { display: flex; flex-direction: column; width: 100%; max-width: 420px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
    border-radius: 16px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); animation: modalIn .2s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes modalIn { from { opacity: 0; transform: scale(.94); } }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 22px; }
.modal-head h3 { flex: 1; font-size: 19px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 8px 22px 16px; }
.modal-body .people-list { margin: 0 -12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 16px 16px; }
.confirm-modal { max-width: 380px; }
.confirm-text { line-height: 1.5; }
.friends-modal, .group-modal { max-width: 460px; height: min(640px, calc(100dvh - 40px)); }
.tabs { position: sticky; top: -8px; z-index: 1; display: flex; margin: -8px -22px 8px; padding: 0 12px; border-bottom: 1px solid var(--border); background: #fff; }
.tabs button { position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 8px; font-weight: 600; color: var(--text-2); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--blue); }
.tabs button.active::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--blue); }
.tabs .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 12px; }
.empty-note { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 12px; text-align: center; font-size: 14px; color: var(--text-2); }
.empty-note img { width: 150px; height: 150px; object-fit: contain; mix-blend-mode: multiply; margin-bottom: 4px; }
.empty-note b { font-size: 17px; color: var(--text); }
.empty-note .btn { margin-top: 10px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.empty-actions .btn { margin: 0; }

.field-float { position: relative; margin: 14px 0; }
.field-float input, .field-float textarea { width: 100%; height: 54px; padding: 0 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
    outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.field-float textarea { height: auto; min-height: 54px; padding: 15px 16px; resize: vertical; line-height: 1.4; }
.field-float label { position: absolute; left: 12px; top: 27px; padding: 0 5px; border-radius: 4px; background: #fff; color: var(--text-2); font-size: 16px;
    pointer-events: none; transform: translateY(-50%); transition: top .15s, font-size .15s, color .15s; }
.field-float input:focus, .field-float textarea:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.field-float input:focus + label, .field-float textarea:focus + label { color: var(--blue); }
.field-float input:focus + label, .field-float input:not(:placeholder-shown) + label,
.field-float textarea:focus + label, .field-float textarea:not(:placeholder-shown) + label { top: 0; font-size: 13px; }
.field-float input:disabled { background: #f7f7f8; color: var(--text-2); }
.field-float input:disabled + label { background: linear-gradient(#fff 50%, #f7f7f8 50%); }
.field-float .pw-toggle { position: absolute; top: 7px; right: 6px; }
.field-float.pw input { padding-right: 52px; }
.hint { margin: -6px 4px 10px; font-size: 13px; color: var(--text-2); }
.group-form { display: flex; align-items: center; gap: 16px; }
.group-form .field-float { flex: 1; }
.photo-pick { position: relative; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--blue); color: #fff;
    overflow: hidden; cursor: pointer; flex-shrink: 0; transition: filter .15s; }
.photo-pick:hover { filter: brightness(1.08); }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-pick > .ic { width: 30px; height: 30px; }
.photo-pick.xl { width: 120px; height: 120px; background: linear-gradient(var(--a), var(--b)); }
.pp-initials { font-size: 44px; font-weight: 600; }
.pp-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .15s; }
.pp-overlay .ic { width: 36px; height: 36px; }
.photo-pick:hover .pp-overlay { opacity: 1; }
.profile-top { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 10px; }
.pw-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.pw-section summary { display: flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--blue); font-weight: 600; cursor: pointer; list-style: none; }
.pw-section summary::-webkit-details-marker { display: none; }
.pw-section summary .ic { width: 20px; height: 20px; }
.photo-modal { max-width: 460px; }
.photo-grid { display: grid; gap: 4px; margin-bottom: 12px; overflow: hidden; border-radius: 12px; }
.photo-grid.n1 { grid-template-columns: 1fr; }
.photo-grid.n2 { grid-template-columns: repeat(2, 1fr); }
.photo-grid.n3 { grid-template-columns: repeat(3, 1fr); }
.photo-grid.n4 { grid-template-columns: repeat(4, 1fr); }
.pg-item { aspect-ratio: 1; background: #eef0f2; }
.pg-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-grid.n1 .pg-item { aspect-ratio: auto; background: #f4f4f5; }
.photo-grid.n1 .pg-item img { max-height: 380px; object-fit: contain; }
.caption-input { width: 100%; padding: 10px 2px; border: 0; border-bottom: 2px solid var(--border); outline: none; resize: none; font-size: 16px; line-height: 1.4; transition: border-color .15s; }
.caption-input:focus { border-color: var(--blue); }

/* ------------------------------------------------------------ lightbox & toasts */
.lightbox { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; background: rgba(0, 0, 0, .9); animation: fade .15s; }
.lightbox-bar { align-self: stretch; display: flex; align-items: center; gap: 4px; padding: 8px 12px; color: #fff; }
.lightbox-info { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.lightbox-info span { opacity: .7; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100vh - 88px); margin: auto; border-radius: 4px; object-fit: contain; }
.toasts { position: fixed; top: 16px; left: 50%; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 10px;
    background: rgba(0, 0, 0, .82); color: #fff; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); animation: toastIn .2s ease-out; transition: opacity .4s, transform .4s; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; flex-shrink: 0; }
.toast.success::before { background: #4cd964; }
.toast.info::before { background: #5ac8fa; }
.toast.hide { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ------------------------------------------------------------ auth pages */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 0; }
.auth { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 380px; padding: 8px 20px; text-align: center; }
.auth-logo { width: 140px; height: 140px; margin-bottom: 22px; filter: drop-shadow(0 8px 20px rgba(51, 144, 236, .28)); }
.auth h1 { margin-bottom: 8px; font-size: 28px; font-weight: 600; }
.auth-sub { margin-bottom: 18px; color: var(--text-2); line-height: 1.45; }
.auth form { width: 100%; text-align: left; }
.auth form .btn { margin-top: 20px; }
.auth-switch { margin-top: 22px; color: var(--text-2); }
.auth-foot { margin-top: 36px; font-size: 13px; color: var(--text-2); }
.alert { display: flex; align-items: flex-start; gap: 10px; width: 100%; margin: 4px 0; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; text-align: left; }
.alert .ic { width: 20px; height: 20px; }
.alert.error { background: #fdecea; color: #b3261e; }
.alert.success { background: #e7f6e9; color: #1e6b2c; }
.suspended-icon { display: grid; place-items: center; width: 120px; height: 120px; margin-bottom: 24px; border-radius: 50%; background: linear-gradient(#ffcd6a, #ffa85c);
    color: #fff; box-shadow: 0 8px 24px rgba(255, 168, 92, .35); }
.suspended-icon .ic { width: 56px; height: 56px; }

/* ------------------------------------------------------------ admin */
.admin-body { min-height: 100vh; background: var(--hover); }
.admin-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 24px;
    background: #fff; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text); text-decoration: none !important; }
.brand img { width: 34px; height: 34px; }
.brand .tag { padding: 2px 8px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; }
.admin-header nav { display: flex; gap: 8px; }
.admin-content { max-width: 1100px; margin: 0 auto; padding: 28px 20px 48px; }
.admin-content h1 { font-size: 26px; font-weight: 700; }
.admin-content .sub { margin: 4px 0 22px; color: var(--text-2); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.stat-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(var(--a), var(--b)); color: #fff; flex-shrink: 0; }
.stat b { display: block; font-size: 24px; line-height: 1.15; }
.stat span { font-size: 13px; color: var(--text-2); }
.admin-tabs { display: inline-flex; gap: 4px; margin-bottom: 14px; padding: 4px; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.admin-tabs button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 9px; font-weight: 600; color: var(--text-2); }
.admin-tabs button.active { background: var(--blue); color: #fff; }
.admin-tabs .count { padding: 0 7px; border-radius: 9px; background: rgba(0, 0, 0, .08); font-size: 12px; }
.admin-tabs button.active .count { background: rgba(255, 255, 255, .25); }
.card { overflow: hidden; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 17px; }
.card-head .search-box { flex: 0 1 280px; }
.card-head .search-box input { height: 38px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 20px; border-bottom: 1px solid #eef0f2; text-align: left; white-space: nowrap; }
th { background: #fafafa; color: var(--text-2); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell b { display: block; font-weight: 600; }
.user-cell small { font-size: 13px; color: var(--text-2); }
.actions { display: flex; gap: 6px; }
form.inline { display: inline; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; background: #eef0f2; color: #555; font-size: 12px; font-weight: 600; }
.pill.admin { background: #e8f1fd; color: var(--blue); }
.pill.pending { background: #fff4e0; color: #b26a00; }
.pill.online { background: #e7f6e9; color: #1e8e3e; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-2); }
.empty-state img { width: 140px; mix-blend-mode: multiply; }
.empty-state b { display: block; margin: 6px 0 2px; font-size: 16px; color: var(--text); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
    .info-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 30; box-shadow: -4px 0 24px rgba(0, 0, 0, .12); }
}
@media (max-width: 1100px) {
    :root { --sidebar: 350px; }
}
@media (max-width: 900px) {
    .sidebar { width: 100%; min-width: 0; border-right: 0; }
    .chat-area { display: none; }
    .app.chat-open .sidebar { display: none; }
    .app.chat-open .chat-area { display: flex; }
    .back-btn { display: inline-grid !important; }
    .chat-head { padding: 0 8px 0 4px; }
    .info-panel { width: 100%; border-left: 0; }
    .scroller { padding: 0 8px; }
    .unread-sep { margin-left: -8px; margin-right: -8px; }
    .composer-wrap { padding: 4px 8px max(8px, env(safe-area-inset-bottom)); gap: 6px; }
    .composer-row { min-height: 48px; padding: 0 2px; }
    .composer-row .icon-btn { margin-bottom: 4px; }
    .composer textarea { padding: 12px 4px; }
    .send-btn { width: 48px; height: 48px; }
    .to-bottom { right: 12px; bottom: 72px; }
    .bubble { max-width: 88%; }
    .wallpaper { background-size: 240px auto; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .admin-header { padding: 0 14px; }
    .modal-backdrop { padding: 10px; }
    .friends-modal, .group-modal { height: calc(100dvh - 20px); }
}
@media (max-width: 480px) {
    .admin-header .brand span:not(.tag) { display: none; }
    .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { padding: 14px; }
}
