:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-text: #ffffff;
  --mine: #d1fae5;
  --unread: #e11d48;
  --mine-text: #064e3b;
  --theirs: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --chat-bg: #e7eef0;
  --read: #0284c7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #111827;
    --panel-2: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1f2937;
    --accent: #14b8a6;
    --accent-2: #2dd4bf;
    --accent-text: #042f2e;
    --mine: #115e59;
    --mine-text: #ecfeff;
    --theirs: #1e293b;
    --chat-bg: #0b1220;
    --read: #38bdf8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Vazirmatn, "Vazir", "Segoe UI", Tahoma, system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.screen { position: fixed; inset: 0; }
.ico { display: inline-flex; width: 22px; height: 22px; }
.ico svg { width: 100%; height: 100%; }

.logo { width: 84px; height: 84px; border-radius: 22px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

.card {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 16px;
  max-width: 420px;
  width: calc(100% - 32px);
}
.login-card { display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: right; }
.login-card .logo { align-self: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 22px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input:not([type]), textarea.field, select {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; text-align: center; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }

/* ---- layout --------------------------------------------------------- */
#main { display: flex; }
#sidebar {
  width: 360px;
  max-width: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); position: relative; }
#chat-empty { flex: 1; padding: 24px; }
.big-lock { width: 56px; height: 56px; margin: 0 auto 8px; color: var(--accent); opacity: .8; }
.big-lock svg { width: 100%; height: 100%; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 60px;
  flex: none;
}
.bar .titles { flex: 1; min-width: 0; }
.bar .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-titles { cursor: pointer; }
.sub.online { color: var(--ok); }
.sub.offline-state { color: var(--danger); }
.back { display: none; }

.avatar {
  --hue: 170;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: hsl(var(--hue) 55% 42%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
  position: relative;
  font-size: 17px;
}
.avatar.group { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.avatar .ico { width: 22px; height: 22px; }
.avatar.huge { width: 112px; height: 112px; font-size: 44px; }
.avatar.huge .ico { width: 52px; height: 52px; }
.avatar .dot {
  position: absolute; bottom: 0; left: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--panel);
}

.tabs { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 14px;
  white-space: nowrap; font-size: 14px; display: inline-flex; gap: 6px; align-items: center;
}
.tab.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }

#banners { flex: none; }
.banner {
  margin: 8px 10px 0; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  font-size: 13.5px; display: flex; gap: 10px; align-items: center;
}
.banner .grow { flex: 1; }
.banner .x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 0 4px; }

.list { flex: 1; overflow-y: auto; padding: 6px 0 calc(16px + var(--safe-bottom)); }
.item {
  display: flex; gap: 12px; align-items: center; padding: 9px 12px; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: right;
}
.item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.item.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.item .body { flex: 1; min-width: 0; }
.item .row1, .item .row2 { display: flex; gap: 8px; align-items: center; }
.item .name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); flex: none; }
.item .preview { flex: 1; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--unread); color: #fff; border-radius: 999px; min-width: 22px; height: 22px;
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; flex: none;
}
.section-label { font-size: 12.5px; color: var(--muted); padding: 10px 14px 4px; }
.empty-state { padding: 28px 20px; text-align: center; color: var(--muted); }

/* ---- messages ------------------------------------------------------- */
.messages { flex: 1; overflow-y: auto; padding: 12px 10px 8px; display: flex; flex-direction: column; gap: 3px; }
.e2e-note {
  align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 10px;
  padding: 6px 12px; margin: 4px 0 10px; display: flex; gap: 6px; align-items: center; text-align: center; max-width: 92%;
}
.e2e-note .ico { width: 14px; height: 14px; flex: none; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 999px; padding: 2px 12px; margin: 10px 0 6px; }
.msg {
  max-width: min(78%, 560px); padding: 6px 10px 4px; border-radius: 14px; background: var(--theirs);
  align-self: flex-end; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.mine { align-self: flex-start; background: var(--mine); color: var(--mine-text); }
.msg.cont { margin-top: -1px; }
.msg { position: relative; touch-action: pan-y pinch-zoom; transition: transform .18s; }
.msg.swiping { transition: none; }
.msg.swipe-ready { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }
.msg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 3px var(--accent); } }
.quote {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-width: 120px; margin: 2px 0 4px; padding: 4px 8px;
  border: 0; border-inline-start: 3px solid hsl(var(--hue, 170) 60% 42%); border-radius: 6px;
  background: color-mix(in srgb, currentColor 7%, transparent); color: inherit; font: inherit; text-align: start; cursor: pointer;
}
.msg.has-media .quote { margin: 2px 0 6px; }
.q-name { font-size: 12.5px; font-weight: 700; color: hsl(var(--hue, 170) 60% 38%); }
.q-text { display: block; max-width: 100%; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-color-scheme: dark) { .q-name { color: hsl(var(--hue, 170) 70% 65%); } }
.reply-btn {
  position: absolute; top: 50%; inset-inline-end: -38px; transform: translateY(-50%); width: 30px; height: 30px;
  display: none; place-items: center; border: 0; border-radius: 50%; background: var(--panel); color: var(--muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15); cursor: pointer; padding: 0;
}
.msg.theirs .reply-btn { inset-inline-end: auto; inset-inline-start: -38px; }
.reply-btn .ico { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .msg .reply-btn { display: grid; opacity: 0; transition: opacity .12s; }
  .msg:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; }
}
.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line); flex: none;
}
.reply-bar > .ico { color: var(--accent); flex: none; }
.reply-bar .quote-body { flex: 1; min-width: 0; border-inline-start: 3px solid hsl(var(--hue, 170) 60% 42%); padding-inline-start: 8px; }
.reply-bar .q-text { color: var(--muted); opacity: 1; }
.reply-bar + .composer { border-top: 0; }
.back { position: relative; }
.back-badge { position: absolute; top: 0; inset-inline-end: -4px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 4px; }
.msg .sender { font-size: 12.5px; font-weight: 700; color: hsl(var(--hue, 170) 60% 40%); }
@media (prefers-color-scheme: dark) { .msg .sender { color: hsl(var(--hue, 170) 70% 65%); } }
.msg .text { white-space: pre-wrap; }
.msg .text a { color: inherit; text-decoration: underline; }
.msg .meta { display: flex; gap: 4px; justify-content: flex-end; align-items: center; font-size: 11px; margin-top: 1px; }
.msg .meta .time { opacity: .7; }
.msg .meta .ico { width: 15px; height: 15px; opacity: .7; }
.ico.tick.read { color: var(--read); opacity: 1; }
.item .row2 .ico.tick { width: 16px; height: 16px; flex: none; color: var(--muted); }
.item .row2 .ico.tick.read { color: var(--read); }
.msg.failed .text { font-style: italic; opacity: .7; }
.msg.pending .meta { opacity: .9; }
.msg.call-log { align-self: center; background: var(--panel); font-size: 13px; display: flex; gap: 8px; align-items: center; padding: 6px 14px; }
.msg.call-log .ico { width: 16px; height: 16px; }
.msg.call-log.missed { color: var(--danger); }
.typing { font-size: 12.5px; color: var(--accent); }
.load-more { align-self: center; font-size: 12.5px; color: var(--muted); padding: 4px; }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + var(--safe-bottom));
  background: var(--panel); border-top: 1px solid var(--line); flex: none;
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--panel-2); border-radius: 22px;
  padding: 10px 14px; font-size: 16px; max-height: 140px; outline: none; line-height: 1.5; color: var(--text);
}
.send-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
/* Persian layout: send / mic on the right, attach on the left */
.composer .send-btn { order: -1; }
.composer .attach-btn { order: 1; }

.call-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: color-mix(in srgb, var(--ok) 16%, var(--panel));
  border-bottom: 1px solid var(--line); font-size: 14px; flex: none;
}
.call-banner .grow { flex: 1; }

.attach-btn { color: var(--muted); align-self: center; }
.rec-bar {
  flex: 1; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 6px;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 22px;
}
.rec-bar .icon-btn { color: var(--danger); width: 36px; height: 36px; order: 1; } /* cancel far from send */
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-label { color: var(--muted); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn.recording { background: var(--danger); color: #fff; }

.msg.has-media { width: min(280px, 78%); padding: 4px 4px 4px; }
.msg.has-media .text, .msg.has-media .sender, .msg.has-media .meta { padding: 0 6px; }
.photo {
  display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px; cursor: zoom-in;
  background: color-mix(in srgb, var(--text) 10%, transparent); min-height: 80px;
}
.media-error { padding: 18px 10px; font-size: 13px; color: var(--muted); text-align: center; }
.voice { display: flex; align-items: center; gap: 8px; padding: 4px 4px 0; min-width: 230px; }
.vp-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text);
}
.vp-btn .ico { width: 18px; height: 18px; }
/* tall invisible hit area so the knob is easy to grab with a finger */
.vp-bar { flex: 1; position: relative; height: 28px; display: flex; align-items: center; cursor: pointer; touch-action: pan-y; outline: none; }
.vp-track { flex: 1; height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.vp-fill { height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.vp-knob {
  position: absolute; top: 50%; inset-inline-start: 0; width: 12px; height: 12px; margin-inline-start: -6px;
  border-radius: 50%; background: var(--accent); transform: translateY(-50%); transition: transform .12s; pointer-events: none;
}
.voice.dragging .vp-knob, .vp-bar:focus-visible .vp-knob { transform: translateY(-50%) scale(1.4); }
.vp-time { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; min-width: 36px; }
.vp-speed {
  flex: none; min-width: 36px; padding: 3px 7px; border: 0; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, currentColor 12%, transparent); color: inherit; font: inherit; font-size: 12px; font-weight: 700;
}
/* a voice message I have not listened to yet */
.voice.unplayed .vp-time::after {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--read); margin-inline-start: 5px; vertical-align: middle;
}
.file-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px;
  background: color-mix(in srgb, currentColor 8%, transparent); color: inherit; font: inherit; text-align: start; cursor: pointer;
}
.file-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; }
.file-ic .ico { width: 20px; height: 20px; }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; opacity: .75; }
.file-act { flex: none; opacity: .7; }
.file-act .ico { width: 20px; height: 20px; }
.file-card.loading .file-act { animation: blink 1s ease-in-out infinite; }
.file-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.file-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.file-row .file-name { flex: 1; min-width: 0; font-weight: 400; }
.file-row.too-big { color: var(--danger, #dc2626); }
#chat.drop { outline: 3px dashed var(--accent); outline-offset: -8px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.preview-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.viewer {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center;
  padding: calc(56px + var(--safe-top)) 8px calc(16px + var(--safe-bottom));
}
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-bar { position: absolute; top: calc(8px + var(--safe-top)); left: 8px; display: flex; gap: 8px; }
.icon-btn.light { color: #fff; background: rgba(255, 255, 255, .12); }

/* ---- call screen ---------------------------------------------------- */
.call-screen {
  position: fixed; inset: 0; z-index: 50; background: #020617; color: #fff;
  display: flex; flex-direction: column; padding: var(--safe-top) 0 var(--safe-bottom);
}
.call-top { text-align: center; padding: 14px 12px 8px; flex: none; }
.call-title { font-size: 18px; font-weight: 700; }
.call-status { font-size: 13px; opacity: .75; }
.tiles {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  grid-auto-rows: minmax(0, 1fr);
  position: relative;
}
.tile {
  position: relative; background: #0f172a; border-radius: 16px; overflow: hidden; min-height: 120px;
  display: flex; align-items: center; justify-content: center;
}
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.local.mirror video { transform: scaleX(-1); }
.tile.no-video video { opacity: 0; position: absolute; width: 1px; height: 1px; }
.tile .avatar { position: absolute; }
.tile:not(.no-video) .avatar { display: none; }
.tile .label {
  position: absolute; bottom: 8px; right: 8px; background: rgba(0, 0, 0, .55); padding: 2px 10px; border-radius: 999px;
  font-size: 13px; display: flex; gap: 6px; align-items: center;
}
.tile .label .ico { width: 14px; height: 14px; }
.tile .state { position: absolute; top: 8px; right: 8px; font-size: 12px; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 999px; }
/* one-to-one video: remote fills the screen, me in a small corner */
.tiles.duo { display: block; }
.tiles.duo .tile.remote { position: absolute; inset: 8px; }
.tiles.duo .tile.local {
  position: absolute; width: 30%; max-width: 180px; aspect-ratio: 3 / 4; min-height: 0; bottom: 16px; left: 16px; z-index: 2;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
}
.tiles.duo .tile.local .avatar { width: 48px; height: 48px; font-size: 20px; }
.audio-unlock { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; }
.call-controls { display: flex; justify-content: center; gap: 18px; padding: 14px 12px 22px; flex: none; }
.round {
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.round .ico { width: 26px; height: 26px; }
.round.off { background: #fff; color: #0f172a; }
.round.danger { background: var(--danger); color: #fff; }
.round.ok { background: var(--ok); color: #fff; }
.round.danger .ico.hang { transform: rotate(135deg); }

.incoming {
  position: fixed; inset: 0; z-index: 60; background: radial-gradient(circle at 50% 30%, #134e4a, #020617 70%);
  color: #fff; display: flex; align-items: center; justify-content: center; text-align: center;
}
.inc-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; }
.inc-name { font-size: 24px; font-weight: 700; margin-top: 12px; }
.inc-what { opacity: .8; }
.inc-actions { display: flex; gap: 70px; margin-top: 50px; }
.inc-actions .round { width: 72px; height: 72px; }
.inc-actions .ok { animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } 50% { transform: rotate(0); } }

/* ---- modal ---------------------------------------------------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 70; background: rgba(2, 6, 23, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--panel); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; box-shadow: var(--shadow); padding-bottom: var(--safe-bottom);
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; flex: 1; font-size: 17px; }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); justify-content: flex-start; }
@media (min-width: 700px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 20px; }
}
.group-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.group-box h4 { margin: 0; font-size: 15px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.checks { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 12.5px; }
.chip.admin { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.admin-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-item:last-child { border-bottom: 0; }
.admin-item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.admin-item .uname { color: var(--muted); font-size: 13px; direction: ltr; text-align: right; }
.cred {
  background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 12px; padding: 12px; font-size: 15px;
  direction: rtl; white-space: pre-wrap; user-select: all;
}
.fp { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; text-align: center; letter-spacing: 1px; font-size: 15px; }
.pw-row { display: flex; gap: 8px; }
.help-steps { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }
.pw-row input { flex: 1; }

#toasts { position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90%; box-shadow: var(--shadow); animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* ---- small screens: one pane at a time ------------------------------ */
@media (max-width: 760px) {
  #sidebar { width: 100%; border: 0; }
  #chat { position: fixed; inset: 0; transform: translateX(-100%); transition: transform .2s ease; z-index: 10; }
  #main.chat-open #chat { transform: none; }
  .back { display: inline-flex; }
  .back .ico { transform: none; }
}
