* { box-sizing: border-box; }

:root {
    --acc: #5865f2;
    --acc-text: #fff;
    --win-op: .92;
    --win-blur: 10px;
    --fs: 14.5px;
    --r-lg: 20px;
    --r-md: 12px;
    --r-sm: 8px;
}
html[data-theme="dark"] {
    --page: #131417;
    --win-rgb: 32, 34, 40;
    --panel: #26282f;
    --panel-deep: #17181c;
    --input: rgba(255, 255, 255, .055);
    --surface: rgba(0, 0, 0, .18);
    --text: #e4e6ea;
    --muted: #8f96a3;
    --muted-2: #b8bdc7;
    --hover: rgba(255, 255, 255, .075);
    --hover-pre: rgba(255, 255, 255, .035);
    --border: rgba(255, 255, 255, .09);
    --border-hi: rgba(255, 255, 255, .16);
    --sep: #3b3e47;
    --link: #4db8ff;
    --danger: #f23f42;
    --them: #2fb46b;
    --shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
html[data-theme="light"] {
    --page: #dfe2e6;
    --win-rgb: 252, 253, 255;
    --panel: #ffffff;
    --panel-deep: #eceef2;
    --input: rgba(0, 0, 0, .05);
    --surface: rgba(255, 255, 255, .5);
    --text: #26292e;
    --muted: #7d828c;
    --muted-2: #4c5058;
    --hover: rgba(0, 0, 0, .05);
    --hover-pre: rgba(66, 66, 66, 0.15);
    --border: rgba(0, 0, 0, .09);
    --border-hi: rgba(255, 255, 255, .8);
    --sep: #d4d7dc;
    --link: #0568d0;
    --danger: #d83c3e;
    --them: #178a4c;
    --shadow: 0 24px 70px rgba(30, 40, 70, .35);
}

/* ---- scrollbars (match the glass UI everywhere) ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--sep); border-radius: 999px;
    border: 3px solid transparent; background-clip: padding-box;
    min-height: 40px;
}
::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--acc) 70%, var(--sep));
    border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
    background: var(--acc);
    border: 3px solid transparent; background-clip: padding-box;
}
@supports not selector(::-webkit-scrollbar) {
    * { scrollbar-width: thin; scrollbar-color: var(--sep) transparent; }
}

html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--page); color: var(--text); height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
}
#bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

button { font-family: inherit; color: inherit; }
.ico {
    width: 18px; height: 18px; stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: -4px; pointer-events: none;
}
.actions .ico { width: 17px; height: 17px; stroke-width: 2.2; }
.avatar-xs + .ico { width: 15px; height: 15px; }
.dock .ico { width: 19px; height: 19px; }
.tool-head .title .ico, #games-header .title .ico, #songs-header .title .ico, #users-header .title .ico,
#call-header .title .ico, #weather-header .title .ico, #admin-header .title .ico { width: 15px; height: 15px; vertical-align: -2px; color: var(--acc); margin-right: 10px; }
#send-btn .ico { width: 15px; height: 15px; margin-left: 7px; }
.pin-mark .ico { width: 11px; height: 11px; color: var(--acc); }
.song-play .ico, .vote-pill .ico { width: 14px; height: 14px; }
.call-btn .ico { width: 20px; height: 20px; }
.call-btn.hangup .ico { transform: rotate(135deg); }
#call-chip .ico { width: 22px; height: 22px; }

/* ---- floating app window ---- */
#app {
    position: relative; z-index: 1; display: flex; flex-direction: column;
    width: min(920px, 96vw); height: min(92vh, 92dvh);
    background: rgba(var(--win-rgb), var(--win-op));
    backdrop-filter: blur(var(--win-blur)) saturate(1.3);
    -webkit-backdrop-filter: blur(var(--win-blur)) saturate(1.3);
    border: 1px solid var(--border);
    border-top-color: var(--border-hi);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ---- login ---- */
.login-wrap {
    position: relative; z-index: 1; margin: auto; padding: 34px 30px 30px; border-radius: var(--r-sm); width: 330px;
    background: rgba(24, 25, 30, .72);
    backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
    border: 1px solid rgba(0, 0, 0, .6);
    box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 10px 0px;
}
.login-wrap h1 { font-size: 22px; letter-spacing: -.01em; margin: 0 0 4px; color: #f0f2f5; text-align: center; }
.login-wrap .sub { font-size: 12.5px; color: rgba(255, 255, 255, .55); margin: 0 0 20px; text-align: center; }
.login-wrap label { display: block; margin: 12px 0 5px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .6); }
.login-wrap input {
    width: 100%; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px;
    background: rgba(0, 0, 0, .35); color: #f0f2f5; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-wrap input:focus { border-color: var(--acc); box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 10px 0px;}
.login-wrap button {
    margin-top: 22px; width: 100%; padding: 11px; border: none; border-radius:  var(--r-sm);
    background: var(--acc); color: var(--acc-text); font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 10px 0px; transition: filter .15s, transform .1s;
}
.login-wrap button:hover { filter: brightness(.8); }
.login-wrap button:active { transform: translateY(1px); }
.login-wrap button[disabled] { opacity: .8; cursor: default; }
.login-wrap .err { color: #ff8a8d; font-size: 13px; margin-top: 12px; }
.login-wrap { animation: loginIn .4s ease both; }
.login-wrap.leaving { animation: loginOut .3s ease forwards; pointer-events: none; }
@keyframes loginIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes loginOut { to { opacity: 0; transform: translateY(-22px) scale(.97); } }
.spinner {
    display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- header ---- */
#header {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px 10px 18px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    z-index: 5; flex: 0 0 auto; min-height: 52px;
}
#header .title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
#header .title .hash { color: var(--acc); margin-right: 5px; font-weight: 800; }
#header .spacer { flex: 1; }
#search-input {
    background: var(--input); border: 1px solid transparent; border-radius: 999px; color: var(--text);
    padding: 7px 14px; width: 190px; font-size: 13px; outline: none; transition: border-color .15s, width .2s;
}
#search-input::placeholder { color: var(--muted); }
#search-input:focus { border-color: var(--acc); width: 230px; }
#chat-hide, #dm-voice-btn, #dm-video-btn {
    color: var(--muted-2); font-size: 14px; background: none;
    border: none; cursor: pointer; padding: 6px 8px; border-radius: 999px; transition: background .12s;
}
#chat-hide:hover, #dm-voice-btn:hover, #dm-video-btn:hover { color: var(--text); background: var(--hover); }

/* ---- app row: sidebar + chat column ---- */
#app-row { flex: 1; display: flex; min-height: 0; }
#sidebar {
    width: 168px; flex: 0 0 auto; background: var(--surface); border-right: 1px solid var(--border);
    padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.sb-label {
    font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--muted); margin: 14px 6px 5px; display: flex; align-items: center; gap: 6px;
}
.sb-flex { flex: 1; min-height: 12px; }
#chan-add-btn {
    background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px;
    padding: 0 4px; border-radius: 4px; margin-left: auto;
}
#chan-add-btn:hover { color: var(--acc); }
.sb-gear {
    background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 2px;
    display: none; flex: 0 0 auto;
}
.sb-item:hover .sb-gear { display: block; }
.sb-gear:hover { color: var(--acc); }
.sb-gear .ico { width: 13px; height: 13px; }
.sb-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--r-sm);
    cursor: pointer; color: var(--muted-2); font-size: 13.5px; font-weight: 600; user-select: none;
}
.sb-item:hover { background: var(--hover); color: var(--text); }
.sb-item.active { background: color-mix(in srgb, var(--acc) 18%, transparent); color: var(--text); }
.sb-hash { color: var(--acc); font-weight: 800; margin: 0 2px 0 4px; }
.sb-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sep); flex: 0 0 auto; }
.sb-dot.on { background: var(--them); }
.sb-badge {
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    border-radius: 999px; padding: 1px 6px; flex: 0 0 auto;
}
.sb-badge:empty { display: none; }
#voice-room .ico { width: 15px; height: 15px; flex: 0 0 auto; }
#voice-room.active { background: color-mix(in srgb, var(--them) 20%, transparent); color: var(--text); }
.voice-member { display: flex; align-items: center; gap: 7px; padding: 2px 8px 2px 12px; font-size: 12px; color: var(--muted-2); }
.vm-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vm-conn { color: var(--muted); }
#voice-leave { display: none !important; }
#voice-room:hover #voice-leave.avail { display: block !important; }
#voice-leave:hover { color: var(--danger); }
#chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#app.closed { display: none; }

/* ---- dock (account-level bar, outside all windows) ---- */
.dock {
    /* centered via auto-margins, NOT transform — the boot appIn animation ends on transform:none
       and would otherwise wipe a translateX(-50%) centering, shoving the dock off to the right */
    position: fixed; bottom: 14px; left: 0; right: 0; margin-inline: auto; width: max-content; z-index: 5000;
    display: flex; align-items: center; gap: 3px; padding: 7px 10px;
    background: rgba(var(--win-rgb), .88);
    backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid var(--border); border-top-color: var(--border-hi); border-radius: 999px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
.dock button, .dock a {
    font-size: 17px; background: none; border: none; color: var(--muted-2); cursor: pointer;
    padding: 7px 9px; border-radius: 999px; text-decoration: none;
    display: flex; align-items: center; transition: background .12s, transform .1s, color .12s;
}
.dock button:hover, .dock a:hover { background: var(--hover)!important; color: var(--text); 
    /* transform: translateY(-2px);  */
}
/* active = its window/panel is open */
.dock button.active { color: var(--acc); background: color-mix(in srgb, var(--acc) 16%, transparent); }
.dock button.active:hover { background: color-mix(in srgb, var(--acc) 24%, transparent); color: var(--acc); }
#logout-btn:hover { background: var(--danger) !important; color: #fff !important; }
.dock-sep { width: 1px; height: 22px; background: var(--sep); margin: 0 5px; }
/* each dock button lives in a wrapper; mic+caret and headphones+caret pair into a tight group */
.dock-item, .dock-group { display: flex; align-items: center; }
.dock-group { gap: 0; }
.dock-group > button:first-child {
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;
    padding-left:7px;
    padding-right:2px
}
.dock-group > button:last-child {
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
    padding:11px 7px 10px 2px;
    margin-left:1px;
}
/* caret hugs its mic/headphones button */
/* .dock-group .av-caret { margin-left: -5px; }  */
/* .dock .dock-group:has(> button.av-caret.open) button:last-child {
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
    padding-right: 9px!important;
    padding-left: 0px!important;
    padding-top: 10px!important;
    padding-bottom: 11px!important;
  } */

div.dock-group:has(> button.av-caret.open) button {
    background: var(--hover);
    color: var(--text);
    /* transform: translateY(-2px); */
}
div.dock-group:hover button {
    background: var(--hover-pre);
}


div.dock-group:has(> button.av-caret.open) button:first-child {}

html[data-dock="left"] .dock-group, html[data-dock="right"] .dock-group { flex-direction: column; }
html[data-dock="left"] .dock-group .av-caret, html[data-dock="right"] .dock-group .av-caret { margin-left: 0; margin-top: -5px; }
/* muted/deafened state — any mic-or-audio button turns red */
#gmute-mic.off, #gmute-audio.off, #gmute-mic.off:hover, #gmute-audio.off:hover,
.call-btn.off, .call-btn#call-mute.off, #lg-mute.off { color: var(--danger); }
/* live input/output level lights up the icon SHAPE itself: a second copy of the icon in the
   "lit" color is stacked over the base and clipped from the bottom by the level (--clip = top inset) */
.ico-lvl { position: relative; display: inline-flex; }
.ico-lvl .lvl-icon {
    position: absolute; inset: 0; color: var(--them); pointer-events: none;
    clip-path: inset(100% 0 0 0); transition: clip-path .05s linear;
}
html.level-accent .lvl-icon { color: var(--acc); } /* "override level monitor colors" — use highlight color */
#gmute-mic.off .lvl-icon, #gmute-audio.off .lvl-icon { color: var(--danger); } /* muted/deafened → red glow (wins via ID) */
/* dock unread badge */
#dock-chat { position: relative; }
#dock-unread {
    position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px;
    border-radius: 999px; text-align: center; pointer-events: none; box-shadow: 0 0 0 2px var(--panel);
}
#dock-unread:empty { display: none; }
/* mic/output caret buttons + their quick-menu popup */
.av-caret { padding: 11px 2px; color: var(--muted-2); }
.av-caret .ico { width: 12px; height: 12px; }
.av-caret.open { color: var(--text); } /* glyph itself swaps to #i-caret-up in JS */
#av-pop {
    display: none; position: fixed; z-index: 60; width: 232px; padding: 6px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}
.av-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px 4px; }
.av-item {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: none; border: none; color: var(--text); font: inherit; font-size: 13px;
    padding: 8px 8px; border-radius: 8px; cursor: pointer;
}
.av-item > span { flex: 1; }
button.av-item:hover { background: var(--hover); }
.av-chev { width: 13px; height: 13px; transition: transform .15s; color: var(--muted-2); }
.av-expand.open .av-chev { transform: rotate(180deg); }
.av-sub { padding: 2px 4px 4px; }
.av-dev {
    display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    color: var(--muted-2); font: inherit; font-size: 12.5px; padding: 6px 10px 6px 22px; border-radius: 7px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.av-dev:hover { background: var(--hover); color: var(--text); }
.av-dev.sel { color: var(--acc); }
.av-dev.sel::before { content: '✓'; margin-left: -16px; margin-right: 4px; }
.av-note { font-size: 11px; color: var(--muted); padding: 4px 10px; }
.av-vol { flex-wrap: wrap; cursor: default; }
.av-vol input { flex: 1; min-width: 0; accent-color: var(--acc); }
.av-vol .av-volval { font-size: 11px; color: var(--muted); font-weight: 600; min-width: 34px; text-align: right; }
.av-link { color: var(--acc); font-weight: 600; }
#me-chip span { font-size: 13px; font-weight: 600; margin-left: 7px; }
html[data-dock="top"] .dock { top: 14px; bottom: auto; }
html[data-dock="left"] .dock, html[data-dock="right"] .dock {
    /* vertical centering also via auto-margins (same reason — no transform) */
    left: 14px; right: auto; top: 0; bottom: 0; margin-block: auto; margin-inline: 0;
    width: auto; height: max-content;
    flex-direction: column; padding: 10px 7px;
}
html[data-dock="right"] .dock { left: auto; right: 14px; }
html[data-dock="left"] .dock-sep, html[data-dock="right"] .dock-sep { width: 22px; height: 1px; margin: 5px 0; }
html[data-dock="left"] #me-chip span, html[data-dock="right"] #me-chip span { display: none; }
html[data-dock="left"] .dock button:hover, html[data-dock="left"] .dock a:hover,
html[data-dock="right"] .dock button:hover, html[data-dock="right"] .dock a:hover { transform: translateX(0) scale(1.12); }
#games-btn, #users-btn { position: relative; }
#games-btn.has-dot::after {
    content: '!'; position: absolute; top: -3px; right: -3px;
    min-width: 15px; height: 15px; padding: 0 3px; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; line-height: 1; border-radius: 999px;
    background: var(--danger); color: #fff; font-weight: 900;
    border: 1.5px solid rgb(var(--win-rgb));
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 70%, transparent);
    animation: gamesPulse 1.4s ease-out infinite;
}
@keyframes gamesPulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 70%, transparent); transform: scale(1); }
    70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--danger) 0%, transparent); transform: scale(1.12); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 0%, transparent); transform: scale(1); }
}
#users-btn.online::after {
    content: ''; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
    border-radius: 50%; background: var(--them); border: 1.5px solid rgb(var(--win-rgb));
}
.avatar-sm {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.avatar-sm.u-me, #profile-avatar.u-me { background: var(--acc); color: var(--acc-text); }

/* ---- messages ---- */
#chat { flex: 1 1 0; overflow-y: auto; padding: 16px 18px 6px; scroll-behavior: auto; }

#empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%;
    color: var(--muted); gap: 8px; user-select: none;
}
#empty .big { font-size: 40px; }
#empty .txt { font-size: 14px; }

.msg { position: relative; display: flex; gap: 16px; padding: 3px 56px 3px 8px; border-radius: var(--r-md); margin-top: 12px; }
.msg.grouped { display: block; margin-top: 0; }
.msg.grouped .content { margin-left: 52px; }
.msg.anim { animation: msgIn .18s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
html[data-density="compact"] .msg { margin-top: 2px; padding-top: 1px; padding-bottom: 1px; }
html[data-density="compact"] .msg.grouped .content { margin-left: 0; }
.msg:hover { background: var(--hover); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; margin-top: 3px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; text-transform: uppercase; user-select: none;
    object-fit: cover; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
html[data-density="compact"] .avatar { display: none; }
.avatar.u-me { background: var(--acc); color: var(--acc-text); }
.avatar.u-them { background: var(--them); color: #fff; }
.msg .content { flex: 1; min-width: 0; }
.msg .gutter-time {
    position: absolute; left: 8px; top: 5px; width: 52px; padding: 0 4px; font-size: 10px; color: var(--muted);
    opacity: 0; text-align: center; user-select: none; white-space: nowrap;
}
.msg:hover .gutter-time { opacity: 1; }
html[data-density="compact"] .gutter-time { display: none; }
.msg .meta { font-size: 13px; margin-bottom: 1px; }
.msg .name { font-weight: 700; }
.msg .name.u-me { color: var(--acc); }
.msg .name.u-them { color: var(--them); }
.msg .time { color: var(--muted); font-size: 11px; margin-left: 8px; }
.msg .edited { color: var(--muted); font-size: 10px; margin-left: 5px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; font-size: var(--fs); line-height: 1.4; }
.msg .body a { color: var(--link); text-decoration: none; }
.msg .body a:hover { text-decoration: underline; }
.spotify-chip {
    display: inline-flex; align-items: center; gap: 6px; margin: 2px 0;
    background: color-mix(in srgb, #1db954 16%, transparent); border: 1px solid #1db954;
    color: #1db954 !important; border-radius: 999px; padding: 4px 12px;
    font-size: 13px; font-weight: 600; text-decoration: none !important; cursor: pointer;
}
.spotify-chip:hover { background: color-mix(in srgb, #1db954 28%, transparent); }
.msg.deleted .body { color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 8px; }
.act-purge {
    background: none; border: none; color: var(--muted-2); cursor: pointer; padding: 2px; border-radius: 5px;
    display: inline-flex; opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.act-purge .ico { width: 13px; height: 13px; }
.msg.deleted:hover .act-purge { opacity: .7; }
.act-purge:hover { opacity: 1 !important; color: var(--danger); background: var(--hover); }
.msg .attach img {
    max-width: min(420px, 90%); max-height: 320px; border-radius: var(--r-md); margin-top: 5px; display: block;
    cursor: pointer; border: 1px solid var(--border); transition: filter .15s;
}
.msg .attach img:hover { filter: brightness(1.06); }
.msg .attach .filelink {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--link); font-size: 13.5px;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 12px; text-decoration: none;
}
.msg .attach .filelink:hover { border-color: var(--acc); }
.msg .reacts { margin-top: 4px; }
.react-pill {
    display: inline-flex; align-items: center; background: var(--input); border: 1px solid var(--border); border-radius: 999px;
    padding: 2px 9px; margin-right: 5px; font-size: 13px; cursor: pointer; user-select: none;
    transition: transform .1s, border-color .12s, background .12s;
}
.react-pill:hover { transform: scale(1.08); border-color: var(--border-hi); }
.react-pill.mine { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 20%, transparent); }
.react-pill .cnt { font-size: 11px; font-weight: 600; color: var(--muted-2); margin-left: 4px; }
.msg .actions {
    display: none; position: absolute; top: -14px; right: 10px; background: var(--panel);
    border: 1px solid var(--border-hi); border-radius: 999px; padding: 3px 5px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.msg:hover .actions { display: flex; animation: msgIn .12s ease-out; }
.actions button {
    background: none; border: none; cursor: pointer; font-size: 16px; padding: 5px 8px;
    border-radius: 999px; color: var(--muted-2); display: inline-flex; align-items: center;
}
.actions button:hover { background: var(--hover); color: var(--text); }
#emoji-pop {
    display: none; position: fixed; background: var(--panel); border: 1px solid var(--border);
    border-radius: 999px; padding: 5px 8px; z-index: 7000; box-shadow: 0 8px 26px rgba(0, 0, 0, .4);
}
#emoji-pop button { background: none; border: none; font-size: 19px; cursor: pointer; padding: 4px 5px; border-radius: 50%; transition: transform .1s; }
#emoji-pop button:hover { transform: scale(1.25); }
.seen-marker {
    display: flex; justify-content: flex-end; align-items: center; gap: 5px;
    font-size: 10.5px; color: var(--muted); padding: 2px 10px 0 0;
}
.avatar-xs {
    width: 15px; height: 15px; border-radius: 50%; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 700; text-transform: uppercase;
}
.avatar-xs.u-them { background: var(--them); color: #fff; }
.avatar-xs.u-me { background: var(--acc); color: var(--acc-text); }
.edit-box {
    width: 100%; background: var(--panel-deep); color: var(--text); border: 1px solid var(--acc);
    border-radius: var(--r-sm); padding: 8px 10px; font: inherit; font-size: var(--fs); margin-top: 2px; outline: none;
}
.edit-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; user-select: none; }
.day-sep::before, .day-sep::after { content: ''; flex: 1; height: 1px; background: var(--sep); }
.day-sep span {
    color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    background: var(--input); border: 1px solid var(--border); padding: 3px 12px; border-radius: 999px;
}

/* ---- typing + input ---- */
#typing { height: 20px; font-size: 12px; color: var(--muted-2); padding: 0 22px; flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.tdots { display: inline-flex; gap: 3px; align-items: center; }
.tdots i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted-2); animation: tb 1.2s infinite; }
.tdots i:nth-child(2) { animation-delay: .15s; }
.tdots i:nth-child(3) { animation-delay: .3s; }
@keyframes tb { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }
#input-row {
    display: flex; align-items: flex-end; gap: 10px; padding: 4px 16px 16px; flex: 0 0 auto;
}
#input-inner {
    flex: 1; display: flex; align-items: flex-end;
    background: var(--input); border: 1px solid var(--border); border-radius: 24px; padding: 4px 6px 4px 8px;
    transition: border-color .15s;
}
#input-inner:focus-within { border-color: var(--acc); }
#attach-btn {
    background: none; border: none; color: var(--muted-2); font-size: 19px; cursor: pointer;
    width: 34px; height: 38px; border-radius: 50%; flex: 0 0 auto; transition: color .12s;
}
#attach-btn:hover { color: var(--acc); }
#text {
    flex: 1; background: none; border: none; color: var(--text); font: inherit; font-size: var(--fs);
    resize: none; padding: 9px 6px; max-height: 140px; outline: none;
}
#text::placeholder { color: var(--muted); }
#send-btn {
    background: var(--acc); border: none; color: var(--acc-text); border-radius: 12px;
    height: 44px; padding: 0 20px; font-size: 14px; font-weight: 600; cursor: pointer; flex: 0 0 auto;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 5px 16px color-mix(in srgb, var(--acc) 40%, transparent);
    transition: filter .15s, transform .1s;
}
#send-btn .arrow { font-size: 12px; }
#send-btn:hover { filter: brightness(1.12); }
#send-btn:active { transform: translateY(1px); }
#send-btn:disabled { opacity: .6; }
#file-chip {
    display: none; margin: 0 18px 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 8px 12px; font-size: 13px; color: var(--muted-2); align-items: center; gap: 10px; width: fit-content; max-width: 90%;
}
#file-thumb { display: none; max-height: 64px; max-width: 96px; border-radius: 6px; }
#file-chip button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; }
#file-warn { display: none; color: #e8b339; font-size: 12px; }

/* ---- search panel ---- */
#search-panel {
    display: none; position: absolute; top: 56px; right: 12px; width: min(430px, 92vw);
    max-height: 68vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 12px; z-index: 15; box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
#search-panel .shead { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
#search-panel .msg { display: block; padding: 6px 8px; margin-top: 2px; }
#search-panel .msg:hover { background: var(--hover); }

/* ---- settings ---- */
#settings-overlay, #profile-overlay, #chan-overlay {
    display: none; position: fixed; inset: 0; z-index: 6000;
    background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    align-items: center; justify-content: center;
}
#settings, #profile, #chan-modal {
    background: var(--panel); border: 1px solid var(--border); border-top-color: var(--border-hi);
    border-radius: 16px; padding: 0; width: min(420px, 92%);
    max-height: 86%; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    animation: msgIn .18s ease-out;
}
#settings h2, #profile h2, #chan-modal h2 { padding: 16px 22px 10px; flex: 0 0 auto; }
#chan-modal h2 { font-size: 16px; margin: 0; display: flex; justify-content: space-between; align-items: center; }
#chan-modal h2 button { background: none; border: none; color: var(--muted-2); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
#chan-modal h2 button:hover { background: var(--hover); color: var(--text); }
#chan-modal .sec {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
    color: var(--acc); margin: 18px 0 10px; display: flex; align-items: center; gap: 10px;
}
#chan-modal .sec::after { content: ''; flex: 1; height: 1px; background: var(--sep); }
#chan-modal .row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
#chan-name {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13.5px; outline: none;
}
#chan-name:focus { border-color: var(--acc); }
#chan-msg { font-size: 12px; }
#chan-msg.ok { color: var(--them); }
#chan-msg.err { color: var(--danger); }
#chan-members .chk { margin-bottom: 7px; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 22px 16px; }
.modal-foot {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
    padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface);
}
.modal-foot .spacer { flex: 1; }
.modal-foot #prof-msg, .modal-foot #admin-msg { margin: 0; }
.foot-hint { font-size: 11px; color: var(--muted); }
.mini-btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
#settings h2, #profile h2 { font-size: 16px; letter-spacing: -.01em; margin: 0; display: flex; justify-content: space-between; align-items: center; }
#settings h2 button, #profile h2 button { background: none; border: none; color: var(--muted-2); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
#settings h2 button:hover, #profile h2 button:hover { background: var(--hover); color: var(--text); }
#settings .sec, #profile .sec {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
    color: var(--acc); margin: 20px 0 10px; display: flex; align-items: center; gap: 10px;
}
#settings .sec::after, #profile .sec::after { content: ''; flex: 1; height: 1px; background: var(--sep); }
#settings .row, #profile .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
#settings .row > label, #profile .row > label { font-size: 13px; color: var(--text); flex: 0 0 auto; }
#settings .row .ctl-wrap, #profile .row .ctl-wrap { display: flex; align-items: center; gap: 8px; }
#settings input[type="range"] { width: 130px; accent-color: var(--acc); }
#settings input[type="color"] { width: 34px; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: none; padding: 1px; cursor: pointer; }
#settings .val { font-size: 11px; color: var(--muted); min-width: 36px; text-align: right; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { background: var(--panel-deep); color: var(--muted-2); border: none; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; }
.seg button.on { background: var(--acc); color: var(--acc-text); }
.swatch { width: 21px; height: 21px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform .1s; }
.swatch:hover { transform: scale(1.2); }
#bg-select {
    width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.dev-sel {
    width: 190px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.dev-sel:focus { border-color: var(--acc); }
#call-vol { width: 88px; accent-color: var(--acc); }
.chk { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text); margin-bottom: 9px; cursor: pointer; }
.chk input { accent-color: var(--acc); width: 15px; height: 15px; }
#settings .hint { font-size: 11px; color: var(--muted); margin-top: 14px; }
.profile-row { justify-content: flex-start !important; }
#profile-avatar {
    width: 58px; height: 58px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 24px; text-transform: uppercase;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
#profile-name { font-weight: 700; font-size: 15px; margin-bottom: 7px; }
.mini-btn {
    background: var(--panel-deep); border: 1px solid var(--border); color: var(--muted-2);
    border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
    transition: color .12s, background .12s, border-color .12s;
}
.mini-btn:hover { color: var(--text); border-color: var(--border-hi); }
.mini-btn.acc { background: var(--acc); color: var(--acc-text); border-color: transparent; }
.mini-btn.acc:hover { filter: brightness(1.1); color: var(--acc-text); }
#pw-form { margin: 4px 0 12px; }
#pw-form input {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 7px;
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
#pw-form input:focus { border-color: var(--acc); }
#pw-msg, #prof-msg { font-size: 12px; margin-top: 7px; }
#pw-msg.ok, #prof-msg.ok { color: var(--them); }
#pw-msg.err, #prof-msg.err { color: var(--danger); }
#prof-login, #prof-display {
    width: 170px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
#prof-login:focus, #prof-display:focus { border-color: var(--acc); }
.au-sub { font-size: 10.5px; color: var(--muted); }

/* ---- admin ---- */
.admin-user {
    display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--r-sm);
    border: 1px solid var(--border); margin-bottom: 6px; font-size: 13px;
}
.admin-user .au-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.badge {
    font-size: 8px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    background: color-mix(in srgb, var(--acc) 22%, transparent); color: var(--acc);
    border: 1px solid var(--acc); border-radius: 999px; padding: 1px 5px;
}
.avatar-sm.u-them { background: var(--them); color: #fff; }
#admin-add { display: flex; gap: 6px; margin-top: 8px; }
#admin-add input {
    flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
#admin-add input:focus { border-color: var(--acc); }
#admin-msg { font-size: 12px; margin-top: 7px; }
#admin-msg.ok { color: var(--them); }
#admin-msg.err { color: var(--danger); }

/* ---- floating tool windows (games, songs, users, …) ---- */
#games-win, #songs-win, #users-win, #call-win, #weather-win, #admin-win {
    display: none; position: fixed; z-index: 25; flex-direction: column;
    background: rgba(var(--win-rgb), var(--win-op));
    backdrop-filter: blur(var(--win-blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--win-blur)) saturate(1.3);
    border: 1px solid var(--border); border-top-color: var(--border-hi);
    border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
#games-win.open, #songs-win.open, #users-win.open, #call-win.open, #weather-win.open, #admin-win.open { display: flex; }
#games-header, #songs-header, #users-header, #call-header, #weather-header, #admin-header {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: var(--surface); border-bottom: 1px solid var(--border); min-height: 48px; flex: 0 0 auto;
}
#games-header .title, #songs-header .title, #users-header .title, #call-header .title, #weather-header .title, #admin-header .title { font-weight: 700; font-size: 14px; }
#games-header .spacer, #songs-header .spacer, #users-header .spacer, #call-header .spacer, #weather-header .spacer, #admin-header .spacer { flex: 1; }
#games-header button, #songs-header button, #users-header button, #call-header button, #weather-header button, #admin-header button {
    background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 14px;
    padding: 4px 9px; border-radius: 999px;
}
#games-header button:hover, #songs-header button:hover, #users-header button:hover, #call-header button:hover, #weather-header button:hover, #admin-header button:hover { background: var(--hover); color: var(--text); }
#admin-body { flex: 1; overflow-y: auto; padding: 14px; }
.win-sec {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
    color: var(--acc); margin: 14px 0 9px; display: flex; align-items: center; gap: 10px;
}
.win-sec:first-child { margin-top: 0; }
.win-sec::after { content: ''; flex: 1; height: 1px; background: var(--sep); }

/* ---- dungeon window ---- */
#dungeon-win {
    display: none; position: fixed; z-index: 25; flex-direction: column;
    background: rgba(var(--win-rgb), var(--win-op));
    backdrop-filter: blur(var(--win-blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--win-blur)) saturate(1.3);
    border: 1px solid var(--border); border-top-color: var(--border-hi);
    border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
#dungeon-win.open { display: flex; }
#dungeon-header {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: var(--surface); border-bottom: 1px solid var(--border); min-height: 48px; flex: 0 0 auto;
}
#dungeon-header .title { font-weight: 700; font-size: 14px; }
#dungeon-header .title .ico { width: 15px; height: 15px; vertical-align: -2px; color: var(--acc); margin-right: 10px; }
#dungeon-header .spacer { flex: 1; }
#dungeon-header button {
    background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 14px;
    padding: 4px 9px; border-radius: 999px;
}
#dungeon-header button:hover { background: var(--hover); color: var(--text); }
#dungeon-body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; background: #0a0a0e; }
.dg-stage { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.dg-cv { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; outline: none; }
.dg-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
.dg-logo { font-family: Georgia, serif; font-size: 42px; font-weight: 800; letter-spacing: .28em; color: #c8b89a; text-shadow: 0 0 24px rgba(200,120,50,.45); }
.dg-sub { color: var(--muted); font-size: 13px; }
.dg-classes { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.dg-class {
    width: 170px; padding: 16px 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border);
    border-radius: var(--r-lg); color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.dg-class:hover { background: rgba(255,255,255,.09); border-color: var(--acc); transform: translateY(-2px); }
.dg-class-ico { font-size: 30px; }
.dg-class small { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.dg-class em { color: #c8b89a; font-size: 11px; font-style: normal; }
.dg-lobby { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dg-hero { display: flex; gap: 12px; align-items: center; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; }
.dg-hero-ico { font-size: 28px; }
.dg-hero small { color: var(--muted); }
.dg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dg-runs-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--acc); margin-top: 6px; }
.dg-runs { display: flex; flex-direction: column; gap: 7px; }
.dg-run {
    display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 13px;
    background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: var(--r-md, 10px);
    color: var(--text); cursor: pointer; position: relative;
}
.dg-run:hover { background: rgba(255,255,255,.09); border-color: var(--acc); }
.dg-run small { color: var(--muted); }
.dg-run .dg-join { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--acc); font-weight: 700; font-size: 12px; }
.dg-dim { color: var(--muted); font-size: 12.5px; }
.dg-dim2 { color: var(--muted); }
.dg-help { color: var(--muted); font-size: 11.5px; line-height: 1.8; margin-top: auto; padding-top: 10px; }
.dg-help b { color: var(--text); font-weight: 600; }
.dg-inv {
    position: absolute; top: 0; right: 0; bottom: 0; width: 252px; z-index: 5;
    background: rgba(12,12,18,.93); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform .2s ease;
    display: flex; flex-direction: column; padding: 12px; gap: 9px; overflow-y: auto;
}
.dg-inv.open { transform: none; }
.dg-inv-head { color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dg-inv-head .dg-x { margin-left: auto; background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 13px; }
.dg-statrow { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: #c8c3d8; }
.dg-eq { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.dg-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.dg-cell {
    aspect-ratio: 1; border-radius: 7px; border: 1px solid #3a3a4a; background: rgba(255,255,255,.05);
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--text);
}
.dg-cell.empty { cursor: default; }
.dg-cell:not(.empty):hover { background: rgba(255,255,255,.13); }
.dg-cell.r0 { border-color: #71717f; }
.dg-cell.r1 { border-color: #5e8bff; box-shadow: 0 0 6px rgba(94,139,255,.35); }
.dg-cell.r2 { border-color: #ffd452; box-shadow: 0 0 6px rgba(255,212,82,.35); }
.dg-cell.r3 { border-color: #bf7dff; box-shadow: 0 0 8px rgba(191,125,255,.5); }
.dg-slot-ghost { opacity: .25; }
.dg-inv-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dg-gold { color: #ffd452; font-size: 12.5px; font-weight: 700; margin-right: auto; }
.dg-hint2 { color: var(--muted); font-size: 10.5px; }
.dg-tip {
    position: absolute; z-index: 40; display: none; max-width: 210px; pointer-events: none;
    background: rgba(10,10,16,.96); border: 1px solid #3a3a4a; border-radius: 8px; padding: 9px 11px;
    font-size: 11.5px; color: #d8d4e8; line-height: 1.55;
}
.dg-tip b { font-size: 12.5px; }
.dg-tip small { display: block; color: var(--muted); }
.dg-tip hr { border: none; border-top: 1px solid #33333f; margin: 6px 0; }
.dg-touch { position: absolute; right: 10px; bottom: 68px; z-index: 6; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.dg-tbtn {
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25);
    background: rgba(20,20,30,.55); font-size: 19px; cursor: pointer; touch-action: none;
}
.dg-tbtn.atk { width: 60px; height: 60px; font-size: 24px; }
html.mobile #dungeon-win.open {
    position: fixed !important; inset: 0 0 max(58px, var(--kb, 0px)) 0 !important;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none; box-shadow: none;
}

/* ---- weather window ---- */
#weather-place { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#weather-body { flex: 1; display: flex; flex-direction: column; position: relative; min-height: 0; }
#weather-map { flex: 1; min-height: 0; background: var(--panel-deep); }
#weather-msg { display: none; margin: auto; padding: 34px 24px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6; }
#weather-time {
    display: none; position: absolute; bottom: 14px; left: 12px; z-index: 1100;
    background: rgba(var(--win-rgb), .92); border: 1px solid var(--border); border-radius: 999px;
    padding: 4px 12px; font-size: 12px; font-weight: 600;
}
.leaflet-container { font-family: inherit; }
#settings .row-hint, #profile .row-hint { font-size: 11px; color: var(--muted); font-weight: 400; }
#pref-zip {
    width: 110px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
#pref-zip:focus { border-color: var(--acc); }

/* ---- call window ---- */
#call-body {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 16px; overflow: hidden;
}
#call-status { font-size: 13px; font-weight: 600; color: var(--muted-2); text-align: center; }
/* mic level meter (settings test + voice windows): gradient track, right-anchored dark mask shrinks as level rises */
.mic-meter {
    position: relative; height: 8px; border-radius: 999px; overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(90deg, #2ea86e, #d9c84a 65%, #d64545 92%);
}
.mic-meter-mask {
    position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
    background: rgba(12, 12, 18, .9); transition: width .05s linear;
}
.mic-test { display: flex; align-items: center; gap: 10px; flex: 1; }
.mic-test .mic-meter { flex: 1; }
#vid-test-wrap { display: none; margin: 8px 0 4px; }
#vid-test-wrap.on { display: block; }
#vid-test {
    width: 100%; max-height: 220px; border-radius: 10px; background: #000;
    transform: scaleX(-1); /* mirror like a selfie preview */ object-fit: cover;
}
.call-meter { width: 150px; margin: 8px auto 0; }
.lg-meter { width: 70px; align-self: center; }
.call-media { position: relative; flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
#remote-media { width: 100%; height: 100%; object-fit: contain; border-radius: var(--r-md); background: rgba(0,0,0,.35); cursor: pointer; }
#local-video { cursor: pointer; }
#remote-audio { display: none; }
#local-video {
    position: absolute; bottom: 10px; right: 10px; width: 120px; max-height: 90px;
    border-radius: 8px; border: 1px solid var(--border-hi); background: #000; object-fit: cover;
    box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.call-peer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.call-peer.in-media { position: absolute; inset: 0; justify-content: center; }
.call-avatar {
    width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 700; text-transform: uppercase;
    box-shadow: 0 8px 26px rgba(0,0,0,.4);
}
.call-avatar.u-them { background: var(--them); color: #fff; }
.call-name { font-size: 16px; font-weight: 700; }
.call-sub { font-size: 12.5px; color: var(--muted); }
.call-controls { display: flex; gap: 12px; flex: 0 0 auto; }
.call-btn {
    width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--input); color: var(--text); font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: transform .1s, background .12s;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn.off { background: color-mix(in srgb, var(--danger) 25%, transparent); border-color: var(--danger); }
.call-btn.on { background: color-mix(in srgb, var(--acc) 25%, transparent); border-color: var(--acc); color: var(--acc); }
.call-btn.hangup { background: var(--danger); border-color: var(--danger); color: #fff; }
.call-btn.accept { background: var(--them); border-color: var(--them); color: #fff; }

/* ---- users window ---- */
#users-body { flex: 1; overflow-y: auto; padding: 10px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: var(--r-md); }
.user-row:hover { background: var(--hover); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; min-width: 0; }
.user-name .un { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.user-name .badge { flex: 0 0 auto; line-height: 1.4; }
.user-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sep); flex: 0 0 auto; }
.status-dot.on { background: var(--them); box-shadow: 0 0 8px color-mix(in srgb, var(--them) 60%, transparent); }

/* ---- songs window ---- */
#songs-body { flex: 1; overflow-y: auto; padding: 12px; }
.songs-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 10px; line-height: 1.6; }
.songs-empty .big { font-size: 38px; margin-bottom: 8px; }
.song-row {
    display: flex; align-items: center; gap: 11px; padding: 8px 9px; border-radius: var(--r-md);
    margin-bottom: 4px;
}
.song-row:hover { background: var(--hover); }
.song-art-wrap { position: relative; width: 46px; height: 46px; flex: 0 0 auto; }
.song-art {
    width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex: 0 0 auto;
    border: 1px solid var(--border);
}
.song-play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .48); color: #fff; border-radius: 8px; font-size: 15px;
    opacity: 0; transition: opacity .12s; pointer-events: none;
}
.song-row:hover .song-play, .song-row.playing .song-play { opacity: 1; }
.song-art.ph { display: flex; align-items: center; justify-content: center; background: var(--input); font-size: 20px; }
.song-info { flex: 1; min-width: 0; }
.song-title {
    display: block; font-size: 13.5px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-open {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-2); text-decoration: none; font-size: 14px; font-weight: 700;
    background: var(--input); border: 1px solid var(--border);
    transition: color .12s, border-color .12s, transform .1s;
}
.song-open:hover { color: #1db954; border-color: #1db954; transform: scale(1.1); }
.song-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.song-votes { display: flex; gap: 5px; flex: 0 0 auto; }
.vote-pill {
    display: inline-flex; align-items: center; gap: 4px; background: var(--input); color: var(--text);
    border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; font-size: 13px;
    cursor: pointer; transition: border-color .12s, transform .1s;
}
.vote-pill:hover { transform: scale(1.08); border-color: var(--border-hi); }
.vote-pill.mine { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 20%, transparent); }
.song-row { cursor: pointer; }
.song-row.playing { background: color-mix(in srgb, var(--acc) 14%, transparent); }
.song-row.playing .song-title { color: var(--acc); }
#songs-player {
    display: none; flex: 0 0 auto; padding: 10px 12px 12px;
    border-top: 1px solid var(--border); background: var(--surface);
}
#songs-player iframe { display: block; border-radius: 12px; border: none; }
#sdk-bar { display: flex; align-items: center; gap: 10px; }
#sdk-bar[hidden] { display: none; }
.sdk-note { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sp-connect { font-size: 11px !important; padding: 4px 10px !important; }
#listen-btn.on { color: var(--acc); background: color-mix(in srgb, var(--acc) 18%, transparent); }
#listen-note { font-size: 11px; color: var(--muted); white-space: nowrap; }
#games-body {
    flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column;
    align-items: center; gap: 12px;
}
.game-status { font-size: 14px; font-weight: 700; letter-spacing: -.01em; text-align: center; }
.game-result { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.game-hint { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; text-align: center; }
/* prominent whose-turn banner (turn-based games) */
.turn-banner {
    font-size: 14px; font-weight: 800; letter-spacing: .02em; text-align: center;
    padding: 7px 16px; border-radius: 999px; line-height: 1;
}
.turn-banner.mine {
    color: var(--acc-text); background: var(--acc);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--acc) 60%, transparent);
    animation: turnPulse 1.5s ease-out infinite;
}
.turn-banner.wait { color: var(--muted); background: var(--input); border: 1px solid var(--border); font-weight: 700; }
@keyframes turnPulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--acc) 55%, transparent); }
    70% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--acc) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--acc) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .turn-banner.mine, #games-btn.has-dot::after { animation: none; } }
/* stats scoreboard */
.g-scorebar { display: flex; gap: 8px; width: 100%; max-width: 280px; }
.g-stat {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md);
}
.g-stat b { font-size: 24px; font-weight: 800; line-height: 1; }
.g-stat span { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.g-stat.win b { color: var(--them); }
.g-stat.loss b { color: var(--danger); }
.g-statlist { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 280px; }
.g-statrow {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 13px;
}
.gsr-ic { font-size: 17px; width: 22px; text-align: center; }
.gsr-nm { flex: 1; font-weight: 600; }
.gsr-rec { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.gsr-rec i { font-size: 9px; font-style: normal; color: var(--muted); font-weight: 700; margin: 0 3px 0 1px; }
.game-menu { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 260px; }
.game-menu button {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px; font-size: 14px; font-weight: 600;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md);
    color: var(--text); cursor: pointer; transition: border-color .12s, transform .1s;
}
.game-menu button:hover { border-color: var(--acc); transform: translateY(-1px); }
.gm-icon { font-size: 20px; }
.game-actions { display: flex; gap: 8px; margin-top: 4px; }
.ttt-grid { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px; }
.ttt-cell {
    width: 72px; height: 72px; font-size: 32px; font-weight: 800;
    background: var(--input); border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: border-color .12s;
}
.ttt-cell:not(:disabled):hover { border-color: var(--acc); }
.ttt-cell:disabled { cursor: default; }
.ttt-cell.x { color: var(--acc); }
.ttt-cell.o { color: var(--them); }
.c4-grid {
    display: grid; grid-template-columns: repeat(7, 38px); gap: 5px;
    background: var(--input); padding: 10px; border-radius: 14px; border: 1px solid var(--border);
}
.c4-cell {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--panel-deep); border: 1px solid var(--border);
}
.c4-cell.droppable { cursor: pointer; }
.c4-cell.droppable:hover { border-color: var(--acc); }
.c4-cell.r, .c4-dot.r { background: #e84545; border-color: transparent; }
.c4-cell.y, .c4-dot.y { background: #f0b232; border-color: transparent; }
.c4-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; }
.pong-cv {
    align-self: stretch; flex: 1 1 auto; min-height: 240px; width: 100%;
    background: rgba(0, 0, 0, .28); border: 1px solid var(--border); border-radius: 14px;
    cursor: crosshair;
}

/* ---- window manager ---- */
.wm-win { position: fixed !important; margin: 0; }
.wm-win.wm-moving {
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .4) !important;
    will-change: left, top, width, height;
    transition: none !important;
}
body.wm-dragging { user-select: none; }
body.wm-dragging iframe, body.wm-dragging #bg { pointer-events: none; }
.wm-h { position: absolute; z-index: 40; }
.wm-n { top: 0; left: 20px; right: 20px; height: 9px; cursor: ns-resize; }
.wm-s { bottom: 0; left: 20px; right: 20px; height: 9px; cursor: ns-resize; }
.wm-e { right: 0; top: 20px; bottom: 20px; width: 9px; cursor: ew-resize; }
.wm-w { left: 0; top: 20px; bottom: 20px; width: 9px; cursor: ew-resize; }
.wm-ne { top: 0; right: 0; width: 20px; height: 20px; cursor: nesw-resize; }
.wm-nw { top: 0; left: 0; width: 20px; height: 20px; cursor: nwse-resize; }
.wm-se { bottom: 0; right: 0; width: 20px; height: 20px; cursor: nwse-resize; }
.wm-sw { bottom: 0; left: 0; width: 20px; height: 20px; cursor: nesw-resize; }

#lightbox {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 8000;
    align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; animation: msgIn .15s ease-out; }

/* ---- custom dialogs & toasts ---- */
#dlg-overlay {
    display: none; position: fixed; inset: 0; z-index: 9000;
    background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    align-items: center; justify-content: center;
}
#dlg {
    background: var(--panel); border: 1px solid var(--border); border-top-color: var(--border-hi);
    border-radius: 14px; padding: 20px 22px; width: min(340px, 90vw);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: msgIn .16s ease-out;
}
#dlg-title { font-size: 14.5px; font-weight: 700; line-height: 1.45; }
#dlg-msg { font-size: 13px; color: var(--muted-2); margin-top: 6px; line-height: 1.5; }
#dlg-msg:empty { display: none; }
#dlg-input {
    width: 100%; margin-top: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13.5px; outline: none;
}
#dlg-input:focus { border-color: var(--acc); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.mini-btn.danger-btn { background: var(--danger); color: #fff; border-color: transparent; }
.mini-btn.danger-btn:hover { filter: brightness(1.1); color: #fff; }
#toasts { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 9500; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
    background: var(--panel); border: 1px solid var(--border); color: var(--text);
    border-radius: 999px; padding: 8px 18px; font-size: 13px; font-weight: 600;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .4); animation: msgIn .15s ease-out;
}

/* ---- minimized-call chip ---- */
#call-chip {
    display: none; position: fixed; right: 18px; bottom: 84px; z-index: 5500;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--acc); color: var(--acc-text); font-size: 22px;
    align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--acc) 50%, transparent);
    animation: chipPulse 1.6s infinite;
}
#call-chip.show { display: flex; }
@keyframes chipPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ---- post-game screen ---- */
.postgame { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 0 6px; }
.postgame .pg-emoji { font-size: 46px; }
.postgame .pg-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.postgame .pg-sub { font-size: 13px; color: var(--muted); }
/* post-game recap (poker showdown, tank HP, battleship shots…) */
.pg-summary { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 300px; }
.pg-recap { font-size: 13px; color: var(--text); text-align: center; background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md); padding: 9px 14px; }
.pg-recap b { font-weight: 800; font-variant-numeric: tabular-nums; }
.pg-recap-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--acc); }
.pg-hand { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; padding: 8px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--input); }
.pg-hand.win { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 12%, var(--input)); }
.pg-hn { font-size: 12.5px; font-weight: 700; }

/* ---- checkers ---- */
.chk-grid { display: grid; grid-template-columns: repeat(8, 36px); border: 2px solid var(--border); border-radius: 10px; overflow: hidden; }
.chk-cell { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #f0d9b5; border: none; padding: 0; cursor: default; }
.chk-cell.dark { background: #b58863; }
.chk-cell.sel { outline: 3px solid var(--acc); outline-offset: -3px; }
.chk-cell.mv { cursor: pointer; }
.chk-cell.mv::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--acc); opacity: .75; }
.chk-cell.cap { cursor: pointer; box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--danger) 75%, transparent); }
.chk-cell.chkd { background: color-mix(in srgb, var(--danger) 45%, #b58863); }
.ch-p { font-size: 26px; line-height: 1; cursor: pointer; user-select: none; }
.ch-p.w { color: #f6f3ea; text-shadow: 0 1px 1px rgba(0, 0, 0, .65); }
.ch-p.b { color: #1d1d22; text-shadow: 0 1px 1px rgba(255, 255, 255, .18); }
.gm-cat {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
    font-weight: 700; color: var(--acc); margin: 8px 0 2px; display: flex; align-items: baseline; gap: 8px;
}
.gm-cat:first-child { margin-top: 0; }
.gm-cat span { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 11px; }
.chk-man { width: 27px; height: 27px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3); cursor: pointer; }
.chk-man.a { background: #e84545; color: #fff; }
.chk-man.b { background: #2f3136; color: #f0b232; border: 1px solid #777; }

/* ---- battleship ---- */
.ships-wrap { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.ships-col { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.board-label { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.ships-grid { display: grid; grid-template-columns: repeat(8, 24px); gap: 2px; }
.sh-cell { width: 24px; height: 24px; border-radius: 4px; background: var(--input); border: 1px solid var(--border); padding: 0; }
.sh-cell.ship { background: var(--acc); border-color: transparent; }
.sh-cell.hit { background: #e84545; border-color: transparent; }
.sh-cell.miss { background: var(--sep); }
.sh-cell.aim { cursor: crosshair; }
.sh-cell.aim:hover { border-color: var(--acc); }
/* placement board + fleet tray */
.ships-grid.place .sh-cell { cursor: pointer; }
.sh-cell.pv-ok { background: color-mix(in srgb, var(--acc) 55%, transparent); border-color: var(--acc); }
.sh-cell.pv-bad { background: color-mix(in srgb, var(--danger) 45%, transparent); border-color: var(--danger); }
.sh-tray { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sh-pip { display: flex; gap: 2px; padding: 3px; border-radius: 5px; border: 1px solid var(--border); background: var(--input); }
.sh-pip i { width: 8px; height: 8px; border-radius: 2px; background: var(--muted-2); }
.sh-pip.done i { background: var(--acc); }
.sh-pip.done { border-color: var(--acc); }
.sh-pip.cur { border-color: var(--acc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc) 30%, transparent); }
.sh-pip.cur i { background: var(--muted); }

/* ---- games card menu ---- */
.gm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; width: 100%; }
.gm-card {
    display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md);
    color: var(--text); cursor: pointer; transition: border-color .12s, transform .1s;
}
.gm-card:hover { border-color: var(--acc); transform: translateY(-2px); }
.gm-head {
    display: flex; align-items: center; justify-content: space-between; padding: 13px 12px;
    font-size: 28px; line-height: 1; color: #fff;
    background: linear-gradient(135deg, hsl(var(--gh), 55%, 45%), hsl(var(--gh), 58%, 30%));
}
.gm-emoji { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.gm-pc { font-size: 11px; font-weight: 800; background: rgba(0, 0, 0, .32); border-radius: 999px; padding: 2px 8px; }
.gm-name { font-size: 14px; font-weight: 700; padding: 8px 12px 0; }
.gm-desc { font-size: 11.5px; color: var(--muted); padding: 2px 12px 12px; line-height: 1.35; }

/* ---- solo card games (blackjack / solitaire / freecell / poker) ---- */
.card-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pcard {
    width: 44px; height: 62px; border-radius: 6px; flex: 0 0 auto; position: relative;
    background: linear-gradient(158deg, #ffffff 0%, #f4f2ea 100%);
    border: 1px solid rgba(0, 0, 0, .2);
    box-shadow: 0 1.5px 2.5px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .7);
    font-weight: 800; line-height: 1; user-select: none;
}
.pcard.blk { color: #16161a; }
.pcard.red { color: #d81e3f; }
/* corner index: rank over suit, mirrored bottom-right */
.pc-ix { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .95; }
.pc-ix.tl { top: 3px; left: 4px; }
.pc-ix.br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.pc-ix b { font-size: 13px; letter-spacing: -.5px; }
.pc-ix i { font-size: 10px; font-style: normal; margin-top: 1px; }
.pc-pip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 25px; opacity: .9; }
.pcard.back {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0)),
        repeating-linear-gradient(45deg, var(--acc), var(--acc) 5px,
        color-mix(in srgb, var(--acc) 62%, #000) 5px, color-mix(in srgb, var(--acc) 62%, #000) 10px);
    border-color: rgba(255, 255, 255, .25);
}
.pcard.empty {
    background: rgba(128, 128, 128, .07); border: 1px dashed var(--border-hi); box-shadow: none;
    color: var(--muted-2); display: flex; align-items: center; justify-content: center; font-size: 20px; opacity: .55;
}
.pcard.sel-able { cursor: pointer; transition: transform .08s; }
.pcard.sel-able:hover { transform: translateY(-2px); }
.pcard.sel { outline: 2.5px solid var(--acc); outline-offset: 1px; box-shadow: 0 4px 12px color-mix(in srgb, var(--acc) 45%, transparent); z-index: 3; }
.pcard.held { outline: 2.5px solid var(--them); outline-offset: 1px; z-index: 3; }
.sol-top { display: flex; gap: 6px; justify-content: center; width: 100%; overflow-x: auto; padding-bottom: 2px; }
.sol-gap { flex: 0 0 10px; }
.sol-slot { width: 44px; min-height: 62px; flex: 0 0 auto; }
.sol-tab { display: flex; gap: 6px; justify-content: center; align-items: flex-start; width: 100%; overflow-x: auto; padding-bottom: 4px; }
.sol-col { display: flex; flex-direction: column; min-width: 44px; min-height: 62px; flex: 0 0 auto; }
/* overlap so each covered card still shows its top-index strip (face-down cards peek less) */
.sol-col .pcard.stacked { margin-top: -44px; }
.sol-col .pcard.stacked.back { margin-top: -50px; }
.sol-col .pcard.stacked:first-child { margin-top: 0; }

/* ---- game window polish: in-window messages + buttons ---- */
.gwin-confirm {
    position: absolute; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center;
    background: rgba(6, 6, 10, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: gwFade .14s ease;
}
@keyframes gwFade { from { opacity: 0; } to { opacity: 1; } }
.gwc-box {
    background: var(--panel); border: 1px solid var(--border-hi); border-radius: var(--r-lg);
    padding: 20px 22px; width: min(240px, 82%); text-align: center; box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
    animation: gwPop .16s ease;
}
@keyframes gwPop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.gwc-msg { font-size: 14.5px; font-weight: 600; color: var(--text); margin-bottom: 18px; line-height: 1.4; }
.gwc-actions { display: flex; gap: 8px; justify-content: center; }
.gwin-toast {
    position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 14px); z-index: 13;
    background: rgba(12, 12, 18, .94); color: #fff; padding: 9px 16px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; opacity: 0; transition: opacity .2s ease, transform .2s ease;
    pointer-events: none; box-shadow: 0 8px 22px rgba(0, 0, 0, .5); max-width: 88%; text-align: center;
}
.gwin-toast.show { opacity: 1; transform: translate(-50%, 0); }
/* chunky game buttons (confirm + game actions) — replaces the flat pill look */
.g-btn, #games-body .mini-btn, #games-body .game-actions button {
    padding: 9px 17px; font-size: 13px; font-weight: 700; border-radius: 10px; cursor: pointer;
    background: var(--input); border: 1px solid var(--border); color: var(--text);
    transition: transform .1s ease, border-color .12s, background .12s, filter .12s;
}
.g-btn:hover, #games-body .mini-btn:hover, #games-body .game-actions button:hover {
    border-color: var(--acc); transform: translateY(-1px); color: var(--text);
}
.g-btn.acc, #games-body .mini-btn.acc { background: var(--acc); color: var(--acc-text); border-color: transparent; }
.g-btn.acc:hover, #games-body .mini-btn.acc:hover { filter: brightness(1.08); color: var(--acc-text); }
.g-btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.g-btn.danger:hover { filter: brightness(1.08); color: #fff; }

/* ---- games nav: header back arrow + pinned footer action bar ---- */
#games-back { font-size: 16px; font-weight: 700; }
#games-back[hidden] { display: none; }
#games-foot {
    display: none; flex: 0 0 auto; gap: 8px; align-items: center; justify-content: center;
    padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface);
}
#games-foot.show { display: flex; }
#games-foot .mini-btn { flex: 1 1 0; max-width: 170px; }

/* ---- in-match scoreboard strip (players + head-to-head record + counters) ---- */
.g-match {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; max-width: 300px; padding: 10px 12px;
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md);
}
.g-mp { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.g-mp-nm { font-size: 12px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-mp-sub { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-vs { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.g-vs-ic { font-size: 17px; line-height: 1; }
.g-vs-rec { font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.g-vs-sub { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }

/* ---- dots & boxes ---- */
.dots-cv { width: 300px; height: 300px; max-width: 100%; background: var(--input); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; touch-action: manipulation; }

/* ---- tank duel ---- */
.tank-ctl { display: flex; gap: 10px 14px; align-items: center; font-size: 12px; color: var(--muted-2); flex-wrap: wrap; justify-content: center; width: 100%; }
.tank-ctl input[type="number"] { width: 62px; padding: 6px 8px; background: var(--panel-deep); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font: inherit; font-size: 13px; }
.tk-row { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.tk-row input[type="range"] { width: 96px; accent-color: var(--acc); cursor: pointer; touch-action: manipulation; }
.tk-val { min-width: 34px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.tank-ctl button:disabled, .tk-row input:disabled { opacity: .45; cursor: default; }

/* ---- reversi ---- */
.rv-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 3px; background: #1f7a46; border: 2px solid #14562f; border-radius: 10px; }
.rv-cell { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; background: #2a9159; border: none; border-radius: 3px; padding: 0; cursor: default; }
.rv-cell.rv-mv { cursor: pointer; }
.rv-cell.rv-mv::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, .32); }
.rv-cell.rv-mv:hover::after { background: rgba(255, 255, 255, .6); }
.rv-disc { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 -3px 4px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .4); }
.rv-disc.dark { background: radial-gradient(circle at 35% 30%, #4a4a52, #141417); }
.rv-disc.light { background: radial-gradient(circle at 35% 30%, #ffffff, #cfd2d8); }
.rv-tag { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.rv-tag.dark { background: #16161a; }
.rv-tag.light { background: #eaecef; border: 1px solid var(--border-hi); }

/* ---- gomoku ---- */
.gk-grid { display: grid; grid-template-columns: repeat(13, 24px); padding: 2px; background: #d9b477; border: 2px solid #a97e46; border-radius: 8px; max-width: 100%; }
.gk-cell { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: transparent; border: 1px solid rgba(120, 80, 30, .4); padding: 0; cursor: default; }
.gk-cell.gk-open { cursor: pointer; }
.gk-cell.gk-open:hover { background: rgba(255, 255, 255, .25); }
.gk-stone { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .35); }
.gk-stone.dark { background: radial-gradient(circle at 35% 30%, #4a4a52, #131316); }
.gk-stone.light { background: radial-gradient(circle at 35% 30%, #ffffff, #cdd0d6); }

/* ---- three-move fighters ---- */
.fgt-fighter { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 300px; padding: 8px 12px; background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md); }
.fgt-fighter.me { border-color: var(--acc); }
.fgt-nm { font-size: 13px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fgt-bars { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.fgt-hearts { font-size: 15px; letter-spacing: 1px; }
.fgt-hp { color: #e84545; }
.fgt-hp.lost { color: var(--sep); }
.fgt-stam { font-size: 11px; letter-spacing: 1px; }
.fgt-st { color: #f0b232; }
.fgt-st.empty { color: var(--sep); }
.fgt-hint, .fgt-chosen { font-size: 12px; color: var(--muted); text-align: center; max-width: 300px; line-height: 1.4; }
.fgt-chosen { font-weight: 700; color: var(--text); }
.fgt-acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; max-width: 300px; }
.fgt-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px; background: var(--input); border: 1px solid var(--border); border-radius: 10px; color: var(--text); cursor: pointer; font-weight: 700; font-size: 12.5px; transition: border-color .12s, transform .1s; }
.fgt-btn:hover:not(:disabled) { border-color: var(--acc); transform: translateY(-1px); }
.fgt-btn:disabled { opacity: .4; cursor: default; }
.fgt-ic { font-size: 22px; }
.fgt-cost { position: absolute; top: 5px; right: 8px; font-style: normal; font-size: 10px; color: var(--muted); font-weight: 700; }

/* ---- reaction duel ---- */
.rxn-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.rxn-pad { width: 100%; max-width: 320px; height: 200px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: #fff; cursor: pointer; user-select: none; text-align: center; padding: 12px; background: #3a3d44; transition: background .05s; }
.rxn-pad.wait { background: #b3402f; }
.rxn-pad.go { background: #2fae5f; }
.rxn-msg { font-size: 13px; color: var(--muted); text-align: center; min-height: 18px; }

/* ---- games UI kit: stat chips + subtle info lines (replaces bare paragraph text) ---- */
.g-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.g-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
    background: var(--input); border: 1px solid var(--border); border-radius: 999px;
    font-size: 11px; font-weight: 700; color: var(--muted); line-height: 1.35; white-space: nowrap;
}
.g-chip b { font-size: 12.5px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.g-chip.acc { border-color: color-mix(in srgb, var(--acc) 55%, transparent); }
.g-chip.acc b { color: var(--acc); }
.g-chip.win b { color: var(--them); }
.g-chip.danger { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.g-chip.danger b { color: var(--danger); }
.gc-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.g-info {
    display: flex; align-items: center; gap: 6px; max-width: 320px; text-align: center;
    font-size: 11px; color: var(--muted); line-height: 1.45; padding: 3px 11px;
    border-radius: 999px; background: color-mix(in srgb, var(--input) 60%, transparent);
}
.g-info::before { content: 'ⓘ'; opacity: .65; flex: 0 0 auto; }
.g-info b { color: var(--muted-2); font-weight: 700; }

/* blackjack / poker hand labels */
.bj-row { display: flex; align-items: center; gap: 8px; }
.bj-lab { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.bj-val {
    font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px;
    background: var(--input); border: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.bj-val.bust { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.bj-val.hot { color: var(--them); border-color: color-mix(in srgb, var(--them) 60%, transparent); }

/* games drag & drop (cards + board pieces) */
.g-drag-ghost { position: fixed; z-index: 9999; pointer-events: none; display: flex; flex-direction: column; opacity: .95; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .45)); }
.g-drag-ghost .pcard { margin-top: -44px; }
.g-drag-ghost .pcard:first-child { margin-top: 0; }
.g-drag-ghost .ch-p, .g-drag-ghost .chk-man { font-size: 30px; }
.pcard.drag-src, .ch-p.drag-src, .chk-man.drag-src { opacity: .35; }
.sol-slot.drop-ok .pcard:last-child, .sol-col.drop-ok .pcard:last-child { outline: 2px dashed color-mix(in srgb, var(--acc) 70%, transparent); outline-offset: 1px; }
.sol-slot.drop-hover .pcard:last-child, .sol-col.drop-hover .pcard:last-child { outline: 2.5px solid var(--acc); outline-offset: 1px; box-shadow: 0 0 12px color-mix(in srgb, var(--acc) 45%, transparent); }
.chk-cell.drop-hover { outline: 3px solid var(--acc); outline-offset: -3px; }

/* games hover move previews (ghost pieces) */
.c4-cell.ghost-r { background: color-mix(in srgb, #e84545 38%, var(--panel-deep)); border-color: #e84545; }
.c4-cell.ghost-y { background: color-mix(in srgb, #f0b232 38%, var(--panel-deep)); border-color: #f0b232; }
.ttt-grid.mine-x .ttt-cell:not(:disabled):hover::after { content: 'X'; color: var(--acc); opacity: .35; }
.ttt-grid.mine-o .ttt-cell:not(:disabled):hover::after { content: 'O'; color: var(--them); opacity: .35; }
.gk-grid.mine-dark .gk-cell.gk-open:hover, .gk-grid.mine-light .gk-cell.gk-open:hover { background: transparent; }
.gk-grid.mine-dark .gk-cell.gk-open:hover::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4a52, #131316); opacity: .55; }
.gk-grid.mine-light .gk-cell.gk-open:hover::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffffff, #cdd0d6); opacity: .7; }
.rv-grid.mine-dark .rv-cell.rv-mv:hover::after { width: 26px; height: 26px; background: radial-gradient(circle at 35% 30%, #4a4a52, #141417); opacity: .6; }
.rv-grid.mine-light .rv-cell.rv-mv:hover::after { width: 26px; height: 26px; background: radial-gradient(circle at 35% 30%, #ffffff, #cfd2d8); opacity: .75; }
.rv-cell.rv-flip .rv-disc { box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--acc) 85%, transparent), inset 0 -3px 4px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .4); }

/* ---- sidebar drawer (mobile) ---- */
#sb-toggle { display: none; background: none; border: none; color: var(--muted-2); font-size: 18px; cursor: pointer; padding: 4px 9px; border-radius: 999px; }
#sb-scrim { display: none; position: absolute; inset: 0; z-index: 75; background: rgba(0, 0, 0, .45); }

/* ---- mobile: clean fixed layout, no floating windows ---- */
html.mobile #sb-toggle { display: block; }
html.mobile body { padding: 0; }
html.mobile #app {
    position: fixed !important;
    /* bottom pulls up to sit above the keyboard when it's open (--kb), else clears the tab bar (58px) */
    inset: 0 0 max(58px, var(--kb, 0px)) 0 !important;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none; box-shadow: none;
}
/* while the keyboard is open the bottom tab bar is behind it — hide it so nothing peeks through */
html.mobile.kb-open #mtabs { display: none; }
html.mobile #sidebar {
    position: absolute; z-index: 80; top: 0; bottom: 0; left: 0; width: 232px;
    transform: translateX(-105%); transition: transform .2s ease;
    background: var(--panel); box-shadow: 8px 0 30px rgba(0, 0, 0, .35);
}
html.mobile #sidebar.open { transform: none; }
html.mobile #games-win.open, html.mobile #songs-win.open, html.mobile #users-win.open,
html.mobile #call-win.open, html.mobile #weather-win.open, html.mobile #admin-win.open {
    position: fixed !important; inset: 0 0 max(58px, var(--kb, 0px)) 0 !important;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none; box-shadow: none;
}
html.mobile .dock {
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    transform: none !important; flex-direction: row !important;
    border-radius: 0; justify-content: space-evenly; padding: 6px 4px !important; min-height: 56px;
    border-left: none; border-right: none; border-bottom: none;
}
html.mobile .dock-sep { display: none; }
html.mobile #me-chip span { display: none; }
html.mobile .dock button:hover, html.mobile .dock a:hover { transform: none; }
html.mobile #search-input { width: 100px; }
html.mobile #search-input:focus { width: 130px; }
html.mobile .msg { padding-right: 10px; }
/* touch-drag over text can start a selection and Chrome auto-scrolls to keep it in view,
   yanking the chat back up mid-scroll — selection is blocked only WHILE a pan gesture runs
   (chat.js toggles .no-select), so stationary long-press selection still works */
#chat.no-select, #chat.no-select * { -webkit-user-select: none !important; user-select: none !important; }
html.mobile .gutter-time { display: none; }
html.mobile #call-chip { bottom: 72px; }

/* ---- discord-style mobile shell ---- */
#mtabs, #apps-sheet { display: none; }
html.mobile .dock { display: none !important; }
html.mobile #mtabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 58px; z-index: 5000;
    background: var(--panel); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
#mtabs button {
    flex: 1; background: none; border: none; color: var(--muted); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 10px; font-weight: 700; font-family: inherit;
}
#mtabs button.on { color: var(--acc); }
#mtabs .ico { width: 22px; height: 22px; }
#mtabs .avatar-xs { width: 22px; height: 22px; font-size: 10px; }
html.mobile #apps-sheet.open {
    display: block; position: fixed; inset: 0 0 58px 0; z-index: 90;
    background: var(--page); padding: 20px 16px; overflow-y: auto;
}
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.app-tile {
    display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 20px 8px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.app-tile:active { background: var(--hover); }
.app-tile .ico { width: 26px; height: 26px; color: var(--acc); }
html.mobile #sidebar { width: 282px; border-radius: 0 18px 18px 0; padding: 14px 10px calc(16px + 58px); }
html.mobile .sb-item { padding: 11px 12px; font-size: 15px; border-radius: 12px; }
html.mobile .sb-label { font-size: 11px; margin: 18px 8px 7px; }
html.mobile #sb-dms .avatar-sm { width: 30px; height: 30px; }
html.mobile #chat-hide { display: none; }
html.mobile input, html.mobile textarea, html.mobile select { font-size: 16px !important; } /* <16px triggers mobile auto-zoom on focus */
html.mobile #settings, html.mobile #profile, html.mobile #chan-modal {
    width: 100%; height: 100%; max-height: 100%; border-radius: 0;
}
html.mobile .msg .attach img { max-width: 100%; }

/* ---- generic tool windows (gallery, whiteboard, watch) ---- */
.tool-win {
    display: none; position: fixed; z-index: 25; flex-direction: column;
    background: rgba(var(--win-rgb), var(--win-op));
    backdrop-filter: blur(var(--win-blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--win-blur)) saturate(1.3);
    border: 1px solid var(--border); border-top-color: var(--border-hi);
    border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.tool-win.open { display: flex; }
.tool-head {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    background: var(--surface); border-bottom: 1px solid var(--border); min-height: 52px; flex: 0 0 auto;
}
.tool-head .title { font-weight: 700; font-size: 14px; }
.tool-head .spacer { flex: 1; }
.tool-head > button:not(.mini-btn) {
    background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 14px;
    padding: 4px 9px; border-radius: 999px; min-width: 32px; min-height: 32px;
}
.tool-head > button:not(.mini-btn):hover { background: var(--hover); color: var(--text); }
.tool-body { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
html.mobile .tool-win.open {
    position: fixed !important; inset: 0 0 max(58px, var(--kb, 0px)) 0 !important;
    width: auto !important; height: auto !important; border-radius: 0; border: none; box-shadow: none;
}
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.gal-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); }
.gal-thumb:hover { border-color: var(--acc); }
#wb-cv { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; background: var(--panel-deep); }
#wb-erase.on { border-color: var(--acc); color: var(--acc); }
.yt-body { display: flex; flex-direction: column; padding: 0 !important; }
#yt-player { flex: 1; min-height: 0; }
#yt-player iframe { width: 100%; height: 100%; }
#yt-url { width: 200px; }
html.mobile .dock { overflow-x: auto; }

.msg .attach img.as-thumb { max-width: 140px; max-height: 140px; width: 140px; height: 140px; object-fit: cover; }
.stock-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-md); }
.stock-row:hover { background: var(--hover); }
.stock-sym { font-weight: 800; font-size: 13.5px; width: 84px; }
.stock-price { font-weight: 600; font-size: 13.5px; width: 90px; text-align: right; }
.stock-chg { font-size: 12px; font-weight: 700; width: 72px; text-align: right; }
.stock-chg.up { color: var(--them); }
.stock-chg.down { color: var(--danger); }
.stock-spark { flex: 1; height: 30px; min-width: 60px; }
.stock-x { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.stock-x:hover { color: var(--danger); }
#stock-sym { width: 150px; }
.stock-view { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.stock-view:hover { color: var(--acc); }
.stock-view .ico { width: 15px; height: 15px; vertical-align: -3px; }
#stock-chart { display: inline-flex; align-items: center; gap: 6px; padding: 6px 18px; white-space: nowrap; }
#stock-chart .ico { width: 14px; height: 14px; }
#stock-add { padding: 6px 10px; display: inline-flex; align-items: center; }
#stock-add .ico { width: 14px; height: 14px; }
/* stocks window tabs (Watchlist | Calendar) */
#stocks-tabs {
    display: flex; gap: 4px; padding: 6px 12px; flex: 0 0 auto;
    border-bottom: 1px solid var(--border); background: var(--surface);
}
#stocks-tabs button {
    background: none; border: none; color: var(--muted); cursor: pointer; font: inherit;
    font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
}
#stocks-tabs button:hover { background: var(--hover); color: var(--text); }
#stocks-tabs button.on { background: color-mix(in srgb, var(--acc) 18%, transparent); color: var(--acc); }
/* economic calendar */
.scal-month {
    font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); padding: 12px 4px 5px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.scal-month:first-child { padding-top: 2px; }
.scal-ev { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-md); border: 1px solid transparent; }
.scal-ev.past { opacity: .42; }
.scal-ev.soon { background: color-mix(in srgb, var(--acc) 9%, transparent); }
.scal-ev.today { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 14%, transparent); }
.scal-date { width: 64px; flex: 0 0 auto; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.scal-date small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.scal-name { flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scal-time { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scal-badge {
    flex: 0 0 auto; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 999px;
}
.scal-badge.fed { color: #a06ee0; background: color-mix(in srgb, #a06ee0 16%, transparent); }
.scal-badge.inflation { color: #f0a132; background: color-mix(in srgb, #f0a132 16%, transparent); }
.scal-badge.jobs { color: #4596e8; background: color-mix(in srgb, #4596e8 16%, transparent); }
.scal-badge.growth { color: #2fb46b; background: color-mix(in srgb, #2fb46b 16%, transparent); }
.scal-today-chip { flex: 0 0 auto; font-size: 9.5px; font-weight: 800; color: #fff; background: var(--acc); padding: 2px 7px; border-radius: 999px; }
.scal-note { font-size: 11px; color: var(--muted); padding: 10px 4px; }
/* detailed candle chart window */
#schart-ranges { flex: 0 0 auto; }
#schart-ranges button { padding: 6px 10px; min-height: 30px; }
#schart-tools {
    display: flex; align-items: center; gap: 6px; padding: 7px 12px; flex: 0 0 auto;
    border-bottom: 1px solid var(--border); background: var(--surface); overflow: hidden;
}
#schart-tools .spacer { flex: 1; }
#schart-tools .schart-ind { padding: 4px 11px; min-height: 26px; font-size: 11.5px; }
#schart-tools .schart-ind.on { border-color: var(--acc); color: var(--acc); }
#schart-type { flex: 0 0 auto; }
#schart-type button { padding: 3px 9px; min-height: 26px; }
#schart-type .ico { width: 15px; height: 15px; vertical-align: -3px; }
#schart-ohlc {
    font-size: 11.5px; font-weight: 600; color: var(--muted-2); margin-left: 10px;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#schart-body { flex: 1; min-height: 0; position: relative; }
#schart-cv { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }

#lounge-body { display: flex !important; padding: 0 !important; }
#lounge-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#lounge-bar { flex: 0 0 auto; display: flex; justify-content: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
#lounge-bar .call-btn { width: 40px; height: 40px; }
#lg-mute.on, #lg-cam.on, #lg-scr.on { background: color-mix(in srgb, var(--acc) 25%, transparent); border-color: var(--acc); color: var(--acc); }
#lg-mute.on { background: color-mix(in srgb, var(--danger) 22%, transparent); border-color: var(--danger); color: var(--danger); }
#lounge-chat { width: 230px; flex: 0 0 auto; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
#lounge-chat-head { padding: 8px 12px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
#lounge-chat-list { flex: 1; overflow-y: auto; padding: 8px 10px; min-height: 0; }
.lg-line { font-size: 12.5px; line-height: 1.45; margin-bottom: 5px; word-wrap: break-word; }
.lg-line b { font-weight: 700; }
#lounge-chat-input { flex: 0 0 auto; display: flex; gap: 5px; padding: 8px; border-top: 1px solid var(--border); }
#lg-text { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-deep); color: var(--text); font: inherit; font-size: 12.5px; outline: none; }
#lg-text:focus { border-color: var(--acc); }
#lg-send { background: none; border: none; color: var(--acc); cursor: pointer; padding: 4px 6px; }
html.mobile #lounge-body { flex-direction: column !important; }
html.mobile #lounge-main { flex: 0 0 auto; }
html.mobile #lounge-tiles { max-height: 34vh; grid-template-columns: repeat(2, 1fr); padding: 10px; }
html.mobile #lounge-bar { padding: 8px; }
html.mobile #lounge-bar .call-btn { width: 36px; height: 36px; }
html.mobile #lounge-chat { width: auto; flex: 1 1 auto; min-height: 0; border-left: none; border-top: 1px solid var(--border); }
#lounge-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; flex: 1; overflow-y: auto; padding: 12px; align-content: start; }
.lounge-tile {
    position: relative; aspect-ratio: 16/10; border-radius: 12px; overflow: hidden;
    background: rgba(0,0,0,.35); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}
.lounge-tile video { width: 100%; height: 100%; object-fit: cover; }
.lt-ctl {
    position: absolute; left: 8px; right: 8px; bottom: 28px; z-index: 3;
    display: flex; gap: 6px; align-items: center;
    opacity: 0; transition: opacity .15s;
}
.lounge-tile:hover .lt-ctl, .lounge-tile.flagged .lt-ctl { opacity: 1; }
.lt-btn {
    width: 26px; height: 26px; border-radius: 50%; border: none; flex: 0 0 auto;
    background: rgba(10, 10, 16, .72); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
}
.lt-btn:hover { background: rgba(30, 30, 42, .9); }
.lt-btn.off { color: #f23f42; }
.lt-btn .ico { width: 13px; height: 13px; }
.lt-ctl .lt-vol { flex: 1; min-width: 0; accent-color: var(--acc); }
.call-media .media-vol {
    position: absolute; right: 12px; bottom: 12px; width: 120px; z-index: 3;
    opacity: 0; transition: opacity .15s; accent-color: var(--acc);
}
.call-media:hover .media-vol { opacity: 1; }
.user-row.dm-able { cursor: pointer; }
.user-row.dm-able:hover { background: var(--hover); }

/* settings tabs */
#set-tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--sep); }
#set-tabs button {
    background: none; border: none; color: var(--muted); padding: 8px 13px; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
#set-tabs button:hover { color: var(--text); }
#set-tabs button.on { color: var(--text); border-bottom-color: var(--acc); }
.set-pane { display: none; }
.set-pane.on { display: block; }
#grid-overlay { position: fixed; inset: 0; z-index: 1; pointer-events: none; display: none; }
.lounge-tile .lt-name {
    position: absolute; left: 8px; bottom: 6px; font-size: 11px; font-weight: 700; color: #fff;
    background: rgba(0,0,0,.55); border-radius: 999px; padding: 2px 9px;
}
.lounge-tile .call-avatar { width: 56px; height: 56px; font-size: 24px; }

/* ---- replies ---- */
#reply-chip {
    display: none; margin: 0 18px 6px; background: var(--panel); border-left: 3px solid var(--acc);
    border-radius: 8px; padding: 7px 12px; font-size: 12.5px; color: var(--muted-2);
    align-items: center; gap: 10px; width: fit-content; max-width: 90%;
}
#reply-chip button { background: none; border: none; color: var(--danger); cursor: pointer; }
#reply-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-ref {
    font-size: 12px; color: var(--muted-2); margin-bottom: 2px; cursor: pointer;
    border-left: 2px solid var(--acc); padding: 1px 8px; border-radius: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px;
}
.reply-ref:hover { background: var(--hover); }
.reply-ref .rn { font-weight: 700; color: var(--acc); }
.msg.flash { animation: msgFlash 1.2s ease; }
@keyframes msgFlash { 0%, 60% { background: color-mix(in srgb, var(--acc) 22%, transparent); } 100% { background: transparent; } }

/* ---- pins ---- */
#pins-btn, #wb-open, #yt-open, #songs-open, #gif-btn, #mic-btn {
    color: var(--muted-2); background: none; border: none; cursor: pointer; padding: 4px 9px;
    border-radius: 999px; font-size: 14px; min-width: 32px; min-height: 32px;
}
#pins-btn:hover, #wb-open:hover, #yt-open:hover, #songs-open:hover, #gif-btn:hover, #mic-btn:hover { background: var(--hover); color: var(--text); }
#gif-btn { font-size: 11px; font-weight: 800; letter-spacing: .03em; }
#mic-btn.rec { color: var(--danger); animation: chipPulse 1.2s infinite; }
.pin-mark { font-size: 10px; margin-left: 6px; }
#pin-banner {
    display: none; align-items: center; gap: 9px; padding: 7px 16px;
    background: color-mix(in srgb, var(--acc) 10%, var(--surface));
    border-bottom: 1px solid var(--border); border-left: 3px solid var(--acc);
    font-size: 12.5px; cursor: pointer; flex: 0 0 auto; min-width: 0;
}
#pin-banner:hover { background: color-mix(in srgb, var(--acc) 16%, var(--surface)); }
#pin-banner .ico { width: 13px; height: 13px; color: var(--acc); flex: 0 0 auto; }
#pin-banner-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pin-banner-text b { color: var(--acc); }
#pin-banner-more { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--muted); }

#pins-panel {
    display: none; position: absolute; top: 56px; right: 12px; width: min(430px, 92vw);
    max-height: 68vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 12px; z-index: 15; box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
#pins-panel .shead { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
#pins-panel .msg { display: block; padding: 6px 8px; margin-top: 2px; cursor: pointer; }
#pins-panel .msg:hover { background: var(--hover); }

/* ---- link previews / gifs / voice ---- */
.link-card {
    display: flex; gap: 10px; margin-top: 6px; max-width: 440px;
    background: var(--input); border: 1px solid var(--border); border-left: 3px solid var(--acc);
    border-radius: 10px; padding: 9px 12px; text-decoration: none; color: var(--text);
}
.link-card:hover { border-color: var(--acc); }
.link-card .lc-txt { flex: 1; min-width: 0; }
.link-card .lc-title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card .lc-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card img { width: 62px; height: 62px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.msg-gif { max-width: min(320px, 85%); max-height: 240px; border-radius: 10px; margin-top: 4px; display: block; border: 1px solid var(--border); }
.msg audio { margin-top: 5px; max-width: 300px; width: 100%; height: 38px; display: block; }
#gif-panel {
    display: none; position: absolute; bottom: 76px; left: 16px; right: 16px; max-height: 300px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 10px; z-index: 20; box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
    flex-direction: column; gap: 8px;
}
#gif-panel.open { display: flex; }
#accent-ctl.dim { opacity: .4; pointer-events: none; }
#gif-q {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-deep); color: var(--text); font: inherit; font-size: 13.5px; outline: none;
}
#gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; overflow-y: auto; }
#gif-grid img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; cursor: pointer; }
#gif-grid img:hover { outline: 2px solid var(--acc); }
.gif-attrib { font-size: 10px; color: var(--muted); text-align: right; } /* required by KLIPY's API terms */

/* ---- normalization pass: one metric system for inputs, buttons, headers ---- */
#search-input, #pw-form input, #admin-add input, #pref-zip, #prof-login, #prof-display,
#bg-select, .tank-ctl input[type="number"], #text {
    font-size: 13.5px;
}
#pw-form input, #admin-add input, #pref-zip, #prof-login, #prof-display, #prof-status, #yt-url, #stock-sym, #bg-select, .tank-ctl input[type="number"] {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-deep); color: var(--text); font-family: inherit; outline: none;
    transition: border-color .12s, box-shadow .12s;
}
#pw-form input:focus, #admin-add input:focus, #pref-zip:focus, #prof-login:focus, #prof-display:focus,
#bg-select:focus, .tank-ctl input[type="number"]:focus, #search-input:focus, #stock-sym:focus, #yt-url:focus {
    border-color: var(--acc);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 18%, transparent);
}
#pref-zip { width: 120px; }
#prof-login, #prof-display { width: 176px; }
.mini-btn, .seg button { min-height: 32px; }
#settings input[type="color"] { width: 40px; height: 32px; border-radius: 8px; }
#header, #games-header, #songs-header, #users-header, #call-header, #weather-header, #admin-header { min-height: 52px; padding: 8px 14px; }
#header { padding-left: 16px; }
#games-header button, #songs-header button, #users-header button, #call-header button, #weather-header button, #admin-header button,
#settings-btn, #chat-hide, #dm-voice-btn, #dm-video-btn { min-width: 32px; min-height: 32px; }

/* ---- boot: everything fades up once the layout is positioned ---- */
#app, .dock, #call-chip { opacity: 0; }
html.ready #app, html.ready #call-chip { animation: appIn .5s ease forwards; }
/* dock fades WITHOUT transform — it's centered via auto-margins and a residual animation
   transform would knock it off-center */
html.ready .dock { animation: fadeIn .5s ease forwards; }
/* tool windows restored on load fade up in sync with the app (boot-in is stripped after the animation) */
.wm-win.boot-in { opacity: 0; }
html.ready .wm-win.boot-in { animation: appIn .5s ease forwards; }
@keyframes appIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- analytics ---- */
/* admin-only Analytics window — reuses .tool-win / .tool-head / .seg chrome */
#analytics-win { z-index: 26; }
#analytics-tabs {
    flex: 0 0 auto; width: 100%; border: none; border-radius: 0; border-bottom: 1px solid var(--border);
    background: var(--surface); overflow-x: auto;
}
#analytics-tabs button {
    flex: 1; min-width: max-content; background: none; color: var(--muted); border-radius: 0;
    padding: 9px 14px; border-bottom: 2px solid transparent; white-space: nowrap;
}
#analytics-tabs button:hover { color: var(--text); background: var(--hover); }
#analytics-tabs button.on { background: none; color: var(--acc); border-bottom-color: var(--acc); }
#an-range { flex: 0 0 auto; }
#an-range button { padding: 5px 11px; font-size: 11.5px; }
#analytics-body { padding: 14px 16px 20px; }

/* stat tiles */
.an-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 9px; margin-bottom: 4px;
}
.an-tile {
    background: var(--input); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 13px;
}
.an-tile-v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.an-tile-l { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* line charts */
canvas.an-chart { display: block; width: 100%; height: 190px; }

/* horizontal bar ranking */
.an-bars { display: flex; flex-direction: column; gap: 7px; }
.an-bar { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.an-bar-lbl { flex: 0 0 128px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-bar-track { flex: 1; height: 12px; background: var(--input); border-radius: 999px; overflow: hidden; }
.an-bar-fill {
    display: block; height: 100%; min-width: 3px; border-radius: 999px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--acc) 72%, transparent), var(--acc));
}
.an-bar-cnt { flex: 0 0 auto; width: 52px; text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* activity heatmap */
.an-heatwrap { display: flex; flex-direction: column; gap: 9px; }
.an-heat {
    display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center;
}
.an-heat-day { font-size: 10.5px; color: var(--muted); padding-right: 7px; text-align: right; }
.an-heat-cell { aspect-ratio: 1; border-radius: 3px; min-width: 0; }
.an-heat-corner { }
.an-heat-hr { font-size: 9px; color: var(--muted); text-align: center; }
.an-heat-legend { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--muted); }
.an-heat-bar { width: 120px; height: 10px; border-radius: 999px; border: 1px solid var(--border); }

/* tables */
table.an-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.an-tbl th, table.an-tbl td {
    text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
table.an-tbl thead th {
    position: sticky; top: 0; z-index: 1; background: var(--panel-deep); color: var(--muted);
    font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
table.an-tbl th.num, table.an-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.an-tbl tbody tr:nth-child(even) { background: var(--hover-pre); }
table.an-tbl tbody tr:hover { background: var(--hover); }
.an-user { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.an-user .avatar-sm { width: 22px; height: 22px; font-size: 10px; flex: 0 0 auto; }
.an-user .an-uname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.an-badge {
    font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 999px;
}
.an-badge.ok { color: var(--them); background: color-mix(in srgb, var(--them) 18%, transparent); border: 1px solid var(--them); }
.an-badge.fail { color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, transparent); border: 1px solid var(--danger); }

/* misc states */
.an-state { color: var(--muted); font-size: 13px; padding: 26px 6px; text-align: center; }
.an-state.err { color: var(--danger); }
.an-empty { color: var(--muted); font-size: 12px; padding: 8px 2px; }
.an-note { color: var(--muted); font-size: 11px; margin-top: 10px; line-height: 1.5; }
