/* Wi MSG — Apple-like design language: system type, frosted surfaces,
   hairline separators, restrained color. Theme via [data-theme] or system. */

:root {
  --bg: #f2f2f7; --panel: #ffffff; --glass: rgb(255 255 255 / 78%);
  --border: rgb(60 60 67 / 13%); --hairline: rgb(60 60 67 / 22%);
  --text: #000000; --muted: #8e8e93;
  --accent: #0a84ff; --accent-2: #4aa3ff; --accent-soft: rgb(10 132 255 / 10%);
  --hover: rgb(120 120 128 / 10%); --active: #0a84ff;
  --chat-bg: #eef0f4;
  --bubble: #e9e9eb; --bubble-text: #000000;
  --mine: linear-gradient(180deg, #3d9bff, #0a84ff); --mine-flat: #0a84ff;
  --mine-text: #ffffff; --mine-meta: rgb(255 255 255 / 75%);
  --danger: #ff3b30; --online: #30d158;
  --shadow: 0 1px 2px rgb(0 0 0 / 7%);
  --shadow-lg: 0 12px 48px rgb(0 0 0 / 18%);
  --tile-filter: none; --tile-opacity: .05;
}
:root[data-theme='dark'] {
  --bg: #000000; --panel: #1c1c1e; --glass: rgb(28 28 30 / 78%);
  --border: rgb(84 84 88 / 34%); --hairline: rgb(84 84 88 / 55%);
  --text: #ffffff; --muted: #98989f;
  --accent: #0a84ff; --accent-2: #4aa3ff; --accent-soft: rgb(10 132 255 / 18%);
  --hover: rgb(120 120 128 / 18%); --active: #0a84ff;
  --chat-bg: #0b0b0d;
  --bubble: #26252a; --bubble-text: #ffffff;
  --mine: linear-gradient(180deg, #2b8fff, #0a6de0); --mine-flat: #0a84ff;
  --mine-text: #ffffff; --mine-meta: rgb(255 255 255 / 70%);
  --shadow: 0 1px 3px rgb(0 0 0 / 50%);
  --shadow-lg: 0 12px 48px rgb(0 0 0 / 60%);
  --tile-filter: invert(1); --tile-opacity: .06;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000; --panel: #1c1c1e; --glass: rgb(28 28 30 / 78%);
    --border: rgb(84 84 88 / 34%); --hairline: rgb(84 84 88 / 55%);
    --text: #ffffff; --muted: #98989f;
    --accent: #0a84ff; --accent-2: #4aa3ff; --accent-soft: rgb(10 132 255 / 18%);
    --hover: rgb(120 120 128 / 18%); --active: #0a84ff;
    --chat-bg: #0b0b0d;
    --bubble: #26252a; --bubble-text: #ffffff;
    --mine: linear-gradient(180deg, #2b8fff, #0a6de0); --mine-flat: #0a84ff;
    --mine-text: #ffffff; --mine-meta: rgb(255 255 255 / 70%);
    --shadow: 0 1px 3px rgb(0 0 0 / 50%);
    --shadow-lg: 0 12px 48px rgb(0 0 0 / 60%);
    --tile-filter: invert(1); --tile-opacity: .06;
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: rgb(128 128 128 / 30%) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgb(128 128 128 / 30%); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

html, body { height: 100%; }
body {
  margin: 0; color: var(--text); background: var(--bg); overflow: hidden;
  font: 15px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em;
}
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 14px; }
.busy { color: var(--muted); font-size: 14px; }
button { font-family: inherit; color: inherit; transition: filter .12s, background .15s, transform .1s, opacity .15s; }
button:active { transform: scale(.96); }
.ic { display: block; flex: none; }

@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { filter: brightness(1.25); } }
@keyframes tdot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= auth ================= */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background:
    radial-gradient(1100px 520px at 85% -10%, rgb(10 132 255 / 10%), transparent 70%),
    radial-gradient(900px 520px at -10% 110%, rgb(94 92 230 / 9%), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 384px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 22px; padding: 30px 28px; box-shadow: var(--shadow-lg);
  animation: popIn .25s ease-out;
}
.auth-logo {
  width: 76px; height: 76px; margin: 0 auto; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow);
}
.auth-logo img { width: 100%; height: 100%; object-fit: cover; }
.auth-card h1 { margin: 14px 0 2px; text-align: center; letter-spacing: -.03em; font-size: 26px; }
.auth-sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 13px; }
.tabs, .segmented { display: flex; gap: 2px; background: var(--hover); padding: 2px; border-radius: 10px; }
.tabs { margin-bottom: 18px; }
.tab, .segmented button {
  flex: 1; padding: 7px 8px; border: none; background: transparent; color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.tab.active, .segmented button.active { background: var(--panel); box-shadow: var(--shadow); }
form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
form input {
  width: 100%; margin-top: 4px; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg); color: var(--text); font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft); }
.hint { font-size: 11px; }
.warn-note { font-size: 12px; color: var(--muted); background: var(--accent-soft); padding: 9px 11px; border-radius: 12px; }
.btn {
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn.primary { background: var(--accent); border: none; color: #fff; }
form .btn.primary { width: 100%; padding: 12px; font-size: 15px; }
.btn:hover { filter: brightness(1.05); }

/* ================= layout ================= */
.app { display: flex; height: 100dvh; }

/* ---- sidebar ---- */
.sidebar {
  width: 372px; min-width: 264px; max-width: 40vw; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: relative; }
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%; padding: 8px 14px; border: none; border-radius: 10px;
  background: var(--hover); color: var(--text); font-size: 15px;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 8px; border-radius: 10px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--hover); color: var(--accent); }
.dropdown {
  position: absolute; top: 50px; right: 8px; z-index: 30; min-width: 230px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 5px; display: flex; flex-direction: column;
  animation: popIn .14s ease-out;
}
.dropdown button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--text); text-align: left; font-size: 14px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.dropdown button .ic { color: var(--muted); }
.dropdown button:hover { background: var(--hover); }
.dropdown.ctx { position: fixed; top: 0; left: 0; right: auto; }

.chat-list { overflow-y: auto; padding: 2px 0; }
.side-section { border-top: 1px solid var(--border); overflow-y: auto; }
.side-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 16px 4px; display: flex; align-items: center; gap: 8px;
}
.conn { width: 7px; height: 7px; border-radius: 50%; display: inline-block; transition: background .3s; }
.conn.online { background: var(--online); }
.conn.offline { background: var(--danger); }

.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; cursor: pointer;
  border-radius: 12px; margin: 1px 6px; transition: background .12s;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); color: #fff; }
.chat-item.active .ci-preview, .chat-item.active .ci-time, .chat-item.active .ci-name { color: #fff; }
.ci-body { flex: 1; min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 8px; }
.ci-name { font-weight: 590; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.ci-bottom { display: flex; align-items: center; gap: 8px; }
.ci-preview { flex: 1; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-preview.online-text, .typing-preview { color: var(--accent); }
.typing-preview { font-style: italic; }
.ci-pin { flex: none; color: var(--muted); display: inline-flex; }
.chat-item.active .ci-pin { color: #fff; }
.ci-badge {
  flex: none; min-width: 21px; height: 21px; border-radius: 11px; background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.chat-item.active .ci-badge { background: #fff; color: var(--accent); }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 600; user-select: none;
  background: linear-gradient(135deg, #7fa7e8, #4a76c9);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.online::after {
  content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--panel);
}
#me-avatar { width: 36px; height: 36px; font-size: 13px; }

.job-tag {
  flex: none; font-size: 11px; font-weight: 590; line-height: 1;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 7px; padding: 3px 7px; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item.active .job-tag { color: #fff; background: rgb(255 255 255 / 24%); }
.edit-job { opacity: 0; transition: opacity .12s; }
.chat-item:hover .edit-job { opacity: .9; }

/* ---- chat area & wallpapers ---- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--chat-bg); }
.chat::before { content: ''; position: absolute; inset: 0; pointer-events: none; }
.chat.wp-logo::before {
  background-image: url('/icons/wito-tile.png');
  background-size: 150px; opacity: var(--tile-opacity); filter: var(--tile-filter);
}
.chat.wp-gradient { background: linear-gradient(165deg, #b5c8de 0%, #a0b8d2 45%, #8fabc9 100%); }
:root[data-theme='dark'] .chat.wp-gradient { background: linear-gradient(165deg, #1d1b29 0%, #17151f 50%, #100f16 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chat.wp-gradient { background: linear-gradient(165deg, #1d1b29 0%, #17151f 50%, #100f16 100%); } }
.chat.wp-plain { background: var(--chat-bg); }
.chat.wp-blue { background: linear-gradient(170deg, #d8e8fa, #bcd6f2); }
:root[data-theme='dark'] .chat.wp-blue { background: linear-gradient(170deg, #0d1a2b, #0a1522); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chat.wp-blue { background: linear-gradient(170deg, #0d1a2b, #0a1522); } }
.chat.wp-mint { background: linear-gradient(170deg, #dcf2e4, #c2e6d2); }
:root[data-theme='dark'] .chat.wp-mint { background: linear-gradient(170deg, #0c1f16, #091810); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chat.wp-mint { background: linear-gradient(170deg, #0c1f16, #091810); } }
.chat > * { position: relative; }

.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.empty-pill {
  background: var(--glass); backdrop-filter: blur(12px); color: var(--muted);
  border: 1px solid var(--border); padding: 7px 16px; border-radius: 16px; font-size: 14px;
}
.chat-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 7px 14px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--border); z-index: 5;
}
.chat-head .avatar { width: 38px; height: 38px; }
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-info strong { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub.online-text { color: var(--accent); }
.icon-btn.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 12px 7% 8px; display: flex; flex-direction: column; }
.day-sep {
  align-self: center; font-size: 12px; font-weight: 590; color: var(--muted);
  background: var(--glass); border: 1px solid var(--border); backdrop-filter: blur(10px);
  border-radius: 12px; padding: 3px 11px; margin: 10px 0 6px;
  position: sticky; top: 4px; z-index: 3;
}

.msg-row { position: relative; display: flex; gap: 8px; align-items: flex-end; max-width: min(480px, 86%); margin-bottom: 2.5px; }
.msg-row.anim { animation: msgIn .18s ease-out; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar { width: 32px; height: 32px; font-size: 12px; margin-bottom: 3px; }
.msg-row.chain .avatar { visibility: hidden; }

.bubble {
  position: relative; background: var(--bubble); color: var(--bubble-text);
  border-radius: 17px; padding: 7px 11px 6px; box-shadow: var(--shadow);
  min-width: 68px; max-width: 100%;
}
.msg-row:not(.mine):not(.chain) .bubble { border-bottom-left-radius: 5px; }
.msg-row.mine:not(.chain) .bubble { border-bottom-right-radius: 5px; }
.msg-row:not(.mine):not(.chain) .bubble::after {
  content: ''; position: absolute; left: -6.5px; bottom: 0; width: 9px; height: 13px;
  background: var(--bubble); clip-path: path('M9 0 C8 6.5 5 10 0 13 L9 13 Z');
}
.msg-row.mine:not(.chain) .bubble::after {
  content: ''; position: absolute; right: -6.5px; bottom: 0; width: 9px; height: 13px;
  background: var(--mine-flat); clip-path: path('M0 0 C1 6.5 4 10 9 13 L0 13 Z');
}
.mine .bubble { background: var(--mine); color: var(--mine-text); }
.msg-sender { font-size: 12.5px; font-weight: 600; margin-bottom: 1px; }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg-text a { color: var(--accent); text-decoration-thickness: 1px; }
.mine .msg-text a { color: inherit; font-weight: 500; }
.msg-meta {
  float: right; margin: 7px -4px 0 8px; font-size: 10.5px; color: var(--muted);
  display: flex; gap: 3px; align-items: center; font-variant-numeric: tabular-nums;
}
.mine .msg-meta { color: var(--mine-meta); }
.msg-meta .tick { font-size: 11px; }

.quick-reply {
  position: absolute; top: 50%; transform: translateY(-50%); border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--border);
  color: var(--muted); opacity: 0; transition: opacity .12s;
}
.msg-row:not(.mine) .quick-reply { right: -40px; }
.msg-row.mine .quick-reply { left: -40px; }
.msg-row:hover .quick-reply { opacity: 1; }
.quick-reply:hover { color: var(--accent); }

.reply-quote {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 7px; padding: 3px 8px; margin-bottom: 4px; cursor: pointer; overflow: hidden;
}
.mine .reply-quote { border-left-color: rgb(255 255 255 / 80%); background: rgb(255 255 255 / 16%); }
.rq-name { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.mine .rq-name { color: #fff; }
.rq-text { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .8; }

.msg-row.flash .bubble { outline: 2px solid var(--accent); }

.delivery-status {
  align-self: flex-end; font-size: 11px; font-weight: 500; color: var(--muted);
  margin: 0 8px 4px 0; animation: fadeIn .2s;
}

/* media */
.media-img, .media-video {
  display: block; max-width: 320px; max-height: 340px; width: 100%;
  border-radius: 12px; margin: 2px 0 4px; cursor: pointer; object-fit: cover; background: rgb(0 0 0 / 8%);
}
.media-img { transition: filter .15s; }
.media-img:hover { filter: brightness(.93); }
.media-video { cursor: default; }
.media-placeholder {
  width: 260px; height: 180px; border-radius: 12px; margin: 2px 0 4px;
  background: rgb(0 0 0 / 7%); display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.spinner { width: 24px; height: 24px; border: 2.5px solid rgb(128 128 128 / 25%); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }

.file-card { display: flex; align-items: center; gap: 10px; padding: 4px 2px; cursor: pointer; min-width: 200px; }
.file-icon {
  width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.mine .file-icon { background: rgb(255 255 255 / 22%); }
.file-info { min-width: 0; }
.file-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.file-size { font-size: 12.5px; color: var(--muted); }
.mine .file-size { color: var(--mine-meta); }

.voice-player { display: flex; align-items: center; gap: 10px; padding: 4px 2px; min-width: 230px; }
.vp-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; flex: none;
  background: var(--accent); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.mine .vp-btn { background: rgb(255 255 255 / 22%); }
.vp-bars { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; flex: 1; }
.vp-bars i { width: 3px; border-radius: 2px; background: rgb(128 128 128 / 35%); transition: background .15s; }
.vp-bars i.on { background: var(--accent); }
.mine .vp-bars i { background: rgb(255 255 255 / 35%); }
.mine .vp-bars i.on { background: #fff; }
.vp-time { font-size: 12px; color: var(--muted); flex: none; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.mine .vp-time { color: var(--mine-meta); }

/* skeletons / empty */
.skel {
  background: linear-gradient(100deg, rgb(128 128 128 / 12%) 40%, rgb(128 128 128 / 22%) 50%, rgb(128 128 128 / 12%) 60%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.skel-row .bubble.skel { box-shadow: none; }
.chat-welcome {
  align-self: center; margin: auto; text-align: center; color: var(--muted);
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--border);
  border-radius: 20px; padding: 22px 26px; max-width: 300px; animation: popIn .25s ease-out;
}
.cw-emoji { font-size: 38px; margin-bottom: 8px; }
.cw-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; color: var(--text); }
.cw-text { font-size: 13px; }

.typing { min-height: 20px; padding: 0 7% 2px; font-size: 12.5px; color: var(--muted); }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: middle; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: tdot 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }

.scroll-down {
  position: absolute; right: 18px; bottom: 92px; min-width: 42px; height: 42px; border-radius: 21px;
  background: var(--glass); backdrop-filter: blur(16px); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer; box-shadow: var(--shadow-lg); z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 11px;
  font-size: 13px; font-weight: 500; animation: popIn .15s ease-out;
}
.scroll-down:hover { color: var(--accent); }
.scroll-down .sd-label { display: none; }
.scroll-down.has-new { color: #fff; background: var(--accent); border-color: transparent; }
.scroll-down.has-new .sd-label { display: inline; }

/* context bars */
.context-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border-top: 1px solid var(--border); padding: 6px 14px; animation: popIn .12s ease-out;
}
.context-bar-body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.cb-title { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.cb-text { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview { width: 40px; height: 40px; border-radius: 10px; background: var(--hover); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); }
.attach-preview img { width: 100%; height: 100%; object-fit: cover; }

/* composer */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 7% 14px; background: transparent; }
.composer-box {
  flex: 1; display: flex; align-items: flex-end;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; resize: none; border: none; background: transparent; padding: 11px 6px; font: inherit; font-size: 15px;
  color: var(--text); max-height: 160px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus { outline: none; }
.icon-btn.tool { border-radius: 50%; padding: 10px; color: var(--muted); background: transparent; }
.icon-btn.tool:hover { color: var(--accent); background: transparent; }
#emoji-btn { margin-left: 4px; }
#mic-btn { margin-right: 4px; }
#mic-btn.recording { color: #fff; background: var(--danger); animation: pulse 1.2s infinite; }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { opacity: .6; }

/* emoji panel */
.emoji-panel {
  position: absolute; bottom: 76px; left: 7%; z-index: 10; width: 344px; max-width: 90%;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: popIn .15s ease-out;
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); }
.emoji-tabs button { flex: 1; background: none; border: none; font-size: 17px; padding: 8px 0; cursor: pointer; opacity: .45; }
.emoji-tabs button.active { opacity: 1; border-bottom: 2px solid var(--accent); }
.emoji-grid { height: 244px; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); padding: 6px; }
.emoji-grid button { background: none; border: none; font-size: 22px; padding: 5px 0; cursor: pointer; border-radius: 8px; }
.emoji-grid button:hover { background: var(--hover); }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 88%); display: flex; align-items: center; justify-content: center; cursor: zoom-out; animation: fadeIn .15s; }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 6px; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(0 0 0 / 40%); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; animation: fadeIn .15s;
}
.modal {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px; max-height: 85dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: popIn .18s ease-out;
}
.modal h3 { margin: 0 0 12px; letter-spacing: -.02em; }
.member-picker { overflow-y: auto; margin: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 6px; cursor: pointer; font-size: 14px; color: var(--text); border-radius: 10px; }
.pick-row:hover { background: var(--hover); }
.pick-row .avatar { width: 34px; height: 34px; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* settings */
.settings-card { max-width: 380px; gap: 4px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings-head h3 { margin: 0; }
.settings-group { padding: 12px 0; border-top: 1px solid var(--border); }
.settings-label { font-size: 13px; font-weight: 590; color: var(--muted); margin-bottom: 10px; }
.wallpaper-grid { display: flex; gap: 10px; }
.wp-swatch {
  width: 56px; height: 76px; border-radius: 12px; border: 2px solid var(--border);
  cursor: pointer; background: var(--chat-bg); position: relative; overflow: hidden;
}
.wp-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wps-logo { background: var(--chat-bg) url('/icons/wito-tile.png') center/44px repeat; }
.wps-gradient { background: linear-gradient(165deg, #b5c8de, #8fabc9); }
.wps-plain { background: var(--chat-bg); }
.wps-blue { background: linear-gradient(170deg, #d8e8fa, #bcd6f2); }
.wps-mint { background: linear-gradient(170deg, #dcf2e4, #c2e6d2); }

/* profile card */
.profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  width: 100%; max-width: 300px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 22px; padding: 26px 22px 22px; box-shadow: var(--shadow-lg); animation: popIn .18s ease-out;
}
.avatar.xl { width: 96px; height: 96px; font-size: 34px; margin-bottom: 6px; }
.profile-card strong { font-size: 18px; letter-spacing: -.02em; }
.profile-line { font-size: 13px; color: var(--muted); }
.profile-actions { margin-top: 12px; display: flex; gap: 8px; }

/* QR login */
.qr-toggle { width: 100%; margin-top: 12px; }
.qr-login { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }
.qr-box { width: 240px; height: 240px; background: #fff; border-radius: 16px; padding: 8px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.qr-box svg { width: 100%; height: 100%; }
.qr-hint { font-size: 13px; color: var(--muted); text-align: center; margin: 0; }

/* calls */
.call-overlay {
  position: fixed; inset: 0; z-index: 60; background: radial-gradient(900px 600px at 50% 30%, #1d2733, #0d1117);
  display: flex; align-items: center; justify-content: center; animation: fadeIn .2s;
}
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.call-peer { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; }
.call-overlay.has-video .call-peer { position: absolute; top: 24px; left: 0; right: 0; }
.call-overlay.has-video .call-peer .avatar { display: none; }
.avatar.big { width: 110px; height: 110px; font-size: 38px; box-shadow: 0 0 0 10px rgb(255 255 255 / 6%), 0 0 0 22px rgb(255 255 255 / 3%); }
.call-name { font-size: 22px; font-weight: 600; text-shadow: 0 1px 3px rgb(0 0 0 / 50%); }
.call-status { font-size: 14px; opacity: .8; }
.local-video {
  position: absolute; right: 16px; bottom: 110px; width: 200px; max-width: 34vw;
  border-radius: 14px; z-index: 3; box-shadow: 0 4px 20px rgb(0 0 0 / 50%); background: #000;
}
.call-controls { position: absolute; bottom: 28px; left: 0; right: 0; display: flex; justify-content: center; gap: 18px; z-index: 4; }
.call-btn {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: rgb(255 255 255 / 16%); color: #fff; backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.call-btn:hover { background: rgb(255 255 255 / 28%); }
.call-btn.danger { background: var(--danger); }
.call-btn.danger .ic { transform: rotate(135deg); }
.call-btn.accept { background: var(--online); }
.call-btn.off { background: #fff; color: #10151c; }

.incoming-call {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 14px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--border); border-radius: 20px; padding: 12px 16px;
  box-shadow: var(--shadow-lg); min-width: 320px; animation: slideDown .25s ease-out;
}
.incoming-call .call-btn { width: 44px; height: 44px; }
.inc-info { flex: 1; min-width: 0; }
.inc-info strong { display: block; }
.inc-type { font-size: 13px; color: var(--muted); }

/* QR scanner */
.scanner-overlay {
  position: fixed; inset: 0; z-index: 65; background: rgb(0 0 0 / 92%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px;
  animation: fadeIn .15s;
}
#scanner-video { width: min(420px, 92vw); border-radius: 16px; background: #000; }
.scanner-hint { color: #fff; font-size: 14px; margin: 0; }
.scanner-manual { display: flex; gap: 8px; }
.scanner-manual input { padding: 9px 12px; border-radius: 10px; border: none; font-size: 14px; width: 240px; }

/* mobile */
@media (max-width: 720px) {
  .sidebar { width: 100%; max-width: none; border-right: none; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .icon-btn.back { display: inline-flex; }
  .messages, .composer, .typing { padding-left: 8px; padding-right: 8px; }
  .emoji-panel { left: 8px; }
  .quick-reply { display: none; }
}
