/* Vaarta — app styles */
:root {
  --bg: #e9e7f5;
  --panel: #ffffff;
  --panel-2: #f6f5fb;
  --hover: #f1f0f8;
  --active: #e9e7f8;
  --line: #e6e4ef;
  --text: #1b1a2b;
  --muted: #6c6a83;
  --faint: #9a98ae;
  --brand: #4b3fc9;
  --brand-2: #6d5ef5;
  --brand-ink: #ffffff;
  --brand-soft: #ecebff;
  --accent: #14a3a0;
  --read: #12a3b8;
  --danger: #d6334d;
  --online: #1fa463;
  --out: #e2defe;
  --out-ink: #1b1a2b;
  --in: #ffffff;
  --chat-bg: #efedf7;
  --chat-dot: rgba(75, 63, 201, 0.07);
  --shadow: 0 1px 2px rgba(27, 26, 43, .08), 0 4px 16px rgba(27, 26, 43, .06);
  --shadow-lg: 0 12px 40px rgba(27, 26, 43, .18);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b12; --panel: #15151f; --panel-2: #1b1b28; --hover: #1f1f2d; --active: #262538;
    --line: #262636; --text: #ecebf6; --muted: #9c9ab3; --faint: #6f6d86;
    --brand: #8a7cff; --brand-2: #a497ff; --brand-ink: #0f0d24; --brand-soft: #24214a;
    --accent: #2ec4b6; --read: #3cc9dc; --danger: #ff5c74; --online: #3ccf86;
    --out: #3a3275; --out-ink: #f1efff; --in: #20202e; --chat-bg: #101019; --chat-dot: rgba(138, 124, 255, 0.06);
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b12; --panel: #15151f; --panel-2: #1b1b28; --hover: #1f1f2d; --active: #262538;
  --line: #262636; --text: #ecebf6; --muted: #9c9ab3; --faint: #6f6d86;
  --brand: #8a7cff; --brand-2: #a497ff; --brand-ink: #0f0d24; --brand-soft: #24214a;
  --accent: #2ec4b6; --read: #3cc9dc; --danger: #ff5c74; --online: #3ccf86;
  --out: #3a3275; --out-ink: #f1efff; --in: #20202e; --chat-bg: #101019; --chat-dot: rgba(138, 124, 255, 0.06);
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.4; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
#root { height: 100%; height: 100dvh; }

/* boot */
.boot { display: grid; place-items: center; background: linear-gradient(160deg, #6d5ef5, #3a2fb0); }
.boot-logo { color: #fff; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .3px; }
.boot-logo img { display: block; margin: 0 auto 12px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* ---------------------------------------------------------------- login */
.login { height: 100%; overflow: auto; background: linear-gradient(160deg, #6d5ef5 0%, #3a2fb0 55%, #241c7a 100%); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 22px; padding: 32px 28px 28px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand img { width: 46px; height: 46px; border-radius: 13px; }
.login-brand b { font-size: 22px; letter-spacing: .2px; }
.login h1 { font-size: 20px; margin: 0 0 6px; }
.login p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel-2); outline: none; transition: border-color .15s, background .15s; }
.input:focus { border-color: var(--brand); background: var(--panel); }
.phone-row { display: flex; gap: 8px; }
.phone-row .cc { width: 84px; flex: none; text-align: center; }
.otp-input { letter-spacing: 12px; font-size: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; font-weight: 600; background: var(--brand); color: var(--brand-ink); transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--danger); color: #fff; }
.link-btn { color: var(--brand); font-weight: 600; font-size: 14px; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 20px; margin: 4px 0 10px; }
.form-note { color: var(--muted); font-size: 13px; margin-top: 14px; text-align: center; }
.dev-code { background: #fff6d6; color: #6b5200; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.acct { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); margin-bottom: 10px; text-align: left; }
.acct:hover { border-color: var(--brand); background: var(--brand-soft); }
.acct .meta { flex: 1; min-width: 0; }
.acct .meta small { display: block; color: var(--muted); }
.divider-text { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 16px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; height: 100%; max-width: 1600px; margin: 0 auto; background: var(--panel); box-shadow: var(--shadow); position: relative; overflow: hidden; }
@media (min-width: 1440px) { .shell { height: calc(100% - 38px); margin-top: 19px; border-radius: 6px; } }
.sidebar { width: 30%; min-width: 320px; max-width: 460px; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: relative; background: var(--panel); }
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.rightbar { width: 30%; min-width: 320px; max-width: 420px; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }

.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.topbar .title { flex: 1; font-weight: 700; font-size: 19px; min-width: 0; }
.topbar .title small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); flex: none; transition: background .15s, color .15s; position: relative; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { background: var(--active); color: var(--brand); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel-2); }

.tabs { display: flex; gap: 6px; padding: 8px 12px 0; background: var(--panel); }
.tab { flex: 1; padding: 9px 6px 10px; text-align: center; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tab.on { color: var(--brand); border-color: var(--brand); }
.tab .badge { margin: 0; }

.search { padding: 8px 12px; background: var(--panel); }
.search-box { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 10px; padding: 0 12px; height: 38px; color: var(--muted); }
.search-box input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; color: var(--text); }
.search-box svg.i { width: 18px; height: 18px; }
.filters { display: flex; gap: 8px; padding: 2px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--brand-soft); color: var(--brand); }

.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px; height: 72px; cursor: pointer; position: relative; width: 100%; text-align: left; }
.row:hover { background: var(--hover); }
.row.on { background: var(--active); }
.row .body { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--line); padding-right: 2px; }
.row:last-child .body { border-bottom: 0; }
.row .line1, .row .line2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row .name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.row .time { font-size: 12px; color: var(--faint); flex: none; }
.row.unread .time { color: var(--accent); font-weight: 600; }
.row .preview { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; display: flex; align-items: center; gap: 3px; }
.row .preview svg.i { width: 16px; height: 16px; }
.row .preview .typing { color: var(--accent); font-weight: 500; }
.row .flags { display: flex; align-items: center; gap: 4px; color: var(--faint); flex: none; }
.row .flags svg.i { width: 16px; height: 16px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.row.muted .badge { background: var(--faint); }
.row .row-menu { opacity: 0; width: 24px; height: 24px; color: var(--faint); display: grid; place-items: center; margin-right: -4px; }
.row:hover .row-menu { opacity: 1; }
.section-label { padding: 14px 16px 6px; font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.archived-row { display: flex; align-items: center; gap: 22px; padding: 12px 24px; color: var(--text); font-weight: 600; width: 100%; }
.archived-row:hover { background: var(--hover); }
.archived-row svg.i { color: var(--accent); }
.archived-row .count { margin-left: auto; color: var(--accent); font-size: 13px; }

/* avatars */
.av { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; position: relative; overflow: visible; user-select: none; }
.av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.av.sm { width: 40px; height: 40px; font-size: 15px; }
.av.xs { width: 32px; height: 32px; font-size: 13px; }
.av.lg { width: 120px; height: 120px; font-size: 40px; }
.av.xl { width: 200px; height: 200px; font-size: 64px; }
.av .on-dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--online); border: 2.5px solid var(--panel); }
.av.group-av { background: var(--brand-soft); color: var(--brand); }
.av.group-av svg.i { width: 55%; height: 55%; }

/* ---------------------------------------------------------------- empty pane */
.welcome { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--panel-2); border-bottom: 6px solid var(--brand); }
.welcome-inner { max-width: 460px; }
.welcome img { width: 96px; height: 96px; border-radius: 26px; margin-bottom: 18px; box-shadow: var(--shadow-lg); }
.welcome h2 { font-weight: 300; font-size: 30px; margin: 0 0 10px; }
.welcome p { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
.welcome .lock { margin-top: 30px; color: var(--faint); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.welcome .lock svg.i { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- conversation */
.conv-head { cursor: pointer; }
.conv-head .who { flex: 1; min-width: 0; }
.conv-head .who b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-head .who small { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-head .who small.live { color: var(--accent); }
.back-btn { display: none; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 6% 8px; overscroll-behavior: contain;
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-dot) 1.2px, transparent 1.2px), radial-gradient(var(--chat-dot) 1.2px, transparent 1.2px);
  background-size: 26px 26px; background-position: 0 0, 13px 13px;
}
.load-more { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }
.day { text-align: center; margin: 12px 0 10px; position: sticky; top: 4px; z-index: 2; }
.day span { display: inline-block; padding: 5px 12px; border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow); }
.sys { text-align: center; margin: 8px 0; }
.sys span { display: inline-block; max-width: 80%; padding: 5px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--text); font-size: 12.5px; }
.unread-bar { text-align: center; margin: 10px -6%; padding: 6px; background: rgba(20, 163, 160, .12); color: var(--accent); font-size: 13px; font-weight: 600; }
.e2e-note { text-align: center; margin: 4px auto 12px; max-width: 420px; padding: 8px 14px; border-radius: 10px; background: #fff6d6; color: #6b5200; font-size: 12.5px; display: flex; gap: 8px; align-items: center; justify-content: center; }
:root[data-theme="dark"] .e2e-note { background: #2b2614; color: #e6d7a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .e2e-note { background: #2b2614; color: #e6d7a3; } }
.e2e-note svg.i { width: 14px; height: 14px; }

.msg { display: flex; margin: 1px 0; position: relative; }
.msg.out { justify-content: flex-end; }
.msg.first { margin-top: 8px; }
.bubble {
  max-width: min(68%, 560px); background: var(--in); border-radius: 10px; padding: 6px 8px 7px 9px; box-shadow: var(--shadow);
  position: relative; word-wrap: break-word; overflow-wrap: anywhere; min-width: 80px;
}
.msg.out .bubble { background: var(--out); color: var(--out-ink); }
.msg.first.in .bubble { border-top-left-radius: 3px; }
.msg.first.out .bubble { border-top-right-radius: 3px; }
.msg.first.in .bubble::before, .msg.first.out .bubble::before {
  content: ""; position: absolute; top: 0; width: 10px; height: 12px; background: inherit;
}
.msg.first.in .bubble::before { left: -7px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg.first.out .bubble::before { right: -7px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble .sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; display: block; }
.bubble .text { white-space: pre-wrap; font-size: 14.5px; }
.bubble .text.big-emoji { font-size: 38px; line-height: 1.15; }
.bubble .text a { color: var(--brand); word-break: break-all; }
.msg.out .bubble .text a { color: inherit; text-decoration: underline; }
.bubble .meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--faint); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; position: relative; top: 3px; }
.msg.out .bubble .meta { color: color-mix(in srgb, var(--out-ink) 55%, transparent); }
.bubble .meta svg.i { width: 16px; height: 16px; stroke-width: 2.1; }
.bubble .meta .read { color: var(--read); }
.bubble .fwd { font-size: 12.5px; color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.bubble .fwd svg.i { width: 14px; height: 14px; }
.bubble.deleted .text { color: var(--muted); font-style: italic; display: inline-flex; align-items: center; gap: 6px; }
.bubble.deleted .text svg.i { width: 16px; height: 16px; }
.bubble .edited { font-style: italic; }
.msg.highlight .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 40%, transparent); } }

.msg-menu-btn { position: absolute; top: 3px; right: 4px; width: 26px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); opacity: 0; background: inherit; z-index: 1; }
.bubble:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
.msg-menu-btn svg.i { width: 18px; height: 18px; }
.react-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .15s; }
.msg.in .react-btn { right: -40px; }
.msg.out .react-btn { left: -40px; }
.msg:hover .react-btn { opacity: 1; }
.react-btn svg.i { width: 18px; height: 18px; }

.reactions { display: flex; gap: 2px; position: absolute; bottom: -14px; background: var(--panel); border-radius: 12px; padding: 1px 6px; box-shadow: var(--shadow); font-size: 13px; cursor: pointer; z-index: 1; }
.msg.in .reactions { left: 8px; }
.msg.out .reactions { right: 8px; }
.msg.has-reactions { margin-bottom: 16px; }
.reactions small { color: var(--muted); margin-left: 3px; font-size: 11.5px; align-self: center; }

.quote { display: flex; border-radius: 7px; background: rgba(0,0,0,.05); overflow: hidden; margin: 0 -2px 5px; cursor: pointer; }
:root[data-theme="dark"] .quote { background: rgba(255,255,255,.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .quote { background: rgba(255,255,255,.06); } }
.quote::before { content: ""; width: 4px; flex: none; background: var(--qc, var(--brand)); }
.quote .q-body { padding: 5px 9px; min-width: 0; flex: 1; }
.quote b { display: block; font-size: 12.5px; color: var(--qc, var(--brand)); }
.quote .q-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.quote .q-text svg.i { width: 14px; height: 14px; }
.quote .q-thumb { width: 52px; height: 52px; object-fit: cover; flex: none; }

/* media in bubbles */
.media-img, .media-video { display: block; border-radius: 7px; margin: -2px -4px 4px -5px; max-width: calc(100% + 9px); width: 330px; max-height: 360px; object-fit: cover; background: var(--panel-2); cursor: pointer; }
.media-video { cursor: default; }
.bubble.media-only .meta { position: absolute; right: 10px; bottom: 10px; float: none; margin: 0; padding: 2px 6px; border-radius: 8px; background: rgba(0,0,0,.4); color: #fff !important; top: auto; }
.bubble.media-only .meta .read { color: #8ff0ff; }
.file-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: rgba(0,0,0,.05); min-width: 240px; text-decoration: none; color: inherit; margin-bottom: 2px; }
:root[data-theme="dark"] .file-card { background: rgba(255,255,255,.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .file-card { background: rgba(255,255,255,.06); } }
.file-card .ficon { width: 38px; height: 44px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; flex: none; text-transform: uppercase; }
.file-card .fmeta { flex: 1; min-width: 0; }
.file-card .fmeta b { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .fmeta small { color: var(--muted); font-size: 12px; }
.file-card svg.i { color: var(--muted); }

.voice { display: flex; align-items: center; gap: 10px; min-width: 250px; padding: 4px 2px 0; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--brand); flex: none; }
.voice .play svg.i { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.voice .track { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.voice .bars { height: 26px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.voice .bars i { flex: 1; background: color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 2px; min-height: 3px; }
.voice .bars i.done { background: var(--brand); }
.voice .vtime { font-size: 11.5px; color: var(--muted); }
.voice .av { width: 44px; height: 44px; }
.voice .mic-badge { position: absolute; bottom: -2px; right: -4px; color: var(--accent); }
.voice .mic-badge svg.i { width: 16px; height: 16px; }

/* typing indicator bubble */
.typing-bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: .2s; }
.typing-bubble i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.scroll-down { position: absolute; right: 18px; bottom: 82px; width: 42px; height: 42px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow-lg); display: grid; place-items: center; color: var(--muted); z-index: 3; }
.scroll-down .badge { position: absolute; top: -6px; right: -4px; }

/* composer */
.composer-wrap { flex: none; background: var(--panel-2); border-top: 1px solid var(--line); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0 16px; }
.reply-bar .quote { flex: 1; margin: 0; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.composer .box { flex: 1; display: flex; align-items: flex-end; background: var(--panel); border-radius: 22px; padding: 0 6px; min-height: 44px; box-shadow: var(--shadow); }
.composer textarea { flex: 1; border: 0; background: transparent; outline: none; resize: none; padding: 11px 6px; max-height: 140px; line-height: 1.4; min-width: 0; font-size: 15px; }
.composer .box .icon-btn { width: 38px; height: 44px; border-radius: 12px; }
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex: none; box-shadow: var(--shadow); transition: transform .1s; }
.send-btn:active { transform: scale(.94); }
.send-btn svg.i { width: 22px; height: 22px; }
.readonly-bar { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; background: var(--panel-2); border-top: 1px solid var(--line); }

.recorder { display: flex; align-items: center; gap: 12px; flex: 1; padding: 0 8px; height: 46px; }
.recorder .rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.recorder .rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; }
.recorder .rec-wave { flex: 1; height: 28px; display: flex; align-items: center; gap: 2px; overflow: hidden; justify-content: flex-end; }
.recorder .rec-wave i { width: 3px; flex: none; border-radius: 2px; background: var(--brand); min-height: 3px; }
.recorder .icon-btn.trash { color: var(--danger); }

/* popovers */
.popover { position: fixed; z-index: 50; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px 0; min-width: 190px; animation: pop .12s ease; border: 1px solid var(--line); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.popover button.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 18px; text-align: left; font-size: 14.5px; }
.popover button.item:hover { background: var(--hover); }
.popover button.item svg.i { width: 19px; height: 19px; color: var(--muted); }
.popover button.item.danger { color: var(--danger); }
.popover button.item.danger svg.i { color: var(--danger); }
.react-bar { display: flex; gap: 2px; padding: 6px 8px; border-radius: 999px; }
.react-bar button { font-size: 24px; width: 42px; height: 42px; border-radius: 50%; transition: transform .1s; }
.react-bar button:hover { transform: scale(1.2); background: var(--hover); }
.react-bar button.on { background: var(--brand-soft); }
.emoji-panel { width: 340px; max-width: calc(100vw - 20px); padding: 0; }
.emoji-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.emoji-tabs button { flex: 1; padding: 8px 0; font-size: 18px; opacity: .55; border-bottom: 2px solid transparent; }
.emoji-tabs button.on { opacity: 1; border-color: var(--brand); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; height: 250px; overflow-y: auto; align-content: start; }
.emoji-grid button { font-size: 24px; height: 38px; border-radius: 8px; }
.emoji-grid button:hover { background: var(--hover); }

/* drawers (slide-over panels in sidebar / rightbar) */
.drawer { position: absolute; inset: 0; background: var(--panel); z-index: 10; display: flex; flex-direction: column; animation: slide-in .18s ease; }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
.drawer-head { height: 108px; flex: none; background: var(--brand); color: var(--brand-ink); display: flex; align-items: flex-end; gap: 18px; padding: 0 20px 18px; }
.drawer-head .icon-btn { color: inherit; }
.drawer-head .icon-btn:hover { background: rgba(255,255,255,.15); }
.drawer-head h3 { margin: 0; font-size: 19px; font-weight: 600; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; background: var(--panel-2); }
.right-head { height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); flex: none; }
.right-head h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.card { background: var(--panel); padding: 16px 22px; margin-bottom: 10px; box-shadow: 0 1px 0 var(--line); }
.card.center { text-align: center; padding: 26px 22px; }
.card.center .av { margin: 0 auto 14px; }
.card h4 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.card .muted { color: var(--muted); font-size: 14px; }
.card-label { font-size: 13.5px; color: var(--accent); margin-bottom: 10px; font-weight: 500; }
.edit-line { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; padding: 4px 0; }
.edit-line .val { flex: 1; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.edit-line input { flex: 1; border: 0; outline: none; background: transparent; font-size: 16px; padding: 4px 0; min-width: 0; }
.edit-line.editing { border-color: var(--brand); }
.edit-line .icon-btn { width: 32px; height: 32px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.av-edit { position: relative; display: inline-block; cursor: pointer; border-radius: 50%; }
.av-edit .overlay { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; display: grid; place-items: center; text-align: center; font-size: 11.5px; text-transform: uppercase; opacity: 0; transition: opacity .15s; padding: 30px; }
.av-edit:hover .overlay { opacity: 1; }
.action-row { display: flex; align-items: center; gap: 22px; width: 100%; padding: 14px 22px; text-align: left; font-size: 15.5px; background: var(--panel); }
.action-row:hover { background: var(--hover); }
.action-row svg.i { color: var(--muted); }
.action-row.danger, .action-row.danger svg.i { color: var(--danger); }
.action-row .grow { flex: 1; }
.action-row small { color: var(--muted); display: block; font-size: 13px; }
.quick-actions { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.quick-actions button { width: 88px; padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); color: var(--brand); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13.5px; }
.quick-actions button:hover { background: var(--brand-soft); }
.member-row .tag { font-size: 11.5px; color: var(--accent); border: 1px solid currentColor; border-radius: 6px; padding: 1px 6px; flex: none; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 4px; background: var(--panel); }
.picked span { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 999px; padding: 3px 10px 3px 3px; font-size: 13.5px; }
.picked span .av { width: 24px; height: 24px; font-size: 11px; }
.picked span button { color: var(--muted); display: grid; }
.picked span button svg.i { width: 15px; height: 15px; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); flex: none; display: grid; place-items: center; }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check svg.i { width: 15px; height: 15px; stroke-width: 3; }
.fab { position: absolute; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); z-index: 4; }
.fab svg.i { width: 26px; height: 26px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 14, 30, .55); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 22px; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 4px 22px 16px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 16px; flex-wrap: wrap; }
.modal .list { max-height: 50vh; }
.radio-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }

/* send-media preview */
.preview-modal { max-width: 640px; }
.preview-stage { background: var(--panel-2); display: grid; place-items: center; min-height: 280px; max-height: 60vh; overflow: hidden; }
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 60vh; display: block; }
.preview-stage .file-big { padding: 40px; text-align: center; color: var(--muted); }
.preview-stage .file-big .ficon { width: 70px; height: 84px; margin: 0 auto 12px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.caption-row { display: flex; gap: 10px; padding: 12px 16px; align-items: center; }
.caption-row .input { border-radius: 22px; }
.thumbs { display: flex; gap: 8px; padding: 8px 16px 0; overflow-x: auto; }
.thumbs button { width: 54px; height: 54px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; flex: none; background: var(--panel-2); font-size: 10px; }
.thumbs button.on { border-color: var(--brand); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 8, 14, .94); display: flex; flex-direction: column; animation: fade .15s; }
.lightbox .lb-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff; }
.lightbox .lb-head .who { flex: 1; min-width: 0; }
.lightbox .lb-head small { display: block; color: #aaa; }
.lightbox .icon-btn { color: #ddd; }
.lightbox .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.lightbox .lb-stage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 16px 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-caption { color: #eee; text-align: center; padding: 0 16px 22px; white-space: pre-wrap; }

/* toast */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #262536; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .15s; max-width: 90vw; }
.conn-banner { background: #fff6d6; color: #6b5200; font-size: 13px; padding: 8px 16px; display: flex; gap: 8px; align-items: center; }
.conn-banner svg.i { width: 16px; height: 16px; }

.blocked-page { height: 100%; display: grid; place-items: center; padding: 24px; background: var(--panel-2); text-align: center; }
.blocked-page .card { max-width: 420px; border-radius: 18px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 820px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; border-right: 0; }
  .pane { position: absolute; inset: 0; z-index: 20; transform: translateX(100%); transition: transform .2s ease; }
  .shell.chat-open .pane { transform: none; }
  .shell.chat-open .sidebar { visibility: hidden; transition: visibility 0s .2s; }
  .rightbar { position: absolute; inset: 0; z-index: 30; width: 100%; max-width: none; min-width: 0; border: 0; }
  .back-btn { display: inline-grid; margin-left: -8px; }
  .messages { padding: 10px 10px 6px; }
  .bubble { max-width: 84%; }
  .react-btn, .msg-menu-btn { display: none; }
  .unread-bar { margin: 10px -10px; }
  .welcome { display: none; }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 30%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* misc */
.av-btn { border-radius: 50%; display: grid; }
svg.i.flip-x { transform: scaleX(-1); }
.row .preview svg.i.read-tick { color: var(--read); }
.welcome-pane { background: var(--panel-2); }

/* ---------------------------------------------------------------- calls */
.call-bubble { display: flex; align-items: center; gap: 12px; text-align: left; min-width: 220px; padding: 10px 12px; }
.call-bubble .call-ic { width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.06); display: grid; place-items: center; color: var(--accent); flex: none; }
.call-bubble .call-ic.missed { color: var(--danger); }
.call-bubble .call-txt { flex: 1; display: flex; flex-direction: column; }
.call-bubble .call-txt b { font-weight: 500; font-size: 14.5px; }
.call-bubble .call-txt small { color: var(--muted); font-size: 12.5px; }
.call-bubble .meta { align-self: flex-end; margin: 0; top: 2px; }
.call-dir { display: inline-flex; color: var(--accent); }
.call-dir.missed { color: var(--danger); }
.call-dir svg.i { width: 15px !important; height: 15px !important; }

.call-screen {
  position: fixed; inset: 0; z-index: 80; color: #fff; overflow: hidden; display: flex; flex-direction: column;
  background: radial-gradient(120% 90% at 50% 0%, #4b3fc9 0%, #241c7a 55%, #0f0c33 100%);
  animation: fade .2s;
}
.call-screen .cs-top { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 0; right: 0; text-align: center; font-size: 13px; opacity: .75; display: flex; gap: 6px; justify-content: center; align-items: center; z-index: 3; }
.call-screen .cs-top svg.i { width: 14px; height: 14px; }
.call-screen .cs-info { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 2; gap: 4px; }
.call-screen .cs-info .av { box-shadow: 0 0 0 10px rgba(255,255,255,.08), 0 0 0 22px rgba(255,255,255,.04); margin-bottom: 26px; }
.call-screen:not(.connected) .cs-info .av { animation: ring-pulse 1.6s infinite; }
@keyframes ring-pulse { 50% { box-shadow: 0 0 0 16px rgba(255,255,255,.1), 0 0 0 34px rgba(255,255,255,.04); } }
.call-screen h2 { margin: 0; font-size: 28px; font-weight: 500; }
.call-screen .cs-status { font-size: 16px; opacity: .85; font-variant-numeric: tabular-nums; }
.call-screen .cs-peer-note { margin-top: 10px; font-size: 13.5px; background: rgba(0,0,0,.35); padding: 6px 12px; border-radius: 10px; }
.call-screen .cs-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; transition: opacity .3s; }
.call-screen.has-remote-video .cs-remote { opacity: 1; }
.call-screen.has-remote-video .cs-info { justify-content: flex-start; padding-top: 48px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.call-screen.has-remote-video .cs-info .av { display: none; }
.call-screen.has-remote-video .cs-info h2 { font-size: 20px; }
.call-screen .cs-local { position: absolute; right: 16px; bottom: 130px; width: 28%; max-width: 220px; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; background: #111; box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 3; transform: scaleX(-1); }
.call-screen:not(.connected) .cs-local { inset: 0; width: 100%; height: 100%; max-width: none; border-radius: 0; z-index: 1; opacity: .55; aspect-ratio: auto; }
.call-screen .cs-controls { display: flex; justify-content: center; gap: 22px; padding: 20px 16px max(28px, env(safe-area-inset-bottom)); z-index: 3; background: linear-gradient(transparent, rgba(0,0,0,.45)); }
.cs-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12.5px; color: #fff; }
.cs-btn svg.i { width: 60px; height: 60px; padding: 17px; border-radius: 50%; background: rgba(255,255,255,.16); backdrop-filter: blur(8px); transition: background .15s, transform .1s; }
.cs-btn:hover svg.i { background: rgba(255,255,255,.26); }
.cs-btn:active svg.i { transform: scale(.94); }
.cs-btn.off svg.i { background: #fff; color: #241c7a; }
.cs-btn.end svg.i { background: #e5344f; }
.cs-btn.end:hover svg.i { background: #f0475f; }
.cs-btn.accept svg.i { background: #1fa463; animation: bounce 1.2s infinite; }
@keyframes bounce { 50% { transform: translateY(-6px); } }
.cs-btn.accept span, .cs-btn.end span { font-weight: 600; }
@media (max-width: 820px) { .cs-btn svg.i { width: 56px; height: 56px; padding: 16px; } .call-screen .cs-controls { gap: 16px; } }
.call-screen .cs-local.no-mirror { transform: none; }

/* company settings */
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.swatch { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; color: transparent; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); transition: transform .1s; }
.swatch:hover { transform: scale(1.08); }
.swatch.on { color: #fff; box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px currentColor; }
.swatch.on { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--text); }
.swatch svg.i { width: 20px; height: 20px; stroke-width: 3; }
.custom-color { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; cursor: pointer; font-size: 14px; }
.custom-color input[type=color] { width: 40px; height: 32px; border: 0; padding: 0; background: none; cursor: pointer; }
.custom-color .hex { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.brand-preview { background: var(--chat-bg); border-radius: 12px; padding: 12px 14px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.brand-preview .bubble { max-width: 85%; }
.brand-preview .btn { align-self: flex-start; margin-top: 8px; padding: 8px 14px; pointer-events: none; }

/* ---------------------------------------------------------------- status */
.ring-av { position: relative; width: 52px; height: 52px; flex: none; display: grid; place-items: center; }
.ring-av .ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-av .ring circle { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.ring-av .ring circle.new { stroke: var(--accent); }
.ring-av .ring circle.seen { stroke: color-mix(in srgb, var(--muted) 45%, transparent); }
.ring-av .av { width: 42px; height: 42px; }
.ring-av .add-badge { position: absolute; right: -1px; bottom: -1px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--panel); }
.ring-av .add-badge svg.i { width: 13px; height: 13px; stroke-width: 3; }
.q-text-thumb { display: grid; place-items: center; color: #fff; font-size: 9px; padding: 4px; text-align: center; overflow: hidden; line-height: 1.1; }

.status-compose { position: fixed; inset: 0; z-index: 75; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: background .25s; animation: fade .15s; }
.status-compose .st-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; }
.status-compose .icon-btn { color: #fff; }
.status-compose .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.status-compose .grow { flex: 1; }
.st-text-input { width: min(90%, 640px); background: transparent; border: 0; outline: none; resize: none; color: #fff; text-align: center; font-size: 38px; line-height: 1.25; height: 50vh; font-weight: 500; }
.st-text-input::placeholder { color: rgba(255,255,255,.6); }
.st-send { position: absolute; right: 22px; bottom: max(22px, env(safe-area-inset-bottom)); background: #fff; color: #222; width: 56px; height: 56px; }
.st-prog { padding: 8px 16px 0; color: var(--muted); font-size: 13px; }

.status-viewer { position: fixed; inset: 0; z-index: 75; background: #0b0b10; display: flex; flex-direction: column; color: #fff; animation: fade .15s; user-select: none; }
.sv-bars { display: flex; gap: 4px; padding: max(10px, env(safe-area-inset-top)) 12px 0; position: relative; z-index: 3; max-width: 560px; width: 100%; margin: 0 auto; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.3); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #fff; }
.sv-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: relative; z-index: 3; max-width: 560px; width: 100%; margin: 0 auto; }
.sv-who { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.sv-who small { display: block; color: rgba(255,255,255,.7); font-size: 12px; }
.status-viewer .icon-btn { color: #fff; }
.status-viewer .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.sv-stage { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; max-width: 560px; width: 100%; margin: 0 auto; }
.sv-stage img, .sv-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.sv-text { width: 100%; height: 100%; display: grid; place-items: center; padding: 30px; text-align: center; font-size: clamp(22px, 4.2vw, 36px); font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 6px; }
.sv-caption { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; padding: 10px 20px; background: rgba(0,0,0,.45); white-space: pre-wrap; }
.sv-nav { position: absolute; top: 90px; bottom: 90px; width: 30%; z-index: 2; }
.sv-nav.prev { left: 0; } .sv-nav.next { right: 0; }
.sv-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px max(14px, env(safe-area-inset-bottom)); position: relative; z-index: 3; max-width: 560px; width: 100%; margin: 0 auto; justify-content: center; }
.sv-reply { flex: 1; border-radius: 24px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: #fff; padding: 12px 18px; outline: none; }
.sv-reply::placeholder { color: rgba(255,255,255,.65); }
.sv-views { display: inline-flex; align-items: center; gap: 6px; color: #fff; padding: 8px 14px; border-radius: 20px; background: rgba(255,255,255,.1); }
.sv-del { position: absolute; right: 14px; }
/* dialogs and menus must sit above the status viewer / call screen */
.modal-bg { z-index: 85; }
.popover { z-index: 86; }
.tag.danger { color: var(--danger); }
.member-row .tag { font-size: 11.5px; color: var(--accent); border: 1px solid currentColor; border-radius: 6px; padding: 1px 6px; flex: none; }
.row.dim { opacity: .6; }
