@font-face { font-family: "Vazirmatn"; src: url("../assets/fonts/Vazirmatn-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../assets/fonts/Vazirmatn-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../assets/fonts/Vazirmatn-Bold.ttf") format("truetype"); font-weight: 700 900; font-display: swap; }

:root {
  --bg: #0c0d12; --bg-2: #111218; --panel: #15171f; --panel-2: #1a1d26; --panel-3: #222633;
  --line: #20242f; --line-2: #2a2f3d;
  --ink: #f2f4f8; --ink-2: #c9cedb; --ink-3: #98a0b3; --ink-4: #6d7488;
  --accent: #5b8def; --accent-2: #8b7cf6; --accent-ink: #fff; --accent-soft: rgba(91, 141, 239, .14);
  --ok: #3fb27f; --warn: #e0a43b; --live: #e5534b; --idle: #e0a43b; --dnd: #e5534b;
  --glow: rgba(91, 141, 239, .28);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7fb; --bg-2: #eef0f6; --panel: #ffffff; --panel-2: #f3f5fa; --panel-3: #e9ecf4;
  --line: #e2e5ee; --line-2: #d3d8e4;
  --ink: #12141b; --ink-2: #353a49; --ink-3: #5d6477; --ink-4: #8a91a3;
  --accent: #3f74e0; --accent-2: #7461ee; --accent-soft: rgba(63, 116, 224, .1);
  --glow: rgba(63, 116, 224, .18); --shadow: 0 24px 60px -25px rgba(30, 40, 80, .3);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fb; --bg-2: #eef0f6; --panel: #ffffff; --panel-2: #f3f5fa; --panel-3: #e9ecf4;
    --line: #e2e5ee; --line-2: #d3d8e4;
    --ink: #12141b; --ink-2: #353a49; --ink-3: #5d6477; --ink-4: #8a91a3;
    --accent: #3f74e0; --accent-2: #7461ee; --accent-soft: rgba(63, 116, 224, .1);
    --glow: rgba(63, 116, 224, .18); --shadow: 0 24px 60px -25px rgba(30, 40, 80, .3);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.7 "Vazirmatn", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.4; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  font-weight: 700; box-shadow: 0 8px 24px -10px var(--glow);
  transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--block { width: 100%; padding-block: 11px; }
.btn--ghost { background: var(--panel-2); color: var(--ink); box-shadow: none; border: 1px solid var(--line-2); }
.btn--danger { background: var(--live); box-shadow: none; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 9px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--ink); }
.icon-btn.is-on { color: var(--live); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }
.only-mobile { display: none; }

.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* In normal flow, not a fixed scroller: phone keyboards resize the viewport under a fixed box while typing. */
body:has(#auth:not([hidden])) { overflow: auto; }
.auth {
  min-height: 100%; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(600px 400px at 80% 0%, rgba(91, 141, 239, .18), transparent 70%),
    radial-gradient(500px 400px at 10% 100%, rgba(139, 124, 246, .14), transparent 70%),
    var(--bg);
}
.auth__card {
  width: min(420px, 100%); padding: 28px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 800; font-size: 20px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 11px; }
.brand small { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 6px; margin-inline-start: 4px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; background: var(--bg-2); border-radius: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 7px; border-radius: 9px; cursor: pointer; color: var(--ink-3); font-weight: 700; }
.seg button[aria-selected="true"] { background: var(--panel-3); color: var(--ink); }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.form input, .composer textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form input[dir="ltr"] { text-align: left; }
.form__error { color: var(--live); font-size: 13px; }
.auth__foot { text-align: center; }
.auth__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.shell { position: fixed; inset: 0; display: grid; grid-template-columns: 72px 260px minmax(0, 1fr); }
.rail {
  background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0; overflow-y: auto; scrollbar-width: none; border-inline-end: 1px solid var(--line);
}
.rail::-webkit-scrollbar { display: none; }
.rail__sep { width: 32px; height: 2px; border-radius: 2px; background: var(--line-2); margin: 2px 0; }
.srv {
  position: relative; width: 48px; height: 48px; flex: none; border-radius: 16px; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer; overflow: visible;
  background: var(--panel-2); color: var(--ink-2); font-weight: 800; font-size: 17px;
  transition: border-radius .18s, background .18s, color .18s;
}
.srv img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.srv:hover, .srv.is-on { border-radius: 14px; background: var(--accent); color: #fff; }
.srv::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 50%; width: 4px; height: 0;
  border-radius: 0 4px 4px 0; background: var(--ink); transform: translateY(-50%); transition: height .18s;
}
[dir="rtl"] .srv::before { border-radius: 4px 0 0 4px; }
.srv:hover::before { height: 18px; }
.srv.is-on::before { height: 36px; }
.srv--add { color: var(--ok); background: var(--panel-2); }
.srv--add:hover { background: var(--ok); }
.srv .badge-voice { position: absolute; bottom: -2px; inset-inline-end: -2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ok); border: 3px solid var(--bg); }

.side { background: var(--panel); display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--line); }
.side__head { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__head span { overflow: hidden; text-overflow: ellipsis; }
.side__list { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.cat {
  display: flex; align-items: center; gap: 4px; width: 100%; padding: 14px 6px 4px; border: 0; background: none; cursor: pointer;
  color: var(--ink-4); font-size: 11.5px; font-weight: 800; letter-spacing: .02em; text-align: start;
}
.cat:hover { color: var(--ink-2); }
.cat svg { width: 12px; height: 12px; transition: transform .15s; }
.cat.is-collapsed svg { transform: rotate(90deg); }
[dir="rtl"] .cat.is-collapsed svg { transform: rotate(90deg); }
.ch {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin: 1px 0;
  border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--ink-3); text-align: start;
}
.ch svg { width: 18px; height: 18px; color: var(--ink-4); }
.ch span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch:hover { background: var(--panel-3); color: var(--ink-2); }
.ch.is-on { background: var(--panel-3); color: var(--ink); }
.ch.is-unread { color: var(--ink); font-weight: 700; }
.ch.is-live svg { color: var(--ok); }
.ch .count { font-size: 11px; color: var(--ink-4); }
.vlist { display: grid; gap: 1px; padding: 0 30px 4px 0; }
[dir="ltr"] .vlist { padding: 0 0 4px 30px; }
.vstatus { padding: 0 30px 2px 0; color: var(--ink-4); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[dir="ltr"] .vstatus { padding: 0 0 2px 30px; }
.vuser { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; color: var(--ink-3); font-size: 13.5px; }
.vuser span.name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vuser svg { width: 15px; height: 15px; color: var(--ink-4); }
.vuser .live-tag { font-size: 10px; font-weight: 800; color: #fff; background: var(--live); padding: 0 6px; border-radius: 5px; }

.av {
  --h: 220; position: relative; flex: none; display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: hsl(var(--h) 55% 46%); color: #fff; font-weight: 800; font-size: 13px;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av--xs { width: 22px; height: 22px; font-size: 10px; }
.av--lg { width: 40px; height: 40px; font-size: 15px; }
.av--xl { width: 84px; height: 84px; font-size: 30px; }
.av.is-speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ok); }
.av-wrap { position: relative; flex: none; display: inline-grid; }
.av-wrap .pres { position: absolute; bottom: -1px; inset-inline-end: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--panel); background: var(--ink-4); }
.pres--online { background: var(--ok) !important; }
.pres--idle { background: var(--idle) !important; }
.pres--dnd { background: var(--dnd) !important; }

.callbar { flex: none; margin: 0 8px 8px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); display: grid; gap: 8px; }
.callbar__row { display: flex; align-items: center; gap: 8px; }
.callbar__state { flex: 1; min-width: 0; line-height: 1.4; }
.callbar__state b { display: block; font-size: 13px; color: var(--ok); }
.callbar__state b.is-warn { color: var(--warn); }
.callbar__state span { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.callbar__state span:hover { color: var(--ink); text-decoration: underline; }
.callbar__tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.callbar__tools .btn { padding: 6px; }

.me { flex: none; height: 58px; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: var(--bg-2); border-top: 1px solid var(--line); }
.me__who { flex: 1; min-width: 0; line-height: 1.3; }
.me__who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__who span { display: block; font-size: 11.5px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .icon-btn { width: 32px; height: 32px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); }
.main__head { height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.main__title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 800; }
.main__title svg { color: var(--ink-4); }
.main__title .auto-delete { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 5px; flex: none; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.main__title .auto-delete svg { width: 14px; height: 14px; }
.main__title .topic { font-weight: 400; color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-inline-start: 1px solid var(--line-2); padding-inline-start: 10px; }
.conn { font-size: 12px; color: var(--warn); display: inline-flex; align-items: center; gap: 6px; }
.main__body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

.empty { margin: auto; display: grid; justify-items: center; gap: 12px; padding: 24px; text-align: center; max-width: 420px; }
.empty .big { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .big svg { width: 30px; height: 30px; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 0 8px; display: flex; flex-direction: column; }
.msgs__top { padding: 16px 20px 24px; display: grid; gap: 6px; }
.msgs__top .big { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); }
.msgs__top .big svg { width: 28px; height: 28px; }
.day { display: flex; align-items: center; gap: 12px; margin: 14px 20px 6px; color: var(--ink-4); font-size: 12px; font-weight: 700; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; padding: 2px 20px; }
.msg:hover { background: color-mix(in srgb, var(--panel-3) 45%, transparent); }
.msg--head { margin-top: 12px; padding-top: 4px; }
.msg__gutter { grid-row: span 2; }
.msg__time-inline { font-size: 10.5px; color: var(--ink-4); opacity: 0; text-align: center; padding-top: 4px; direction: ltr; }
.msg:hover .msg__time-inline { opacity: 1; }
.msg__meta { display: flex; align-items: baseline; gap: 8px; }
.msg__meta b { font-weight: 700; color: var(--ink); }
.msg__meta time { font-size: 11.5px; color: var(--ink-4); }
.msg__body { color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.msg__body .edited { font-size: 10.5px; color: var(--ink-4); margin-inline-start: 4px; }
.msg--pending .msg__body { opacity: .55; }
.msg--failed .msg__body { color: var(--live); }
.msg--system { color: var(--ink-3); font-size: 13.5px; }
.msg--system .msg__gutter { display: grid; place-items: center; color: var(--ok); }
.msg__reply { font-size: 12.5px; color: var(--ink-4); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.atts img { max-width: min(360px, 100%); max-height: 280px; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.att-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.att-file--web { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; width: min(340px, 100%); }
.att-file__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.att-file__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.att-file__info { display: flex; flex-direction: column; min-width: 0; }
.att-file__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file__size { font-size: 12.5px; color: var(--ink-3); }
.att-file__note { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.att-file--web .btn { align-self: flex-start; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; padding: 0 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.react.is-me { border-color: var(--accent); background: var(--accent-soft); }
.loader { display: grid; place-items: center; padding: 12px; }

.composer { flex: none; padding: 0 16px 16px; }
.composer__box { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); }
[dir="rtl"] .composer__box { padding: 6px 10px 6px 6px; }
.composer textarea { border: 0; background: transparent; resize: none; max-height: 200px; padding: 6px 2px; box-shadow: none !important; line-height: 1.6; unicode-bidi: plaintext; }
.composer__typing { height: 20px; font-size: 12px; color: var(--ink-3); padding: 2px 4px 0; }
.composer__locked { padding: 10px 14px; border-radius: 12px; background: var(--panel-2); color: var(--ink-3); font-size: 13.5px; }

.call { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #07080b; color: #f2f4f8; }
:root[data-theme="light"] .call { background: #10121a; }
.call__grid { flex: 1; min-height: 0; display: grid; gap: 12px; align-content: center; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); overflow-y: auto; }
.call__grid.has-stage { flex: none; grid-template-columns: repeat(auto-fill, 140px); justify-content: center; align-content: start; max-height: 140px; }
.tile {
  position: relative; aspect-ratio: 16 / 10; border-radius: 16px; background: #171a23; display: grid; place-items: center;
  border: 2px solid transparent; transition: border-color .12s; overflow: hidden;
}
.has-stage .tile { aspect-ratio: 16 / 11; }
.has-stage .tile .av--xl { width: 48px; height: 48px; font-size: 18px; }
.tile.is-speaking { border-color: var(--ok); }
.tile__name { position: absolute; bottom: 8px; inset-inline-start: 8px; max-width: calc(100% - 16px); display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 8px; background: rgba(0, 0, 0, .55); font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tile__name svg { width: 14px; height: 14px; color: #ff8b84; }
.tile__vol { position: absolute; top: 8px; inset-inline-end: 8px; opacity: 0; transition: opacity .15s; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .55); }
.tile:hover .tile__vol, .tile__vol:focus-within { opacity: 1; }
.tile__vol input { width: 90px; accent-color: var(--accent); }
.tile__vol svg { width: 14px; height: 14px; }
.stage { flex: 1; min-height: 0; position: relative; border-radius: 16px; overflow: hidden; background: #000; display: grid; place-items: center; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage__wait { position: absolute; display: grid; justify-items: center; gap: 10px; color: #c9cedb; }
.stage__paused { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(7, 8, 11, .82); font-weight: 700; }
.call__notice { margin: 0 auto; padding: 8px 14px; border-radius: 10px; background: rgba(224, 164, 59, .14); color: #f1c47a; font-size: 13px; text-align: center; max-width: 560px; }
.call__join { margin: auto; display: grid; justify-items: center; gap: 16px; text-align: center; padding: 24px; }
.call__join .avs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 360px; }

.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(400px, calc(100% - 32px)); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.dialog input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); outline: none; text-align: left; }
.dialog__actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 50; padding: 10px 16px; border-radius: 12px; background: var(--panel-3); color: var(--ink); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14px; }
.toast.is-error { border-color: color-mix(in srgb, var(--live) 50%, var(--line-2)); }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 820px) {
  .only-mobile { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); --tabbar-h: calc(57px + env(safe-area-inset-bottom)); }
  .shell[data-view="call"] { --tabbar-h: 0px; }
  .rail, .side {
    position: fixed; top: 0; bottom: var(--tabbar-h); z-index: 30; padding-top: env(safe-area-inset-top);
    transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s; will-change: transform;
  }
  .rail { inset-inline-start: 0; width: 72px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .side { inset-inline-start: 72px; width: min(300px, calc(100vw - 88px)); box-shadow: var(--shadow); }
  [dir="rtl"] .shell:not(.is-drawer) .rail, [dir="rtl"] .shell:not(.is-drawer) .side { transform: translateX(calc(100% + 360px)); }
  [dir="ltr"] .shell:not(.is-drawer) .rail, [dir="ltr"] .shell:not(.is-drawer) .side { transform: translateX(calc(-100% - 360px)); }
  .shell:not(.is-drawer) .rail, .shell:not(.is-drawer) .side { visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
  .scrim { position: fixed; inset: 0 0 var(--tabbar-h); z-index: 20; background: rgba(0, 0, 0, .5); animation: shell-fade .2s ease; }
  .shell.is-members-sheet .scrim { bottom: 0; z-index: 35; }
  .msg { padding-inline: 12px; column-gap: 10px; }
  .composer { padding: 0 10px 8px; }
}

/* App shell: members column/sheet, account sheet, phone tab bar and voice mini-bar. */
@keyframes shell-fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes members-in-rtl { from { transform: translateX(-100%); } }
@keyframes members-in-ltr { from { transform: translateX(100%); } }

body { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
.shell { bottom: auto; height: 100vh; height: 100dvh; }
.msgs, .side__list, .members__list { overscroll-behavior: contain; }
.ch { min-height: 36px; border-radius: 9px; }

.me__open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px; margin-inline-start: -4px;
  border: 0; border-radius: 10px; background: none; color: inherit; cursor: pointer; text-align: start;
}
.me__open:hover { background: var(--panel-3); }

.shell.has-members { grid-template-columns: 72px 260px minmax(0, 1fr) 248px; }
.members { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-inline-start: 1px solid var(--line); }
.members__head { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding-inline: 16px 8px; border-bottom: 1px solid var(--line); }
.members__head b { font-weight: 800; }
.members__head small { flex: 1; color: var(--ink-4); font-size: 12px; }
.shell.has-members #members-close { display: none; }
.members__list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.mem-group { display: flex; align-items: center; gap: 6px; padding: 14px 8px 6px; color: var(--ink-4); font-size: 11.5px; font-weight: 700; }
.mem-group i { width: 8px; height: 8px; flex: none; border-radius: 50%; }
.mem { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.mem:hover { background: var(--panel-3); }
.mem.is-offline { opacity: .5; }
.mem__who { flex: 1; min-width: 0; line-height: 1.35; }
.mem__name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.mem__name b { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem__sub { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem__sub.is-voice { color: var(--ok); }
.mem-more { padding: 8px; }
.pf { display: inline-grid; place-items: center; flex: none; color: var(--ink-3); cursor: help; }
.pf svg { width: 15px; height: 15px; stroke-width: 1.9; }
.pf:hover { color: var(--ink); }

.sheet { padding: 16px; width: min(380px, calc(100% - 32px)); }
.sheet__me { display: flex; align-items: center; gap: 12px; padding: 4px 4px 8px; }
.sheet__me .me__who { flex: 1; min-width: 0; line-height: 1.35; }
.sheet__me .me__who b { font-size: 16px; }
.sheet__label { padding: 10px 6px 2px; color: var(--ink-4); font-size: 12px; font-weight: 700; }
.sheet__group { display: grid; gap: 2px; margin-top: 8px; padding: 4px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.sheet__label + .sheet__group { margin-top: 4px; }
.sheet__row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border: 0; border-radius: 10px;
  background: none; color: var(--ink); cursor: pointer; text-align: start;
}
.sheet__row:hover { background: var(--panel-3); }
.sheet__row span { flex: 1; }
.sheet__row small { color: var(--ink-3); font-size: 12.5px; }
.sheet__row svg { color: var(--ink-3); }
.sheet__row[aria-checked="true"] svg { color: var(--accent); }
.sheet__row.is-danger, .sheet__row.is-danger svg { color: var(--live); }
.sheet__dot { width: 10px; height: 10px; flex: none; margin-inline: 5px; border-radius: 50%; background: var(--ink-4); }

.composer__box { border-radius: 14px; }
.composer__send.icon-btn.is-active { background: var(--accent); color: var(--accent-ink); }
.composer__send.icon-btn.is-active:hover { filter: brightness(1.08); }

.minibar, .tabbar { display: none; }

@media (max-width: 1099px) {
  .members {
    position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 40; width: min(320px, 88vw);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    border-inline-start: 1px solid var(--line-2); box-shadow: var(--shadow);
  }
  [dir="rtl"] .members { animation: members-in-rtl .24s cubic-bezier(.2, .8, .2, 1); }
  [dir="ltr"] .members { animation: members-in-ltr .24s cubic-bezier(.2, .8, .2, 1); }
  .shell.is-members-sheet .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .5); animation: shell-fade .2s ease; }
}

@media (max-width: 820px) {
  .main__head {
    height: calc(56px + env(safe-area-inset-top)); gap: 2px;
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
  }
  .main__head .icon-btn { width: 44px; height: 44px; border-radius: 14px; }
  .main__title { font-size: 16px; font-weight: 700; gap: 6px; }
  .main__title .topic, .main__title .auto-delete { display: none; }
  .main__title > svg { width: 18px; height: 18px; }
  #theme-toggle { display: none; }

  .composer__box { min-height: 50px; align-items: center; border-radius: 16px; background: var(--panel); }
  [dir="rtl"] .composer__box { padding: 4px 12px 4px 5px; }
  [dir="ltr"] .composer__box { padding: 4px 5px 4px 12px; }
  .composer__send.icon-btn { width: 40px; height: 40px; border-radius: 12px; }

  .minibar:not([hidden]) {
    display: flex; align-items: center; gap: 10px; flex: none; margin: 0 10px 8px; padding: 8px;
    border-radius: 16px; background: var(--panel); border: 1px solid var(--line-2); cursor: pointer;
    animation: shell-fade .2s ease;
  }
  .minibar__icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
  .minibar__text { flex: 1; min-width: 0; line-height: 1.45; }
  .minibar__text b { display: block; font-size: 13.5px; color: var(--ok); }
  .minibar__text b.is-warn { color: var(--warn); }
  .minibar__text span { display: block; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .minibar__btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--panel-3); color: var(--ink); cursor: pointer; }
  .minibar__btn.is-off { background: var(--ink); color: var(--bg); }
  .minibar__btn--leave { background: var(--live); color: #fff; }

  .tabbar {
    display: flex; flex: none; border-top: 1px solid var(--line); background: var(--panel);
    padding: 2px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }
  .shell[data-view="call"] .tabbar { display: none; }
  .tabbar button {
    position: relative; flex: 1; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 6px 0 2px; border: 0; background: none; color: var(--ink-3); font-size: 11px; font-weight: 500; line-height: 1.3; cursor: pointer;
  }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .tabbar button.is-live::after {
    content: ""; position: absolute; top: 5px; inset-inline-start: calc(50% + 6px); width: 9px; height: 9px;
    border-radius: 50%; background: var(--ok); border: 2px solid var(--panel);
  }

  .members__head { height: 56px; }
  .members__head .icon-btn { width: 44px; height: 44px; }
  .sheet:modal {
    margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; border-inline: 0; border-bottom: 0;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1);
  }
  .sheet::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 10px; border-radius: 4px; background: var(--line-2); }
}

@media (max-width: 820px), (pointer: coarse) {
  .form input, .composer textarea, .dialog input { font-size: 16px; }
}

@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .me { height: 64px; }
  .me .icon-btn { width: 40px; height: 44px; }
  .ch { min-height: 44px; }
  .cat { min-height: 36px; }
  .vuser { min-height: 36px; }
  .mem { min-height: 52px; }
  .dialog__actions .btn { min-height: 44px; }
}

@media (hover: none) {
  .msg:hover, .ch:hover:not(.is-on), .mem:hover, .me__open:hover, .sheet__row:hover { background: none; }
  .msg__time-inline { opacity: .6; }
  .callbar__state span { text-decoration: underline dotted; text-underline-offset: 3px; }
  .pf { cursor: pointer; }
}

[data-clean-reload].is-busy svg { animation: spin .8s linear infinite; }

/* The server's Cinema channel: desktop only. */
.cine-only { position: relative; flex: 1; display: grid; place-items: center; padding: 24px 16px; overflow: hidden; }
.cine-only__glow { position: absolute; left: 50%; top: -120px; width: 760px; height: 520px; transform: translateX(-50%); background: radial-gradient(ellipse at 50% 0, var(--glow), transparent 65%); pointer-events: none; animation: cine-glow 1.4s ease-out both; }
@keyframes cine-glow { from { opacity: 0; } }
.cine-only__card { position: relative; width: min(460px, 100%); display: grid; justify-items: center; gap: 12px; text-align: center; padding: 30px 24px 24px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: cine-rise .7s cubic-bezier(.32, .72, 0, 1) both; }
@keyframes cine-rise { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.cine-only__icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 30px -8px var(--glow); animation: cine-float 4s ease-in-out infinite; }
.cine-only__icon svg { width: 30px; height: 30px; }
@keyframes cine-float { 50% { transform: translateY(-5px); } }
.cine-only__kick { font-size: 11px; font-weight: 800; letter-spacing: .3em; color: var(--accent); }
.cine-only h2 { font-size: 20px; line-height: 1.5; }
.cine-only p { font-size: 13.5px; line-height: 1.9; }
.cine-only__perks { width: 100%; display: grid; gap: 8px; margin-top: 4px; }
.cine-only__perk { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); text-align: start; animation: cine-in .5s cubic-bezier(.32, .72, 0, 1) both; }
.cine-only__perk > span { width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.cine-only__perk > span svg { width: 16px; height: 16px; }
.cine-only__perk b { display: block; font-size: 13px; }
.cine-only__perk small { font-size: 11.5px; color: var(--ink-3); }
@keyframes cine-in { from { opacity: 0; transform: translateY(8px); } }
.cine-only__go { margin-top: 6px; width: 100%; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .cine-only *, .cine-only__glow { animation: none !important; } }
