/* =====================================================================
   پیام‌رسان دیمن — ظاهر
   Idea: a student's squared notebook. Fountain-pen blue ink on white paper,
   faint grid lines, and the red margin rule as the one bold accent.
   ===================================================================== */

:root {
  --paper: #FBFCFE;
  --sheet: #FFFFFF;
  --grid: #E4EAF6;
  --rule: #DCE3F0;
  --ink: #1D3A8A;          /* fountain-pen blue: primary actions, links */
  --ink-dark: #142A66;
  --ink-soft: #EAF0FB;
  --margin: #D64545;       /* notebook margin red: pin, unread, the brand rule */
  --text: #22262E;
  --muted: #5E6675;
  --faint: #8A92A2;
  --ok: #1E7A4F;
  --warn: #9A5B00;
  --warn-bg: #FFF5E0;
  --danger: #B42318;
  --danger-bg: #FDECEA;

  --font: "Vazirmatn", "Vazir", Tahoma, "Segoe UI", sans-serif;
  --fs-xs: 12.5px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 24px;
  --fs-mark: 34px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-pill: 999px;
  --bar-h: 60px;
  --nav-h: 62px;
  --side-w: 380px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Graph-paper background for the entry screens */
.paper-grid {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { font-size: var(--fs-mark); font-weight: 800; color: var(--ink); opacity: .35; }

/* ---------- network banner ---------- */
.net {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  padding: 6px 16px; text-align: center;
  font-size: var(--fs-sm); font-weight: 600;
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid #F1D9A8;
}

/* ---------- entry / auth screens ---------- */
.auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}
.sheet {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 28px 58px 24px 22px;   /* wide right padding = the notebook margin */
  box-shadow: 0 1px 0 var(--rule), 0 12px 32px -18px rgba(29, 58, 138, .35);
}
/* the red margin line of a notebook page, on the right (start) side in RTL */
.sheet::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: 40px;
  width: 1.5px; background: var(--margin); opacity: .55;
}
.wordmark {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 18px;
}
.wordmark b { font-size: var(--fs-mark); font-weight: 800; color: var(--ink); line-height: 1.2; letter-spacing: -.5px; }
.wordmark span { font-size: var(--fs-sm); color: var(--muted); }
.auth h1 { font-size: var(--fs-xl); font-weight: 800; line-height: 1.5; margin: 0 0 6px; }
.auth .lead { color: var(--muted); margin: 0 0 22px; font-size: var(--fs-sm); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; }
.field .opt { color: var(--faint); font-weight: 400; }
.input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid #C9D3E6; border-radius: var(--r-sm);
  background: #fff; font-size: var(--fs-md);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.ltr { direction: ltr; text-align: left; letter-spacing: .5px; }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.err { font-size: var(--fs-xs); color: var(--danger); margin-top: 4px; }
.form-error {
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 14px;
  font-size: var(--fs-sm);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  font-weight: 700; font-size: var(--fs-md);
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--ink); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--ink-dark); }
.btn-quiet { background: transparent; color: var(--ink); border-color: #C9D3E6; }
.btn-quiet:hover { background: var(--ink-soft); }
.btn-danger { background: transparent; color: var(--danger); border-color: #F0C6C1; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 38px; padding: 0 14px; font-size: var(--fs-sm); width: auto; }

.alt-links { margin-top: 18px; display: grid; gap: 6px; font-size: var(--fs-sm); }
.link { color: var(--ink); text-decoration: none; font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; }

/* recovery code */
.code-box {
  direction: ltr; text-align: center;
  font-size: 21px; font-weight: 800; letter-spacing: 2px; color: var(--ink); white-space: nowrap;
  background: var(--ink-soft); border: 1.5px dashed #9FB3DE; border-radius: var(--r-sm);
  padding: 14px 8px; margin: 14px 0 10px; user-select: all;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

/* ---------- app shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.side { display: flex; flex-direction: column; flex: 1; background: var(--sheet); }
.main { display: none; }

.bar {
  position: sticky; top: 0; z-index: 10;
  height: var(--bar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}
.bar .brand { font-size: 23px; font-weight: 800; color: var(--ink); letter-spacing: -.3px; }
.bar .brand::after {
  /* the margin rule as the brand's signature underline */
  content: ""; display: block; height: 2px; width: 22px; margin-top: -4px;
  background: var(--margin); border-radius: 2px;
}
.bar h2 { font-size: var(--fs-lg); margin: 0; font-weight: 700; }
.bar .grow { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--ink-soft); color: var(--ink); }
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* conversation list: rows, not cards */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 16px; min-height: 76px;
  background: transparent; border: 0; text-align: right; cursor: pointer;
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit;
}
.row:hover { background: #F6F8FD; }
.row[aria-current="page"] { background: var(--ink-soft); }
.row .body { flex: 1; min-width: 0; }
.row .top { display: flex; align-items: center; gap: 6px; }
.row .title { font-weight: 700; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { margin-inline-start: auto; font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; }
.row .sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub.accent { color: var(--ink); font-weight: 600; }
.row .sub.wait { color: var(--warn); }
.pin { width: 15px; height: 15px; color: var(--margin); flex: none; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--margin); color: #fff; font-size: var(--fs-xs); font-weight: 700;
  display: inline-grid; place-items: center; flex: none;
}
.pinned-row { background: linear-gradient(to left, rgba(214, 69, 69, .05), transparent 60%); }
.list-note { padding: 14px 16px; font-size: var(--fs-xs); color: var(--faint); }

.avatar {
  width: 50px; height: 50px; border-radius: 50%; flex: none;
  display: grid; place-items: center; overflow: hidden;
  font-weight: 800; font-size: var(--fs-lg); color: #fff; background: var(--ink);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.channel { background: var(--ink); position: relative; }
.avatar.channel::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.avatar.avatar-empty { background: #fff; color: var(--ink); border: 1.5px dashed #9FB3DE; }
.avatar.lg { width: 96px; height: 96px; font-size: 34px; }

/* bottom navigation (phones) */
.nav {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--sheet); border-top: 1px solid var(--rule);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: var(--fs-xs); color: var(--faint); text-decoration: none; font-weight: 600;
}
.nav a[aria-current="page"] { color: var(--ink); }
.nav .icon { width: 24px; height: 24px; }
.side-scroll { flex: 1; overflow-y: auto; }

/* inner pages (profile, placeholders) */
.page { flex: 1; overflow-y: auto; background: var(--paper); }
.page-inner { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; }
.section {
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 18px 16px; margin-bottom: 14px;
}
.section h3 { margin: 0 0 12px; font-size: var(--fs-md); font-weight: 700; }
.section p { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.chip { display: inline-block; padding: 1px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; background: var(--ink-soft); color: var(--ink); }
.chip.ok { background: #E6F4EC; color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--danger-bg); color: var(--danger); }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head .who { font-size: var(--fs-lg); font-weight: 800; line-height: 1.5; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* empty / placeholder states */
.empty {
  display: grid; place-items: center; align-content: center; text-align: center; gap: 10px;
  padding: 56px 24px; color: var(--muted);
}
.empty .icon { width: 44px; height: 44px; color: #9FB3DE; stroke-width: 1.4; }
.empty h3 { margin: 0; color: var(--text); font-size: var(--fs-lg); }
.empty p { margin: 0; max-width: 36ch; font-size: var(--fs-sm); }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); max-width: calc(100vw - 32px);
}

/* dialog */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 30, 60, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dialog-backdrop .sheet { max-width: 440px; }
.dialog-title { font-size: var(--fs-lg); font-weight: 800; margin: 0 0 6px; }
.dialog-text { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.stack { display: grid; gap: 8px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.ltr-cell { text-align: right; }
.note-top { margin-top: 10px !important; }

.noscript { padding: 24px; text-align: center; }

/* ---------- channel ---------- */
.bar-title { flex: 1; min-width: 0; line-height: 1.35; }
.bar-title h2 { font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { font-size: var(--fs-xs); color: var(--faint); }
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }
.channel-top { background: var(--sheet); border-bottom: 1px solid var(--rule); }
.channel-top:empty { display: none; }
.pinned-bar {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 16px; border: 0; background: transparent; cursor: pointer; text-align: right;
  border-inline-start: 3px solid var(--margin);
}
.pinned-bar:hover { background: #FBF3F3; }
.pinned-text { display: grid; min-width: 0; font-size: var(--fs-sm); line-height: 1.5; }
.pinned-text b { color: var(--margin); font-size: var(--fs-xs); }
.pinned-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cat-row { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none; }
.cat-row + .pinned-bar, .pinned-bar + .cat-row { border-top: 1px solid var(--rule); }
.chip.cat { border: 1px solid var(--rule); background: #fff; color: var(--muted); white-space: nowrap; }
.chip.cat.filter { cursor: pointer; padding: 3px 12px; font-size: var(--fs-xs); }
.chip.cat.filter.on { outline: 2px solid currentColor; outline-offset: -2px; }
.chip.pin-chip { background: #FBF0F0; color: var(--margin); display: inline-flex; align-items: center; gap: 2px; }

.feed { flex: 1; overflow-y: auto; background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; }
.feed-inner { max-width: 680px; margin: 0 auto; padding: 16px 12px 96px; display: grid; gap: 12px; }
.feed-older { display: flex; justify-content: center; }
.post {
  position: relative; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 14px 16px 10px; box-shadow: 0 1px 0 var(--rule);
}
/* urgent posts carry the notebook's red margin rule */
.post.urgent { border-inline-start: 4px solid var(--margin); }
.post-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 8px; }
.post-tags:not(:empty) { margin-bottom: 6px; }
.post-more { margin-inline-start: auto; width: 32px; height: 32px; }
.post-title { margin: 0 0 4px; font-size: var(--fs-lg); line-height: 1.6; font-weight: 800; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-md); line-height: 1.95; }
.post-body a { color: var(--ink); }
.atts { display: grid; gap: 8px; margin-top: 10px; }
.att-grid { display: grid; gap: 4px; border-radius: var(--r-sm); overflow: hidden; }
.att-grid.n2 { grid-template-columns: 1fr 1fr; }
.att-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.att-img { padding: 0; border: 0; background: var(--ink-soft); cursor: zoom-in; display: block; }
.att-img img { width: 100%; height: auto; max-height: 420px; object-fit: cover; }
.att-grid.n2 .att-img img, .att-grid.n3 .att-img img { aspect-ratio: 1; height: 100%; }
.att-file {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-sm); text-decoration: none; color: var(--text); background: #FAFBFE;
}
.att-file:hover { border-color: #9FB3DE; }
.att-icon { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--ink-soft); color: var(--ink); display: grid; place-items: center; flex: none; }
.att-meta { flex: 1; min-width: 0; display: grid; line-height: 1.5; }
.att-name { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-size { font-size: var(--fs-xs); color: var(--faint); }
.post-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: var(--fs-xs); color: var(--faint); }
.post-foot .grow { flex: 1; }
.views { display: inline-flex; align-items: center; gap: 3px; }
.views .icon { width: 15px; height: 15px; }
.unread-divider { display: flex; align-items: center; gap: 10px; color: var(--margin); font-size: var(--fs-xs); font-weight: 700; }
.unread-divider::before, .unread-divider::after { content: ""; flex: 1; height: 1px; background: rgba(214, 69, 69, .4); }
.fab-row { position: sticky; bottom: 0; display: flex; justify-content: center; padding: 10px 16px; pointer-events: none; margin-top: -68px; }
.fab { width: auto; pointer-events: auto; box-shadow: 0 8px 24px -10px rgba(29, 58, 138, .7); border-radius: var(--r-pill); }

/* panels (bottom sheet on phones, centred on desktop) */
.sheet-backdrop { align-items: flex-end; padding: 0; }
.panel {
  width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--sheet); border-radius: var(--r-md) var(--r-md) 0 0; overflow: hidden;
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--rule); }
.panel-head h2 { flex: 1; margin: 0; font-size: var(--fs-md); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { overflow-y: auto; padding: 16px; display: grid; gap: 12px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.menu { display: grid; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border: 0; background: none; cursor: pointer; font-weight: 600; text-align: right; border-bottom: 1px solid var(--rule); }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--ink-soft); }
.menu-item.danger { color: var(--danger); }
.textarea { height: auto; min-height: 140px; padding: 10px 14px; line-height: 1.9; resize: vertical; }
select.input { appearance: auto; }
.field.check { display: flex; align-items: center; gap: 8px; padding-top: 30px; }
.field.check input { width: 20px; height: 20px; accent-color: var(--margin); }
.field.check label { margin: 0; }
.uploads { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.upload { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: var(--r-sm); }
.upload.err { border-color: #F0C6C1; background: var(--danger-bg); }
.upload.err .att-size { color: var(--danger); }
.search-form { display: flex; gap: 8px; }
.search-form .input { height: 42px; }
.search-results { display: grid; gap: 10px; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); }
.tab { flex: 1; padding: 10px; border: 0; background: none; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.report-summary { margin: 0; font-size: var(--fs-sm); color: var(--text); background: var(--ink-soft); padding: 10px 12px; border-radius: var(--r-sm); }
.people { list-style: none; margin: 0; padding: 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.person-name { flex: 1; display: grid; font-weight: 600; font-size: var(--fs-sm); line-height: 1.5; }
.person-name small { color: var(--faint); font-weight: 400; }
.person-meta { font-size: var(--fs-xs); color: var(--muted); }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10, 16, 32, .92); display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain; }
.lightbox-bar { display: flex; gap: 8px; }
.btn.on-dark { color: #fff; border-color: rgba(255,255,255,.35); text-decoration: none; }
.btn.on-dark:hover { background: rgba(255,255,255,.1); }

/* ---------- advisors & requests ---------- */
.notice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px;
  background: var(--ink-soft); border-radius: var(--r-md); border-inline-start: 3px solid var(--ink); }
.notice > div { flex: 1; }
.notice b { display: block; font-size: var(--fs-sm); }
.notice p { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.notice.wait { background: var(--warn-bg); border-color: var(--warn); }
.notice.bad { background: var(--danger-bg); border-color: var(--danger); }
.advisors { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.advisor { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); }
.advisor.head { border: 0; padding: 0; }
.avatar.md { width: 56px; height: 56px; font-size: 20px; }
.advisor-body { flex: 1; min-width: 0; }
.advisor-name { font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.advisor-spec { font-size: var(--fs-xs); color: var(--ink); font-weight: 600; }
.advisor-bio { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.advisor-bio.quote { border-inline-start: 2px solid var(--rule); padding-inline-start: 8px; -webkit-line-clamp: 6; }
.advisor-action { align-self: center; }
.advisor-action.stack { display: grid; gap: 6px; }
.textarea.short { min-height: 90px; }
.row.archived { opacity: .72; }

/* ---------- chat ---------- */
.msgs { flex: 1; overflow-y: auto; background-color: #EEF2FA;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; }
.msgs-inner { max-width: 760px; margin: 0 auto; padding: 12px 10px 16px; display: flex; flex-direction: column; gap: 4px; }
.msg-row { display: flex; justify-content: flex-start; }      /* RTL: theirs on the right */
.msg-row.mine { justify-content: flex-end; }                   /* mine on the left */
.bubble {
  position: relative; max-width: min(78%, 520px); padding: 6px 10px 4px; border-radius: 14px;
  background: #fff; border: 1px solid var(--rule); box-shadow: 0 1px 0 rgba(29,58,138,.05);
  cursor: pointer; overflow-wrap: anywhere;
}
.bubble.theirs { border-start-start-radius: 4px; }
.bubble.mine { background: #DCE6FA; border-color: #C8D6F3; border-start-end-radius: 4px; }
.bubble:focus-visible { outline: 2px solid var(--ink); }
.bubble.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--margin); } 100% { box-shadow: none; } }
.bubble.uploading { opacity: .75; cursor: default; }
.msg-text { white-space: pre-wrap; line-height: 1.85; font-size: 15.5px; }
.msg-text a { color: var(--ink); }
.bubble .atts { margin: 2px 0 4px; }
.bubble .att-img img { max-height: 320px; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.tick { display: inline-flex; }
.tick .icon { width: 16px; height: 16px; stroke-width: 2; }
.tick.read { color: var(--ink); }
.tick.failed { color: var(--danger); }
.deleted { font-style: italic; color: var(--faint); font-size: var(--fs-sm); }
.reply-quote { display: grid; text-align: right; width: 100%; margin: 2px 0 4px; padding: 4px 8px; border: 0; border-inline-start: 3px solid var(--ink);
  background: rgba(29,58,138,.07); border-radius: 6px; cursor: pointer; font-size: var(--fs-xs); line-height: 1.6; }
.reply-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sep { display: flex; justify-content: center; margin: 8px 0; }
.day-sep span { background: rgba(255,255,255,.9); border: 1px solid var(--rule); color: var(--muted); font-size: var(--fs-xs); padding: 1px 12px; border-radius: var(--r-pill); }
.composer-wrap { background: var(--sheet); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.composer-extra .extra { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--rule); color: var(--ink); }
.composer-extra .extra > span { flex: 1; min-width: 0; display: grid; font-size: var(--fs-xs); line-height: 1.6; }
.composer-extra .extra > span span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; max-width: 760px; margin: 0 auto; }
.msg-input { flex: 1; resize: none; min-height: 42px; max-height: 160px; padding: 9px 14px; border: 1px solid #C9D3E6; border-radius: 21px; line-height: 1.6; font-size: var(--fs-md); background: #fff; }
.msg-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.send-btn .icon { transform: scaleX(-1); }          /* paper plane points left in RTL */
.send-btn:hover { background: var(--ink-dark); }
.archived-note { margin: 0; border-radius: 0; }
.search-hit { display: grid; text-align: right; gap: 2px; padding: 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: #fff; cursor: pointer; }
.search-hit span { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit small { color: var(--faint); font-size: var(--fs-xs); }

/* ---------- notifications hint ---------- */
.push-hint { display: flex; align-items: center; gap: 10px; margin: 10px 12px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--ink-soft); color: var(--ink); font-size: var(--fs-sm); }
.push-hint > span { flex: 1; color: var(--text); }

/* ---------- admin panel ---------- */
.admin-tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--sheet); border-bottom: 1px solid var(--rule); padding: 0 8px; scrollbar-width: none; }
.admin-tabs .tab { flex: none; text-decoration: none; padding: 10px 14px; }
.page-inner.wide { max-width: 920px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.stat { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 10px 12px; background: #FAFBFE; }
.stat dt { font-size: var(--fs-xs); color: var(--muted); }
.stat dd { margin: 0; font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1.5; }
.stat small { font-size: 11.5px; color: var(--faint); }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.filters .input { height: 42px; }
.users { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--rule); }
.users li:last-child .user-row { border-bottom: 0; }
.user-row:hover { background: #F6F8FD; }
a.person-name { text-decoration: none; color: inherit; }
.history { margin: 8px 0 0; padding-inline-start: 18px; font-size: var(--fs-sm); color: var(--muted); }
details summary { cursor: pointer; font-size: var(--fs-sm); color: var(--ink); font-weight: 600; margin-top: 8px; }
.perms { display: grid; gap: 6px; margin-bottom: 12px; }
.perm { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.perm input { width: 18px; height: 18px; accent-color: var(--ink); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .field { margin: 0; flex: 1; min-width: 160px; }
.inline-form .field.small { flex: 0 0 110px; min-width: 0; }
.inline-form .btn { height: 48px; }
.adv-list { list-style: none; margin: 0; padding: 0; }
.adv-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.adv-admin .person-name { flex: 1 1 220px; }
.adv-num { font-size: var(--fs-xs); color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--muted); }
.toggle input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ink); }
.input.cap { width: 70px; height: 34px; padding: 0 8px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; }
.log li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: var(--fs-sm); }
.log li b { font-weight: 700; }
.log li span, .log li small { color: var(--muted); font-size: var(--fs-xs); }
.audit-log { display: grid; gap: 8px; }
.audit-msg { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 8px 10px; background: #fff; }
.audit-msg.adv { background: #F3F6FD; }
.audit-msg.del { border-style: dashed; opacity: .8; }
.audit-msg small { display: block; color: var(--faint); font-size: var(--fs-xs); }
.audit-msg p { margin: 4px 0 0; white-space: pre-wrap; }
.back-link { display: inline-block; margin-bottom: 10px; font-size: var(--fs-sm); }
@media (max-width: 600px) { .filters { grid-template-columns: 1fr 1fr; } .filters .input[type=search] { grid-column: 1 / -1; } }

/* ---------- wide screens: list beside the open item ---------- */
@media (min-width: 900px) {
  .shell { flex-direction: row; height: 100vh; }
  .side { flex: none; width: var(--side-w); border-left: 1px solid var(--rule); }
  .main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
  .main.paper-grid .empty { height: 100%; }
  .nav { display: none; }
  .main .bar .back { display: none; }
  .side .profile-link { display: grid; }
  .toast { bottom: 24px; }
  .sheet-backdrop { align-items: center; padding: 16px; }
  .panel { border-radius: var(--r-md); max-height: 86vh; }
  .fab-row { margin-top: -68px; }
  .shell.has-page .side .side-scroll .row[data-route="profile"] { background: var(--ink-soft); }
}
@media (max-width: 899px) {
  .side .profile-link { display: none; }
  /* on phones an open page replaces the list */
  .shell.has-page .side { display: none; }
  /* the open page is exactly one screen tall; its own list (messages, feed, page) scrolls inside it,
     so the message box stays at the bottom and a chat opens at the newest messages */
  .shell.has-page { height: 100vh; height: 100dvh; min-height: 0; }
  .shell.has-page .main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .shell.has-page .nav-in-main { display: flex; }
}
@media (max-width: 380px) {
  .sheet { padding: 22px 42px 18px 14px; }
  .sheet::before { right: 28px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* login details to send (admin) */
.login-info { margin: 12px 0; align-items: center; }
.code-box.small { font-size: 18px; padding: 8px; margin: 0; letter-spacing: 1px; }


/* =====================================================================
   Theme v10 — «دفتر مشق آرام» (a calm study notebook)
   Night-ink header covered in faint study doodles (atom, set square, √, π,
   pencil, open book); the brand and the closing line are written in
   Nastaliq; a highlighter-yellow stroke is the one warm accent.
   ===================================================================== */
@font-face {
  font-family: "Diman Nastaliq";
  src: url("fonts/diman-nastaliq.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
:root {
  --night: #13285E;          /* header ink */
  --night-2: #1B3A86;
  --highlighter: #FFD54A;    /* the one warm accent: a study highlighter */
  --online: #3DDC97;
  --paper: #F4F7FD;
  --nastaliq: "Diman Nastaliq", "Noto Nastaliq Urdu", var(--font);
  --doodles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='168' height='120' viewBox='0 0 168 120'%3E%3Cg fill='none' stroke='white' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' stroke-opacity='.13'%3E %3Cg transform='translate(24 26)'%3E%3Cellipse rx='13' ry='4.6'/%3E%3Cellipse rx='13' ry='4.6' transform='rotate(60)'/%3E%3Cellipse rx='13' ry='4.6' transform='rotate(120)'/%3E%3Ccircle r='1.6' fill='white' fill-opacity='.13'/%3E%3C/g%3E %3Cpath d='M70 36h24L70 12z M75 31h9l-9-9z'/%3E %3Cpath d='M120 22l4-2 5 11 7-21h16'/%3E%3Cpath d='M132 14h0'/%3E %3Cpath d='M14 84h18 M19 84v14 M27 84v12q0 2 3 2'/%3E %3Cpath d='M62 102l26-26 5 5-26 26-7 2z M84 80l5 5'/%3E %3Cpath d='M118 92q10-6 20 0q10-6 20 0v16q-10-6-20 0q-10-6-20 0z M138 92v16'/%3E %3Cpath d='M100 58v8 M96 62h8 M44 58h7 M150 60l5 5 M155 60l-5 5'/%3E %3C/g%3E%3C/svg%3E");
}

/* no pinch / double-tap zoom: the app is laid out for each phone's own width */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
select { font: inherit; }

/* ---------- header: every top bar shares the night-ink theme ---------- */
.bar {
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  color: #fff; border-bottom: 0;
  background-color: var(--night);
  background-image:
    var(--doodles),
    radial-gradient(130% 160% at 100% 0%, rgba(74, 112, 214, .45) 0%, transparent 55%),
    linear-gradient(180deg, var(--night-2), var(--night));
  background-size: 168px 120px, auto, auto;
  box-shadow: 0 2px 10px -4px rgba(19, 40, 94, .45);
}
.bar h2 { color: #fff; }
.bar .bar-sub { color: rgba(255, 255, 255, .72); }
.bar .icon-btn { color: rgba(255, 255, 255, .88); }
.bar .icon-btn:hover, .bar .icon-btn:focus-visible { background: rgba(255, 255, 255, .14); color: #fff; }
.bar :focus-visible { outline-color: var(--highlighter); }
.bar .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }

.bar .brand {
  position: relative; z-index: 0; display: inline-block;
  font-family: var(--nastaliq); font-weight: 400;
  font-size: 26px; line-height: 2.1; height: 100%; color: #fff; letter-spacing: 0;
  padding: 0 6px; margin: 0 2px 0 0; overflow: visible; transform: translateY(-7px);
}
.bar .brand::after {
  /* a highlighter swash under the name, slightly uneven like a real marker */
  content: ""; position: absolute; z-index: -1;
  inset: auto 4px 14px 0; height: 5px; width: auto; margin: 0;
  background: var(--highlighter); opacity: .9;
  border-radius: 6px 2px 7px 3px; transform: rotate(-2deg);
}

/* connection shield beside the name (like the one in Telegram's title bar) */
.conn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px 0 8px; border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .1);
  color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.conn .icon { width: 16px; height: 16px; stroke-width: 2; }
.conn[data-state="ok"] .icon { color: var(--online); }
.conn[data-state="connecting"] .icon { color: var(--highlighter); animation: conn-pulse 1.2s ease-in-out infinite; }
.conn[data-state="offline"] { background: rgba(214, 69, 69, .28); border-color: rgba(255, 160, 160, .45); }
@keyframes conn-pulse { 50% { opacity: .35; } }
.conn-info { display: grid; gap: 12px; }
.conn-info .big { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.conn-info .big .icon { width: 30px; height: 30px; color: var(--ok); }
.conn-info .big.off .icon { color: var(--danger); }

/* ---------- home: the list is a page of the notebook ---------- */
.side { background: var(--paper); }
.side-scroll {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  padding: 12px 12px 20px;
}
.side-scroll .list {
  background: var(--sheet);
  border: 1px solid var(--rule); border-radius: 16px; overflow: hidden;
  box-shadow: 0 10px 24px -18px rgba(19, 40, 94, .45);
}
.side-scroll .list > li:last-child .row { border-bottom: 0; }
.side-scroll .row { min-height: 78px; padding: 12px 14px; }
.side-scroll .row:hover { background: #F7F9FE; }
.side-scroll .pinned-row {
  background: linear-gradient(to left, rgba(255, 213, 74, .18), rgba(255, 213, 74, 0) 70%);
}
.avatar.channel {
  background: var(--night);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--highlighter);
}
.avatar.channel::after { display: none; }
.avatar.channel img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.bar .avatar.channel { box-shadow: 0 0 0 2px rgba(255, 213, 74, .9); }
.push-hint { margin: 0 0 12px; border-radius: 14px; }

/* ---------- footer: the academy's line, in Nastaliq ---------- */
.slogan {
  position: sticky; bottom: 0; z-index: 9;
  display: flex; align-items: center; justify-content: center;
  min-height: calc(54px + env(safe-area-inset-bottom));
  padding: 4px 16px env(safe-area-inset-bottom);
  background: var(--sheet); border-top: 1px solid var(--rule);
  font-family: var(--nastaliq); font-size: 20px; line-height: 1.6; color: var(--night-2);
  white-space: nowrap; overflow: hidden;
}
.slogan span { position: relative; padding-top: 4px; }
.main .slogan { display: none; }
@media (max-width: 899px) { .shell.has-page .main .slogan { display: flex; } }
.boot-mark { font-family: var(--nastaliq); font-weight: 400; font-size: 46px; opacity: .5; }

/* admin: folded "add advisor" and the channel picture row */
.add-adv summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; color: var(--ink); list-style: none; }
.add-adv summary::-webkit-details-marker { display: none; }
.add-adv[open] summary { margin-bottom: 12px; }
.add-adv summary .icon { width: 20px; height: 20px; }
.channel-photo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.channel-photo-row .avatar.lg { width: 76px; height: 76px; font-size: 30px; }
.channel-photo-row .hint { margin: 0; }
.path { display: block; margin-top: 6px; padding: 6px 8px; background: var(--ink-soft); border-radius: 6px; font-size: 12.5px; word-break: break-all; text-align: left; }

/* admin overview: nightly backup state */
.backup-card h3 { display: flex; align-items: center; gap: 8px; }
.backup-card h3 .icon { width: 22px; height: 22px; }
.backup-card.ok h3 .icon { color: var(--ok); }
.backup-card.warn { border-color: #F1D9A8; background: var(--warn-bg); }
.backup-card.warn h3 .icon { color: var(--warn); }
.backup-card.bad { border-color: #F3B8B2; background: var(--danger-bg); }
.backup-card.bad h3 .icon { color: var(--danger); }
.backup-card p { overflow-wrap: anywhere; }


/* =====================================================================
   Opening screen — the academy's own look: night indigo with violet and
   magenta light, the graduation-cap D, name and tagline.
   ===================================================================== */
html { background: #1B1E66; }
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  color: #fff; text-align: center;
  background:
    radial-gradient(70% 45% at 88% 92%, rgba(214, 70, 200, .55), transparent 70%),
    radial-gradient(60% 40% at 8% 6%, rgba(70, 96, 235, .45), transparent 70%),
    linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .06) 46%, transparent 54%),
    linear-gradient(160deg, #1D2170 0%, #1B1E66 45%, #2B1C70 80%, #3E1D79 100%);
  transition: opacity .4s ease, visibility .4s;
}
.splash.out { opacity: 0; visibility: hidden; }
.splash-logo {
  width: 148px; height: auto; margin-bottom: 26px;
  filter: drop-shadow(0 10px 28px rgba(205, 92, 245, .45));
  animation: splash-in .7s cubic-bezier(.2, .8, .2, 1) both;
}
.splash-name {
  font-family: var(--font); font-weight: 800; font-size: 32px; line-height: 1.4;
  letter-spacing: -.3px; text-shadow: 0 2px 18px rgba(0, 0, 0, .25);
  animation: splash-fade .6s .25s ease both;
}
.splash-tag {
  margin-top: 6px; font-family: var(--font); font-weight: 500; font-size: 15.5px;
  color: rgba(255, 255, 255, .82);
  animation: splash-fade .6s .4s ease both;
}
@keyframes splash-in { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes splash-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
body { background: var(--paper); }

/* =====================================================================
   Stage 11: the advisors' group, personal chats between peers, people search
   ===================================================================== */
.avatar.group { background: var(--night); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #9FB3DE; }
.avatar.group .icon { width: 26px; height: 26px; }
.avatar.group img { background: var(--night); }
.bar .avatar.group { box-shadow: 0 0 0 2px rgba(159, 179, 222, .9); }
.avatar.xs { width: 30px; height: 30px; font-size: 13px; flex: none; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }
.side-scroll .group-row { background: linear-gradient(to left, rgba(29, 58, 138, .07), rgba(29, 58, 138, 0) 70%); }
.mini-ic { width: 14px; height: 14px; color: var(--faint); flex: none; }
.badge.quiet { background: #A3ABBA; }
.list-sep { padding: 8px 16px 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--faint); background: #F7F9FE; border-bottom: 1px solid var(--rule); letter-spacing: .2px; }
.chip.tiny { font-size: 11px; padding: 0 7px; line-height: 1.7; }
.notice-li { border-bottom: 1px solid var(--rule); }
.home-notice { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 6px; text-decoration: none; color: inherit; background: #EFF8F2; }
.home-notice > .icon { width: 22px; height: 22px; color: var(--ok); flex: none; }
.home-notice > span { flex: 1; min-width: 0; display: grid; line-height: 1.6; }
.home-notice b { font-size: var(--fs-sm); }
.home-notice small { font-size: var(--fs-xs); color: var(--muted); }
.home-notice .icon-btn { width: 34px; height: 34px; }

/* chat: system lines, sender names, pinned message */
.sys-row { display: flex; justify-content: center; margin: 6px 0; }
.sys-msg { max-width: 86%; text-align: center; font-size: var(--fs-xs); line-height: 1.7; color: #3E4A63;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--rule); border-radius: var(--r-pill); padding: 3px 14px; }
.sender-name { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; line-height: 1.6; margin-bottom: 1px; }
.admin-tag { font-size: 10.5px; font-weight: 700; color: #7A5A00; background: #FFF1B8; border-radius: var(--r-pill); padding: 0 6px; line-height: 1.6; }
.msg-row.with-av { align-items: flex-end; gap: 6px; }
.msg-row.with-av .avatar.xs { margin-bottom: 2px; }
.chat-pin { display: flex; align-items: center; gap: 4px; padding: 0 8px 0 4px; background: var(--sheet); border-bottom: 1px solid var(--rule); box-shadow: 0 4px 10px -8px rgba(19, 40, 94, .4); }
.chat-pin-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: none; text-align: right; cursor: pointer; }
.chat-pin-main > span { display: grid; min-width: 0; border-inline-start: 2px solid var(--margin); padding-inline-start: 8px; line-height: 1.5; }
.chat-pin-main b { font-size: var(--fs-xs); color: var(--margin); }
.chat-pin-main > span span { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.chat-pin .icon-btn { width: 34px; height: 34px; color: var(--faint); }
.bar-title.clickable { cursor: pointer; }
.bar-extra { display: contents; }
.archived-note { align-items: flex-start; }
.lock-ic { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; color: var(--ink); flex: none; box-shadow: 0 0 0 1px var(--rule); }
.lock-ic .icon { width: 22px; height: 22px; }
.lock-ic.sm { width: 34px; height: 34px; }
.lock-ic.sm .icon { width: 18px; height: 18px; }
.lock-note { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-bottom: 14px; background: var(--warn-bg); border-radius: var(--r-md); }
.lock-note b { display: block; font-size: var(--fs-sm); }
.lock-note p { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--muted); line-height: 1.8; }

/* on/off switches */
.switch-row { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row > span:first-child { flex: 1; display: grid; line-height: 1.6; }
.switch-row b { font-size: var(--fs-sm); }
.switch-row small { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.switch-row.big b { font-size: var(--fs-md); }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; border-radius: 13px; background: #C7CEDB; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--ink); }
.switch-row input:checked + .switch::after { transform: translateX(-20px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--ink); outline-offset: 2px; }
.switch-row input:disabled + .switch { opacity: .5; }

/* group info */
.group-head { display: grid; justify-items: center; text-align: center; gap: 4px; }
.group-name { font-size: var(--fs-xl); font-weight: 800; line-height: 1.5; margin-top: 6px; }
.group-meta { font-size: var(--fs-sm); color: var(--muted); }
.group-desc { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--text); max-width: 46ch; }
.row-actions.center { justify-content: center; margin-top: 8px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sec-head h3 { margin: 0; }
.chip.admin-chip { display: inline-flex; align-items: center; gap: 4px; background: #FFF1B8; color: #7A5A00; }
.chip.admin-chip .mini-ic { color: #B8860B; }
.person.member .icon-btn { color: var(--muted); }
.person.silenced .person-name small { color: var(--warn); }
.person.faded { opacity: .62; }

/* people search & requests */
.people-tabs .tab { display: inline-flex; align-items: center; gap: 6px; }
.tab-badge { min-width: 19px; height: 19px; padding: 0 5px; font-size: 11px; }
.search-big { font-size: var(--fs-md); padding: 12px 16px; border-radius: var(--r-pill); margin: 4px 0 8px; }
.sec-title { margin: 18px 0 8px; font-size: var(--fs-sm); color: var(--muted); }
.sec-title:first-child { margin-top: 4px; }
.person-card .advisor-action { display: grid; justify-items: end; }
.person-card .stack { display: grid; gap: 4px; justify-items: end; }
.link.small { font-size: var(--fs-xs); font-weight: 600; }
.link.danger { color: var(--danger); }
.pair-av { display: flex; align-items: center; }
.pair-av .avatar + .avatar { margin-inline-start: -10px; box-shadow: 0 0 0 2px #fff; }
.advisor-name .arrow { color: var(--faint); font-weight: 400; }
.find-row .avatar-empty .icon { width: 22px; height: 22px; }
.advisor.admin-req { flex-direction: column; align-items: stretch; gap: 10px; }
.req-top { display: flex; align-items: center; gap: 12px; }
.req-actions { display: flex; gap: 8px; }
.req-actions .btn { flex: 1; }
.admin-req .advisor-bio.quote { margin: 0; }

/* =====================================================================
   Stage 12 — voice messages, reactions, forward, polls, broadcast, search
   ===================================================================== */
.icon.solid { fill: currentColor; stroke: none; }
.mini-ic { width: 15px; height: 15px; }

/* --- voice player: a pen-drawn waveform on the bubble --- */
.bubble.is-voice { min-width: min(78%, 270px); }
.voice { display: flex; align-items: center; gap: 10px; padding: 4px 0 0; }
.vp-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--ink); color: #fff; box-shadow: 0 2px 6px -2px rgba(29,58,138,.5); }
.vp-btn .icon { width: 20px; height: 20px; }
.voice:not(.playing) .vp-speed { visibility: hidden; }   /* speed shows while playing */
.voice.loading .vp-btn { animation: conn-pulse 1s ease-in-out infinite; }
.vp-mid { flex: 1; min-width: 0; display: grid; gap: 2px; }
.vw-hit { border: 0; background: none; padding: 0; cursor: pointer; display: block; width: 100%; }
.vw { display: flex; align-items: center; gap: 2px; height: 30px; }
.vw i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: #A9B8DA; transition: background .15s; }
.bubble.mine .vw i { background: #9BB0DC; }
.vw i.on { background: var(--ink); }
.vp-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.vp-time { font-variant-numeric: tabular-nums; direction: ltr; }
.vp-speed { border: 1px solid #C9D3E6; background: rgba(255,255,255,.7); color: var(--ink); font-weight: 800; font-size: 11px;
  border-radius: var(--r-pill); padding: 0 7px; line-height: 1.6; cursor: pointer; }

/* --- recorder bar (replaces the composer while recording) --- */
.rec-host { max-width: 760px; margin: 0 auto; padding: 8px 10px; }
.rec-bar { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.rec-cancel { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--margin); animation: rec-pulse 1.1s ease-in-out infinite; flex: none; }
@keyframes rec-pulse { 50% { opacity: .25; transform: scale(.8); } }
.rec-time { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; min-width: 40px; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; overflow: hidden; justify-content: flex-start; }
.rec-wave i { width: 3px; flex: none; border-radius: 2px; background: var(--margin); opacity: .8; }
.rec-hint { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; }
@media (max-width: 380px) { .rec-hint { display: none; } }
.mic-btn { background: var(--sheet); color: var(--ink); border: 1px solid #C9D3E6; }
.mic-btn:hover { background: var(--ink-soft); color: var(--ink); }
.mic-btn .icon { transform: none; }
.bc-rec { padding: 6px 0; }

.bubble.failed { opacity: 1; border-color: #F0C6C1; background: var(--danger-bg); }
.up-failed { display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: var(--fs-sm); }
.up-failed .icon { width: 18px; height: 18px; }

/* --- forwarded / broadcast marks --- */
.fwd-from { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--ink); margin: 2px 0 2px; }
.fwd-from b { font-weight: 800; }
.bc-tag { display: inline-flex; align-items: center; gap: 2px; color: var(--ink); font-weight: 700; }
.bc-tag .icon { width: 13px; height: 13px; }

/* --- reactions --- */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.react { display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 8px; border-radius: var(--r-pill); cursor: pointer;
  border: 1px solid #C9D3E6; background: rgba(255,255,255,.85); font-size: 12.5px; font-weight: 700; color: var(--ink); }
.react .emo { font-size: 15px; line-height: 1; }
.react.mine { background: var(--ink); border-color: var(--ink); color: #fff; }
.react-pick { display: flex; justify-content: space-between; gap: 2px; padding: 4px 2px 6px; border-bottom: 1px solid var(--rule); }
.emo-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; font-size: 24px; cursor: pointer; line-height: 1; transition: transform .12s; }
.emo-btn:hover, .emo-btn:focus-visible { background: var(--ink-soft); transform: scale(1.12); }
.emo-btn.on { background: var(--ink-soft); box-shadow: inset 0 0 0 2px var(--ink); }
.react-big { font-size: 22px; }
.post-reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.post-reacts .reacts { margin: 0; }
.react-add { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: var(--r-pill);
  border: 1px dashed #C9D3E6; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.react-add .icon { width: 16px; height: 16px; }
.react-add:hover { color: var(--ink); border-color: var(--ink); }

/* --- polls --- */
.bubble.is-poll { width: min(86%, 400px); }
.poll { display: grid; gap: 6px; padding: 4px 0 2px; }
.poll-q { display: flex; align-items: flex-start; gap: 6px; font-size: 15.5px; line-height: 1.7; }
.poll-ic { width: 20px; height: 20px; color: var(--margin); flex: none; margin-top: 3px; stroke-width: 2.4; }
.poll-kind { font-size: var(--fs-xs); color: var(--faint); margin-top: -4px; }
.poll-opts { display: grid; gap: 6px; }
.poll-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: right; cursor: pointer;
  border: 1px solid #C9D3E6; border-radius: 10px; background: rgba(255,255,255,.9); font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.poll-opt:hover { border-color: var(--ink); }
.poll-mark { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #9FB3DE; flex: none; }
.poll-mark.sq { border-radius: 5px; }
.poll-opt.on { border-color: var(--ink); background: var(--ink-soft); }
.poll-opt.on .poll-mark { border-color: var(--ink); background: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.poll-res { position: relative; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 10px; border-radius: 10px;
  background: rgba(255,255,255,.75); border: 1px solid var(--rule); overflow: hidden; font-size: var(--fs-sm); }
.poll-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: rgba(29,58,138,.12); border-radius: 0 8px 8px 0; transition: width .4s ease; }
.poll-res.top .poll-fill { background: rgba(29,58,138,.2); }
.poll-res.mine { border-color: #9FB3DE; }
.poll-txt { position: relative; flex: 1; display: flex; align-items: center; gap: 4px; font-weight: 600; }
.poll-ck { width: 16px; height: 16px; color: var(--ink); stroke-width: 2.6; }
.poll-pct { position: relative; font-weight: 800; color: var(--ink); font-size: var(--fs-xs); }
.poll-submit { justify-self: start; }
.poll-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); color: var(--muted); }
.poll-foot .grow { flex: 1; }
.poll.closed .poll-q b::after { content: " 🔒"; font-size: 12px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 700; font-size: var(--fs-xs); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); }
.voters { display: grid; gap: 14px; }
.voters h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: var(--fs-sm); }
.pl-fields { display: grid; gap: 4px; }
.pl-opts { display: grid; gap: 6px; margin-bottom: 6px; }
.pl-opt { display: flex; align-items: center; gap: 4px; }
.pl-opt .input { flex: 1; }
.pl-fields .field.check { padding-top: 6px; }
.poll-box { border: 1px dashed #C9D3E6; border-radius: var(--r-md); padding: 10px 12px; background: #FAFBFF; }
.poll-toggle { padding-top: 4px; }
.poll-toggle label { display: inline-flex; align-items: center; gap: 4px; }
.post .poll { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-md); background: #FAFBFF; }

/* --- pick lists (forward, broadcast) --- */
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-md); background: #fff; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.pick-list li:last-child .pick-row { border-bottom: 0; }
.pick-row.on { background: var(--ink-soft); }
.pick-name { flex: 1; min-width: 0; display: grid; font-weight: 600; font-size: var(--fs-sm); line-height: 1.5; }
.pick-name small { color: var(--faint); font-weight: 400; }
.pick-row input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }

/* --- broadcast page --- */
.bc-row .bc-av { background: #FBF0F0; color: var(--margin); }
.bc-page { display: grid; gap: 18px; }
.bc-card { display: grid; gap: 10px; padding: 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 1px 0 rgba(29,58,138,.05); }
.bc-card h3, .bc-history h3 { margin: 6px 0 0; font-size: var(--fs-md); }
.bc-intro { display: flex; gap: 10px; margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--ink-soft); color: var(--ink-dark); font-size: var(--fs-sm); line-height: 1.8; }
.bc-intro .icon { flex: none; color: var(--margin); }
.segs { display: flex; gap: 0; border: 1px solid #C9D3E6; border-radius: var(--r-pill); padding: 3px; background: #fff; }
.seg { flex: 1; border: 0; background: none; border-radius: var(--r-pill); padding: 7px 10px; font-weight: 700; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
.seg.on { background: var(--ink); color: #fff; }
.bc-who { display: grid; gap: 8px; }
.bc-pick-tools { display: flex; align-items: center; gap: 14px; }
.bc-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.bc-tools .btn { display: inline-flex; align-items: center; gap: 6px; }
.bc-send { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.bc-send .icon { transform: scaleX(-1); }
.bc-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.bc-item { width: 100%; display: grid; gap: 6px; text-align: right; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-md); background: #fff; cursor: pointer; }
.bc-item:hover { border-color: #9FB3DE; }
.bc-item .chip { justify-self: start; display: inline-flex; align-items: center; gap: 2px; }
.bc-prev { font-weight: 600; font-size: var(--fs-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bc-meter { height: 6px; border-radius: 3px; background: var(--ink-soft); overflow: hidden; }
.bc-meter i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.bc-meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }

/* --- app-wide search --- */
.search-bar { gap: 6px; }
.bar-search { flex: 1; min-width: 0; height: 40px; border-radius: var(--r-pill); border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.14);
  color: #fff; padding: 0 16px; font-size: var(--fs-md); }
.bar-search::placeholder { color: rgba(255,255,255,.7); }
.bar-search:focus { outline: none; background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.5); }
.search-page { display: grid; gap: 6px; }
.res-h { margin: 10px 0 2px; font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.res-list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.res-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--rule); background: none;
  text-decoration: none; color: inherit; text-align: right; cursor: pointer; }
.res-list li:last-child .res-row { border-bottom: 0; }
.res-row:hover { background: #F6F8FD; }
.res-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.res-top { display: flex; align-items: center; gap: 8px; }
.res-top b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); }
.res-top time { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; }
.res-snip { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-snip em { font-style: normal; color: var(--text); font-weight: 600; }
mark { background: #FFE58A; color: inherit; border-radius: 3px; padding: 0 1px; }
.search-people { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; border: 1px dashed #C9D3E6; border-radius: var(--r-md);
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--fs-sm); background: #fff; }
.hint.center { text-align: center; margin: 18px 0 4px; }

/* ---------- stage 14: SMS entry choices + guest call-to-action ---------- */
.entry-choices { display: grid; gap: 10px; margin: 4px 0 6px; }
.entry-choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: right;
  padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--r-md);
  background: var(--sheet); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.entry-choice:hover, .entry-choice:focus-visible { border-color: var(--ink); background: var(--ink-soft); }
.entry-choice:disabled { opacity: .6; cursor: wait; }
.entry-emoji { font-size: 28px; line-height: 1; flex: none; }
.entry-text { display: grid; gap: 3px; }
.entry-text b { font-size: var(--fs-md); font-weight: 800; }
.entry-text span { font-size: var(--fs-xs); color: var(--muted); }
.sms-resend { margin: -4px 0 6px; min-height: 20px; }
#f-code { text-align: center; letter-spacing: 10px; font-size: var(--fs-lg); font-weight: 700; }

.guest-cta {
  position: sticky; bottom: 0; z-index: 2;
  display: grid; gap: 10px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--sheet); border-top: 2px solid var(--margin);
  box-shadow: 0 -6px 18px rgba(20, 42, 102, .08);
}
.guest-cta-text { display: grid; gap: 4px; }
.guest-cta-text b { font-size: var(--fs-md); color: var(--ink-dark); }
.guest-cta-text span { font-size: var(--fs-xs); color: var(--muted); line-height: 1.9; }
.guest-cta .btn { width: 100%; text-align: center; text-decoration: none; }
.guest-login { justify-self: center; font-size: var(--fs-xs); }
