/* Comigo - visual inspirado no iOS/macOS (cores de sistema, bolhas tipo iMessage) */
:root {
  --bg: #f2f2f7; --panel: #ffffff; --fill: rgba(118, 118, 128, .12); --fill-2: rgba(118, 118, 128, .08);
  --fg: #000000; --muted: #6e6e73; --line: rgba(60, 60, 67, .16);
  --acc: #007aff; --acc-fg: #ffffff; --acc-soft: rgba(0, 122, 255, .12);
  --bubble: #e6f0fe; --bubble-fg: #0b1b33; --bubble-muted: rgba(11, 27, 51, .55);
  --bubble-card: rgba(255, 255, 255, .75); --bubble-card-hover: #ffffff;
  --chat-bg: #ffffff; --danger: #ff3b30; --hover: rgba(0, 0, 0, .04);
  --glass: rgba(255, 255, 255, .72); --shadow: 0 12px 40px rgba(0, 0, 0, .16), 0 1px 3px rgba(0, 0, 0, .08);
  --mark: rgba(255, 204, 0, .45); --av1: #a5abb8; --av2: #858994;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --panel: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
    --fg: #ffffff; --muted: #98989f; --line: rgba(84, 84, 88, .55);
    --acc: #0a84ff; --acc-soft: rgba(10, 132, 255, .2); --bubble: #1c2633; --bubble-fg: #f2f5fa; --bubble-muted: rgba(242, 245, 250, .55);
    --bubble-card: rgba(255, 255, 255, .07); --bubble-card-hover: rgba(255, 255, 255, .12);
    --chat-bg: #000000; --danger: #ff453a; --hover: rgba(255, 255, 255, .05);
    --glass: rgba(28, 28, 30, .72); --shadow: 0 12px 40px rgba(0, 0, 0, .6);
    --mark: rgba(255, 214, 10, .4); --av1: #6c6c70; --av2: #48484a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --panel: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .16);
  --fg: #ffffff; --muted: #98989f; --line: rgba(84, 84, 88, .55);
  --acc: #0a84ff; --acc-soft: rgba(10, 132, 255, .2); --bubble: #1c2633; --bubble-fg: #f2f5fa; --bubble-muted: rgba(242, 245, 250, .55);
    --bubble-card: rgba(255, 255, 255, .07); --bubble-card-hover: rgba(255, 255, 255, .12);
  --chat-bg: #000000; --danger: #ff453a; --hover: rgba(255, 255, 255, .05);
  --glass: rgba(28, 28, 30, .72); --shadow: 0 12px 40px rgba(0, 0, 0, .6);
  --mark: rgba(255, 214, 10, .4); --av1: #6c6c70; --av2: #48484a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); overflow: hidden;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em; -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--acc); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--acc) 55%, transparent); outline-offset: 1px; }

.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: var(--acc); flex: none; transition: background .15s, opacity .15s; }
.icon-btn:hover { background: var(--fill-2); }
.icon-btn:active { opacity: .5; }
.btn { padding: 10px 18px; border-radius: 12px; font-weight: 600; background: var(--fill); color: var(--acc); }
.btn:hover { filter: brightness(.97); }
.btn:active { opacity: .6; }
.btn.primary { background: var(--acc); color: var(--acc-fg); }
.btn.danger { background: var(--fill); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--acc-soft), transparent), var(--bg); }
.login-card { width: min(360px, 100%); background: var(--panel); border-radius: 24px; padding: 36px 24px 28px;
  display: grid; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.login-logo { width: 88px; height: 88px; margin: 0 auto 4px; filter: drop-shadow(0 8px 18px rgba(0, 90, 230, .35)); }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 8px; }
.login-card input { padding: 13px 16px; border-radius: 12px; border: 0; background: var(--fill); outline: none; font-size: 16px; }
.login-card input:focus { box-shadow: 0 0 0 3px var(--acc-soft); }
.login-card .btn { padding: 13px; font-size: 16px; }
.err { color: var(--danger); font-size: 14px; margin: 0; }
.err:empty { display: none; }

/* ---------- layout */
.app { display: grid; grid-template-columns: minmax(300px, 370px) 1fr auto; grid-template-rows: 100%;
  height: 100vh; height: 100dvh; overflow: hidden; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 26px; letter-spacing: -.02em; }
.brand { gap: 8px; }
.brand img { width: 42px; height: 42px; margin: -4px -2px -4px -6px; }
.head-actions { display: flex; gap: 2px; }
.search { margin: 6px 16px 10px; position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.search-ic .i { width: 17px; height: 17px; }
.search input { width: 100%; padding: 8px 56px 8px 32px; border-radius: 10px; border: 0; background: var(--fill); outline: none; }
.search input::placeholder { color: var(--muted); }
.search input:focus { box-shadow: 0 0 0 3px var(--acc-soft); }
.kbd { position: absolute; right: 8px; font-size: 11px; color: var(--muted); background: var(--panel); border-radius: 5px;
  padding: 1px 6px; font-family: inherit; }
.chips { display: flex; gap: 6px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chip { padding: 5px 12px; border-radius: 99px; background: var(--fill-2); color: var(--fg); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--acc); color: #fff; }
.list { flex: 1; overflow-y: auto; padding: 0 8px; }
.side-foot { padding: 10px 16px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.bar { height: 4px; background: var(--fill); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--acc); border-radius: 4px; }

.conv { display: flex; align-items: center; gap: 12px; padding: 9px 6px 9px 10px; cursor: pointer; position: relative; border-radius: 12px; }
.conv:hover { background: var(--hover); }
.conv.on { background: var(--acc); color: #fff; }
.conv.on .time, .conv.on .preview, .conv.on .i.pin, .conv.on .conv-more { color: rgba(255, 255, 255, .85); }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 18px; color: #fff; background: linear-gradient(180deg, var(--av1), var(--av2)); }
.avatar.emoji { background: var(--fill); font-size: 22px; }
.conv.on .avatar.emoji { background: rgba(255, 255, 255, .22); }
.conv-main { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.conv-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time { font-size: 13px; color: var(--muted); flex: none; }
.preview { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; min-width: 0; }
.preview .i { width: 14px; height: 14px; }
.preview span { overflow: hidden; text-overflow: ellipsis; }
.i.pin { width: 14px; height: 14px; color: var(--muted); }
.conv-more { opacity: 0; width: 30px; height: 30px; color: var(--muted); }
.conv:hover .conv-more, .conv-more:focus-visible { opacity: 1; }
@media (pointer: coarse) { .conv-more { opacity: .7; } }

.sec-title { padding: 14px 10px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.res { display: flex; gap: 12px; padding: 8px 6px 8px 10px; cursor: pointer; align-items: center; border-radius: 12px; }
.res:hover { background: var(--hover); }
.res-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--acc-soft); display: grid;
  place-items: center; color: var(--acc); flex: none; overflow: hidden; }
.res-ic img { width: 100%; height: 100%; object-fit: cover; }
.res-main { flex: 1; min-width: 0; }
.res-t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-list { padding: 32px 24px; text-align: center; color: var(--muted); }

/* ---------- chat */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.chat-head { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px; min-height: 60px; background: var(--glass); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.chat-head .avatar { width: 36px; height: 36px; font-size: 15px; }
.back { display: none; }
.title-wrap { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; border-radius: 8px; padding: 2px 6px; }
.title-wrap:hover { background: var(--hover); }
.title-wrap h2 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-wrap span { font-size: 12px; }
.empty { position: absolute; inset: 0; z-index: 5; background: var(--chat-bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px; }
.empty img { width: 96px; filter: drop-shadow(0 10px 22px rgba(0, 90, 230, .3)); }
.empty h2 { margin: 10px 0 0; font-size: 22px; letter-spacing: -.02em; }
.empty p { max-width: 380px; margin: 0 0 14px; }

.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 72px clamp(12px, 4vw, 56px) 10px; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 10px; border-radius: 99px;
  margin: 12px 0 6px; position: sticky; top: 0; z-index: 1; background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.msg { display: flex; justify-content: flex-end; }
.bubble { position: relative; background: var(--bubble);
  color: var(--bubble-fg); border-radius: 20px; border-bottom-right-radius: 6px; padding: 7px 12px 5px;
  max-width: min(560px, 80%); min-width: 76px; display: flex; flex-direction: column; gap: 5px; }
.msg.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 45% { box-shadow: 0 0 0 4px rgba(255, 204, 0, .9); } 100% { box-shadow: none; } }
.text { white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.35; }
.text a { color: var(--acc); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px;
  color: var(--bubble-muted); margin-top: -2px; }
.meta .i { width: 12px; height: 12px; }
.msg-more { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: var(--bubble-fg); background: var(--bubble-card); opacity: 0; z-index: 2; box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.msg-more .i { width: 16px; height: 16px; stroke-width: 2.4; }
.bubble:hover .msg-more, .msg-more:focus-visible { opacity: 1; }
@media (pointer: coarse) {
  /* no touch o menu abre com toque longo, como no iPhone */
  .msg-more { display: none; }
  .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; transition: transform .2s; }
  .msg.pressing .bubble { transform: scale(.97); }
}

/* fotos e videos sem bolha, como no iMessage */
.k-image .bubble, .k-video .bubble { background: none; padding: 0; width: min(320px, 80%); gap: 4px; }
.k-image .meta, .k-video .meta, .k-image .fileinfo, .k-video .fileinfo { color: var(--muted); padding: 0 6px; }
.k-image .msg-more, .k-video .msg-more { background: rgba(0, 0, 0, .35); color: #fff; }
.k-image .text, .k-video .text { align-self: flex-end; background: var(--bubble); color: var(--bubble-fg); border-radius: 20px; border-bottom-right-radius: 6px; padding: 7px 12px; }
.media { display: block; border-radius: 18px; overflow: hidden; max-width: 100%; }
.media img { display: block; width: 100%; max-height: 360px; object-fit: cover; cursor: zoom-in; background: var(--fill); }
video.media { max-height: 360px; background: #000; width: 100%; }
audio { width: 280px; max-width: 100%; }
.fileinfo { font-size: 12px; color: var(--bubble-muted); word-break: break-all; }
.filecard { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border-radius: 14px; margin: 0 -6px;
  background: var(--bubble-card); text-decoration: none; color: inherit; min-width: 230px; }
.filecard:hover { background: var(--bubble-card-hover); }
.ext { width: 38px; height: 46px; border-radius: 8px; background: var(--acc); color: #fff; display: grid;
  place-items: end center; padding-bottom: 7px; font-size: 10px; font-weight: 800; flex: none; text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.fc-main { flex: 1; min-width: 0; }
.fc-name { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fc-size { font-size: 12px; opacity: .75; }
.fc-dl { width: 30px; height: 30px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; flex: none; }
.fc-dl .i { width: 17px; height: 17px; stroke-width: 2.2; }
.linkcard { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 14px; margin: 0 -6px;
  background: var(--bubble-card); text-decoration: none; color: inherit; border-left: 3px solid var(--acc); }
.linkcard:hover { background: var(--bubble-card-hover); }
.lc-main { min-width: 0; }
.lc-t { font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lc-d { font-size: 12px; opacity: .75; }
.pending .bubble { opacity: .9; min-width: 240px; }
.pending .bar { background: var(--bubble-card); }
.pending .bar > i { background: var(--acc); }
.pending-t { font-size: 14px; }

.tray { display: flex; gap: 10px; padding: 12px 14px 0; overflow-x: auto; background: var(--panel); border-top: 1px solid var(--line); }
.tray-item { position: relative; flex: none; width: 88px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.tray-thumb { width: 88px; height: 70px; border-radius: 12px; background: var(--fill); display: grid; place-items: center;
  overflow: hidden; color: var(--acc); font-weight: 800; text-transform: uppercase; }
.tray-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tray-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.tray-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: #8e8e93;
  color: #fff; display: grid; place-items: center; border: 2px solid var(--panel); }
.tray-x .i { width: 12px; height: 12px; stroke-width: 3; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line); }
.tray:not(.hidden) + .composer { border-top: 0; padding-top: 10px; }
.composer .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--chat-bg); border-radius: 20px;
  padding: 8px 14px; max-height: 180px; outline: none; line-height: 1.35; font-size: 16px; }
.composer textarea:focus { border-color: color-mix(in srgb, var(--acc) 60%, var(--line)); }
.send { width: 36px; height: 36px; border-radius: 50%; background: var(--acc); color: #fff; display: grid; place-items: center; flex: none; }
.send:active { opacity: .6; }
.send .i { width: 20px; height: 20px; stroke-width: 2.6; }
.drop { position: absolute; inset: 72px 12px 12px; z-index: 6; border: 2px dashed var(--acc); border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 85%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; font-weight: 600; font-size: 18px; color: var(--acc); pointer-events: none; }
.drop div { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop .i { width: 40px; height: 40px; }

/* ---------- gallery */
.gallery { width: 350px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.gal-head { display: flex; align-items: center; gap: 8px; padding: 10px; min-height: 60px; }
.gal-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.tabs { display: flex; margin: 0 12px 10px; padding: 2px; background: var(--fill); border-radius: 9px; }
.tabs button { flex: 1; padding: 6px; font-size: 13px; font-weight: 500; border-radius: 7px; }
.tabs button.on { background: var(--panel); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04); font-weight: 600; }
:root[data-theme="dark"] .tabs button.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs button.on { background: #636366; } }
.gal-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border-radius: 12px; overflow: hidden; }
.grid button { aspect-ratio: 1; overflow: hidden; background: var(--fill); position: relative;
  display: grid; place-items: center; color: var(--muted); }
.grid img { width: 100%; height: 100%; object-fit: cover; }
.grid .vid { position: absolute; bottom: 4px; left: 4px; color: #fff; filter: drop-shadow(0 1px 2px #000); }

/* ---------- menus, modals */
.menu { position: fixed; z-index: 50; background: color-mix(in srgb, var(--panel) 90%, transparent); border-radius: 14px; box-shadow: var(--shadow);
  padding: 5px; min-width: 220px; animation: pop .14s ease; border: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); }
@keyframes pop { from { opacity: 0; transform: scale(.95); } }
.menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 8px 12px; border-radius: 9px; text-align: left; flex-direction: row-reverse; }
.menu button:hover { background: var(--acc); color: #fff; }
.menu button:hover .i { color: #fff; }
.menu button span { flex: 1; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; }
.menu .i { width: 18px; height: 18px; color: var(--fg); opacity: .8; }
.menu .danger .i { color: var(--danger); opacity: 1; }
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .32); display: grid; place-items: center;
  padding: 16px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 22px; width: min(440px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow); animation: rise .22s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal h3 { margin: 0; padding: 22px 22px 4px; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.modal-body { padding: 12px 22px; overflow-y: auto; display: grid; gap: 14px; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 22px 22px; flex-wrap: wrap; }
.field { width: 100%; padding: 11px 14px; border-radius: 12px; border: 0; background: var(--fill); outline: none; font-size: 16px; }
.field:focus { box-shadow: 0 0 0 3px var(--acc-soft); }
textarea.field { resize: vertical; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.opts button { padding: 10px; border-radius: 12px; background: var(--fill-2); font-size: 14px; font-weight: 500; }
.opts button.on { background: var(--acc); color: #fff; font-weight: 600; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; font-size: 14px; }
.copyrow .btn { padding: 10px 14px; }
.picklist { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; margin: 0 -10px; }
.picklist button { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; text-align: left; font-weight: 500; }
.picklist button:hover { background: var(--hover); }
.picklist .avatar { width: 36px; height: 36px; font-size: 15px; }
.picklist .avatar.emoji { color: var(--acc); }
.note { font-size: 13px; color: var(--muted); background: var(--fill-2); border-radius: 12px; padding: 10px 12px; }
.share-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.share-item:last-child { border: 0; }
.share-item .res-main { flex: 1; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; animation: fade .18s ease; }
.lb-head { display: flex; align-items: center; gap: 8px; padding: 8px; color: #fff; }
.lb-head .icon-btn { color: #fff; }
.lb-head .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lb-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; font-weight: 500; }
.lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 8px; position: relative; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .14) !important; color: #fff !important;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(16px) scale(.96);
  background: rgba(30, 30, 32, .86); color: #fff; padding: 11px 18px; border-radius: 14px; opacity: 0; pointer-events: none;
  transition: .22s cubic-bezier(.2, .9, .3, 1.1); z-index: 70; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- mobile */
@media (max-width: 1100px) {
  .gallery { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); max-width: 100%; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .chat { display: none; }
  .app.in-chat .side { display: none; }
  .app.in-chat .chat { display: flex; }
  .side { border-right: 0; }
  .back { display: grid; }
  .kbd { display: none; }
  .search input { padding-right: 12px; }
  .gallery { width: 100%; }
  .msgs { padding-left: 12px; padding-right: 12px; }
  .bubble { max-width: 84%; }
  .k-image .bubble, .k-video .bubble { width: min(280px, 78%); }
}
