/* ============================================================
   ناشناس — Anonymous Messaging · «شبِ نامه‌ها»
   Glass over midnight — aurora atmosphere, frosted panels,
   gradient glow. Dark-first with a frosted-light mode.
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  direction: rtl;
  line-height: 1.75;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

::selection { background: var(--accent-soft-2); color: var(--ink-0); }

* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; }

button, input, textarea { font-family: inherit; }
img, svg { display: block; }
button { -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s); }

/* ── Aurora atmosphere ────────────────────────────────────── */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.aurora i {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--aur-op, 0.5);
  animation: drift var(--aur-dur, 26s) ease-in-out infinite alternate;
}
.aurora i:nth-child(1) {
  width: 55vmax; height: 55vmax;
  top: -25vmax; right: -18vmax;
  background: radial-gradient(circle at 40% 40%, var(--aur-1), transparent 65%);
}
.aurora i:nth-child(2) {
  width: 48vmax; height: 48vmax;
  bottom: -22vmax; left: -16vmax;
  background: radial-gradient(circle at 60% 60%, var(--aur-2), transparent 65%);
  animation-delay: -8s;
}
.aurora i:nth-child(3) {
  width: 34vmax; height: 34vmax;
  top: 32%; left: 18%;
  background: radial-gradient(circle at 50% 50%, var(--aur-3), transparent 65%);
  animation-delay: -16s;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(4vmax, -3vmax, 0) scale(1.12); }
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Glass primitives ─────────────────────────────────────── */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(var(--blur, 22px)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur, 22px)) saturate(160%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  border-radius: var(--r-l);
}
.glass-deep {
  background: var(--glass-2);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(var(--blur, 22px)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur, 22px)) saturate(160%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
  border-radius: var(--r-l);
}

/* ── Logo mark (CSS-masked calligraphy, tinted via currentColor) ── */
.logo-mark {
  display: inline-block;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url('../assets/logo.png') center / contain no-repeat;
  mask: url('../assets/logo.png') center / contain no-repeat;
  pointer-events: none;
}
.lm-xs  { width: 30px; height: 18px; }
.lm-sm  { width: 40px; height: 24px; }
.lm-md  { width: 52px; height: 30px; }
.lm-lg  { width: 74px; height: 44px; }
.lm-xl  { width: 110px; height: 64px; }
.lm-2xl { width: 150px; height: 88px; }
.lm-hero { width: 210px; height: 122px; }

/* gradient text helper */
.grad-text {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Design Tokens · Dark (midnight) ──────────────────────── */
:root {
  --bg: #0a0e17;
  --bg-deep: #070a11;

  --aur-1: rgba(124, 92, 255, 0.55);
  --aur-2: rgba(45, 212, 191, 0.38);
  --aur-3: rgba(244, 114, 182, 0.30);
  --aur-op: 0.55;

  --glass: rgba(148, 163, 205, 0.07);
  --glass-2: rgba(148, 163, 205, 0.12);
  --glass-brd: rgba(255, 255, 255, 0.09);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --glass-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.55);

  --ink-0: #f1f4fc;
  --ink-1: #9aa5c0;
  --ink-2: #5b657f;

  --line-0: rgba(255, 255, 255, 0.06);
  --line-1: rgba(255, 255, 255, 0.12);
  --scroll: rgba(148, 163, 205, 0.25);

  --accent: #8b7cf6;
  --accent-strong: #9d8fff;
  --accent-hi: #7a68f0;
  --accent-2: #2dd4bf;
  --accent-soft: rgba(139, 124, 246, 0.15);
  --accent-soft-2: rgba(139, 124, 246, 0.32);
  --accent-glow: rgba(139, 124, 246, 0.45);
  --on-accent: #ffffff;

  --bubble-out: rgba(139, 124, 246, 0.20);
  --bubble-out-brd: rgba(139, 124, 246, 0.38);
  --bubble-out-ink: #f3f0ff;
  --bubble-in: rgba(148, 163, 205, 0.10);
  --bubble-in-brd: rgba(255, 255, 255, 0.08);
  --bubble-in-ink: #eef1fa;

  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.13);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.13);

  --grad-btn: linear-gradient(135deg, #8b7cf6 0%, #6d5ae6 55%, #2dd4bf 130%);

  --shadow-0: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-1: 0 14px 34px -14px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 30px 70px -24px rgba(0, 0, 0, 0.65);
  --focus-ring: 0 0 0 3px var(--accent-soft);

  --r-s: 8px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --col-w: 720px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  --chat-pattern: radial-gradient(rgba(148, 163, 205, 0.16) 1.2px, transparent 1.2px);
  --chat-pattern-size: 26px;
}

/* ── Design Tokens · Light (frost) ────────────────────────── */
[data-theme="light"] {
  --bg: #eef1f8;
  --bg-deep: #e6eaf4;

  --aur-1: rgba(139, 124, 246, 0.30);
  --aur-2: rgba(45, 212, 191, 0.26);
  --aur-3: rgba(244, 114, 182, 0.20);
  --aur-op: 0.6;

  --glass: rgba(255, 255, 255, 0.55);
  --glass-2: rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(255, 255, 255, 0.85);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 18px 40px -20px rgba(90, 100, 140, 0.35);

  --ink-0: #191d2b;
  --ink-1: #5a637e;
  --ink-2: #9aa2ba;

  --line-0: rgba(25, 29, 43, 0.07);
  --line-1: rgba(25, 29, 43, 0.13);
  --scroll: rgba(90, 100, 140, 0.3);

  --accent: #6d5ae6;
  --accent-strong: #5b48dd;
  --accent-hi: #7e6cf0;
  --accent-2: #0db5a0;
  --accent-soft: rgba(109, 90, 230, 0.13);
  --accent-soft-2: rgba(109, 90, 230, 0.26);
  --accent-glow: rgba(109, 90, 230, 0.4);
  --on-accent: #ffffff;

  --bubble-out: rgba(109, 90, 230, 0.14);
  --bubble-out-brd: rgba(109, 90, 230, 0.28);
  --bubble-out-ink: #241a5e;
  --bubble-in: rgba(255, 255, 255, 0.75);
  --bubble-in-brd: rgba(255, 255, 255, 0.9);
  --bubble-in-ink: #191d2b;

  --green: #0ea771;
  --green-soft: rgba(14, 167, 113, 0.13);
  --red: #e11d48;
  --red-soft: rgba(225, 29, 72, 0.10);
  --amber: #b45309;
  --amber-soft: rgba(180, 83, 9, 0.12);

  --grad-btn: linear-gradient(135deg, #7e6cf0 0%, #6d5ae6 55%, #0db5a0 130%);

  --shadow-0: 0 2px 8px rgba(90, 100, 140, 0.10);
  --shadow-1: 0 14px 34px -16px rgba(90, 100, 140, 0.35);
  --shadow-2: 0 30px 70px -26px rgba(90, 100, 140, 0.45);

  --chat-pattern: radial-gradient(rgba(109, 90, 230, 0.14) 1.2px, transparent 1.2px);
}

/* ── Motion ───────────────────────────────────────────────── */
@keyframes rise   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop    { from { opacity: 0; transform: scale(0.94) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes pulse  { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 24px -4px var(--accent-glow); } 50% { box-shadow: 0 0 44px 2px var(--accent-glow); } }
@keyframes toastIn  { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(16px) scale(0.96); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Avatar (gradient medallion + white logo) ─────────────── */
.avatar {
  --av1: #8b7cf6;
  --av2: #2dd4bf;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--av1), var(--av2));
  color: #ffffff;
  position: relative;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px -8px var(--av1);
}
.avatar .logo-mark { width: 64%; height: 38%; }
.avatar.sm { width: 42px; height: 42px; }
.avatar.lg { width: 72px; height: 72px; }

/* ── Buttons & inputs ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-0);
  background: var(--glass-2);
  transition: transform 0.16s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--grad-btn);
  color: var(--on-accent);
  box-shadow: 0 12px 28px -10px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 34px -10px var(--accent-glow); }

.btn-ghost { background: var(--glass); border-color: var(--glass-brd); color: var(--ink-1); }
.btn-ghost:hover:not(:disabled) { color: var(--accent-strong); border-color: var(--accent-soft-2); background: var(--accent-soft); }

.icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-1);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.16s var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--glass-2); color: var(--ink-0); }
.icon-btn:active:not(:disabled) { transform: scale(0.88); }
.icon-btn svg { width: 21px; height: 21px; }

.field {
  width: 100%;
  padding: 13px 18px;
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-m);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink-0);
  font-size: 15px;
  outline: none;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.field::placeholder { color: var(--ink-2); }
.field:focus { border-color: var(--accent-soft-2); box-shadow: var(--focus-ring); }

/* status chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chip-pending { color: var(--amber); background: var(--amber-soft); border: 1px solid rgba(251, 191, 36, 0.25); }
.chip-pending::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 2s ease infinite; }
.chip-answered { color: var(--green); background: var(--green-soft); border: 1px solid rgba(52, 211, 153, 0.25); }
.chip-answered::before { content: '✓'; font-size: 10px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--glass) 25%, var(--glass-2) 50%, var(--glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-s);
}

/* ── Top bar (floating glass) ─────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: calc(var(--sat) + 10px) var(--space-3) 8px;
  flex-shrink: 0;
}
.topbar-in {
  max-width: var(--col-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 10px;
  --blur: 26px;
}
.brand { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--grad-btn);
  color: #ffffff;
  box-shadow: 0 8px 18px -6px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  animation: glowPulse 4.5s ease-in-out infinite;
}
.brand-logo .logo-mark { width: 62%; height: 36%; }
.brand-name { font-size: 17px; font-weight: 900; white-space: nowrap; letter-spacing: -0.01em; }
.brand-status { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); transition: background 0.25s var(--ease), box-shadow 0.25s var(--ease); }
.dot.offline { background: var(--red); box-shadow: 0 0 10px var(--red); animation: pulse 2s ease infinite; }
.status-text { font-size: 11px; color: var(--ink-2); }

/* search */
.search-wrap { max-width: var(--col-w); margin: 6px auto 0; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  --blur: 20px;
  padding: 10px 18px;
  transition: box-shadow 0.2s var(--ease);
}
.search-bar:focus-within { box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi), 0 0 0 2px var(--accent-soft-2); }
.search-bar svg { width: 17px; height: 17px; color: var(--ink-2); flex-shrink: 0; }
.search-bar input {
  flex: 1; min-width: 0;
  border: none; background: transparent; outline: none;
  color: var(--ink-0); font-family: inherit; font-size: 13.5px;
}
.search-bar input::placeholder { color: var(--ink-2); }

/* offline banner */
.offline-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: var(--col-w);
  width: calc(100% - 24px);
  margin: 8px auto 0;
  padding: 8px var(--space-4);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid rgba(251, 113, 133, 0.3);
  border-radius: var(--r-pill);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-shrink: 0;
  animation: fade 0.3s var(--ease) both;
}
.offline-bar.visible { display: flex; }
.offline-bar svg { width: 15px; height: 15px; }

/* chat identity in header */
.chat-id { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.chat-meta { display: flex; flex-direction: column; min-width: 0; }
.chat-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub .chip { font-size: 10px; padding: 2px 9px; }

/* ── Splash ───────────────────────────────────────────────── */
.splash-screen {
  flex: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  padding: var(--space-5);
}
.splash-logo {
  color: #ffffff;
  animation: breathe 4.5s ease-in-out infinite;
  filter: drop-shadow(0 0 26px var(--accent-glow)) drop-shadow(0 0 60px var(--accent-soft));
}
.splash-name {
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.015em;
  animation: rise 0.5s var(--ease) 0.05s both;
}
.splash-tag { font-size: 13.5px; color: var(--ink-1); animation: rise 0.5s var(--ease) 0.12s both; }
.splash-dots { display: flex; gap: 8px; margin-top: var(--space-2); animation: fade 0.5s var(--ease) 0.25s both; }
.splash-dots span { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); animation: pulse 1.3s ease infinite; }
.splash-dots span:nth-child(2) { animation-delay: 0.16s; }
.splash-dots span:nth-child(3) { animation-delay: 0.32s; }

/* ── Dev login (only without Eitaa) ───────────────────────── */
.dev-login { flex: 1; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.dev-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-7) var(--space-6);
  --blur: 30px;
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pop 0.4s var(--ease) both;
}
.dev-seal {
  width: 112px; height: 112px;
  border-radius: 50%;
  background: var(--grad-btn);
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-5);
  animation: breathe 4.6s ease-in-out infinite, glowPulse 4.5s ease-in-out infinite;
}
.dev-seal .logo-mark { width: 64%; height: 38%; }
.dev-title { font-size: 20px; font-weight: 900; margin-bottom: var(--space-2); }
.dev-desc { font-size: 13px; color: var(--ink-1); margin-bottom: var(--space-5); line-height: 2; }
.dev-note { font-size: 11.5px; color: var(--ink-2); margin-top: var(--space-4); }

/* ── Home page ────────────────────────────────────────────── */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--col-w);
  margin: 0 auto;
  padding: 4px var(--space-3) var(--space-6);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* hero composer — the heart of the product */
.compose-hero {
  --blur: 28px;
  margin-top: var(--space-3);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  animation: rise 0.45s var(--ease) both;
}
.compose-hero::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-soft-2), transparent);
  pointer-events: none;
}
.compose-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  padding: 4px 13px;
  border-radius: var(--r-pill);
  margin-bottom: var(--space-3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.compose-kicker svg { width: 13px; height: 13px; }
.compose-title { font-size: 17px; font-weight: 900; letter-spacing: -0.01em; margin-bottom: 4px; }
.compose-cap { font-size: 11.5px; color: var(--ink-2); margin-bottom: var(--space-4); }

.compose-line {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  background: var(--glass-2);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  border-radius: var(--r-l);
  padding: 10px 10px 10px 16px;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.compose-line:focus-within { border-color: var(--accent-soft-2); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 3px var(--accent-soft); }
.compose-line textarea {
  flex: 1;
  min-height: 44px;
  max-height: 150px;
  border: none;
  background: transparent;
  color: var(--ink-0);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.85;
  resize: none;
  outline: none;
  padding: 9px 4px;
}
.compose-line textarea::placeholder { color: var(--ink-2); }
.compose-hint { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 11px; color: var(--ink-2); padding-top: var(--space-3); }
.compose-hint svg { width: 13px; height: 13px; }

.send-circle {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--grad-btn);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 26px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease), filter 0.2s var(--ease);
}
.send-circle svg { width: 22px; height: 22px; margin-left: -2px; }
.send-circle:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); box-shadow: 0 16px 34px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.send-circle:active:not(:disabled) { transform: scale(0.9); }
.send-circle:disabled { opacity: 0.35; cursor: default; box-shadow: none; filter: grayscale(0.6); }
.send-circle.is-sending { pointer-events: none; }

/* list head */
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-2) var(--space-3);
}
.list-title { font-size: 13px; font-weight: 800; color: var(--ink-1); letter-spacing: 0.01em; }
.list-count { font-size: 12px; color: var(--ink-2); }

/* ── Conversation list (glass rows) ───────────────────────── */
.conv-list { flex: 1; display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--space-3); }
.conv {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  text-align: right;
  cursor: pointer;
  border-radius: var(--r-l);
  animation: rise 0.3s var(--ease) both;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.conv:hover {
  background: var(--glass);
  border-color: var(--glass-brd);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow);
}
.conv:active { transform: scale(0.99); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.conv-name { font-size: 14.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.conv-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.conv-preview {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-state { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; }
.conv-state svg { width: 15px; height: 15px; }
.conv-state .st-answered { color: var(--green); filter: drop-shadow(0 0 5px var(--green)); }
.conv-state .st-pending { color: var(--ink-2); }

/* skeletons */
.skel-conv { display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; }
.skel-av { width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.skel-line { height: 12px; border-radius: 6px; }
.skel-line:first-child { width: 38%; }
.skel-line:nth-child(2) { width: 76%; }

/* ── Empty / error states ─────────────────────────────────── */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-8) var(--space-5); animation: fade 0.35s var(--ease) both; }
.empty-seal {
  width: 112px; height: 112px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-5);
  animation: breathe 4.8s ease-in-out infinite, glowPulse 5s ease-in-out infinite;
}
.empty-seal .logo-mark { width: 64%; height: 38%; }
.empty-title { font-size: 16px; font-weight: 800; margin-bottom: var(--space-1); }
.empty-desc { font-size: 13px; color: var(--ink-1); max-width: 320px; line-height: 2; margin-bottom: var(--space-4); }

/* ── Chat shell ───────────────────────────────────────────── */
#app.chat-mode { height: 100dvh; min-height: 0; overflow: hidden; }
.chat-page {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: var(--col-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4) var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  background-color: transparent;
  background-image: var(--chat-pattern);
  background-size: var(--chat-pattern-size) var(--chat-pattern-size);
}

.day { display: flex; justify-content: center; padding: var(--space-2) 0 var(--space-3); }
.day span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-1);
  background: var(--glass-2);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 4px 16px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-0);
}

/* bubbles — frosted glass, RTL: own (user) on the left */
.msg { display: flex; flex-direction: column; max-width: 86%; animation: bubbleIn 0.26s var(--ease) both; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-admin { align-self: flex-start; align-items: flex-start; }
.msg.first, .msg.single { margin-top: var(--space-2); }

.bubble {
  position: relative;
  padding: 10px 15px;
  font-size: 14.5px;
  line-height: 1.85;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  text-align: start;
  min-width: 76px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-0), inset 0 1px 0 var(--glass-hi);
}
.bubble .b-text { display: inline; }
.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  float: left;
  margin: 10px 4px -2px 12px;
  font-size: 10.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.msg-meta svg { width: 14px; height: 14px; }

/* outgoing (user) */
.msg-user .bubble {
  background: var(--bubble-out);
  border: 1px solid var(--bubble-out-brd);
  color: var(--bubble-out-ink);
  border-radius: 18px 18px 18px 6px;
}
.msg-user.single .bubble,
.msg-user.last .bubble { border-bottom-left-radius: 6px; }
.msg-user.first .bubble { border-top-left-radius: 6px; }
.msg-user .msg-meta { color: var(--bubble-out-ink); opacity: 0.65; }

/* incoming (admin) */
.msg-admin .bubble {
  background: var(--bubble-in);
  border: 1px solid var(--bubble-in-brd);
  color: var(--bubble-in-ink);
  border-radius: 18px 18px 6px 18px;
}
.msg-admin.single .bubble,
.msg-admin.last .bubble { border-bottom-right-radius: 6px; }
.msg-admin.first .bubble { border-top-right-radius: 6px; }
.msg-admin .msg-meta { color: var(--ink-2); }

/* chat empty */
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-8) var(--space-5); text-align: center; }
.chat-empty-seal {
  width: 108px; height: 108px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-4);
  animation: breathe 4.8s ease-in-out infinite, glowPulse 5s ease-in-out infinite;
}
.chat-empty-seal .logo-mark { width: 64%; height: 38%; }
.chat-empty-title { font-size: 16px; font-weight: 800; }
.chat-empty-desc { font-size: 12.5px; color: var(--ink-1); max-width: 260px; line-height: 2; }

/* chat composer */
.chat-composer {
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  padding: var(--space-2) var(--space-3) calc(var(--space-3) + var(--sab));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

/* skeletons in chat */
.skel-msgs { flex: 1; padding: var(--space-4); display: flex; flex-direction: column; gap: 12px; }
.skel-msg { height: 54px; width: 64%; border-radius: var(--r-l); }
.skel-msg:nth-child(even) { align-self: flex-end; width: 46%; }

/* ── Toast (glass snackbar) ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--sab) + 22px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
  color: var(--ink-0);
  background: var(--glass-2);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi);
  animation: toastIn 0.3s var(--ease) both;
  max-width: min(92vw, 420px);
}
.toast.hiding { animation: toastOut 0.26s var(--ease) both; }
.toast-success::before { content: '✓'; color: var(--green); flex-shrink: 0; font-size: 12px; font-weight: 800; }
.toast-error::before { content: '!'; color: var(--red); flex-shrink: 0; font-size: 13px; font-weight: 800; }
.toast-info::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex-shrink: 0; }

/* ── Utilities ────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 640px) {
  :root { --col-w: 680px; }
  .msg { max-width: 72%; }
}
@media (min-width: 1024px) {
  :root { --col-w: 760px; }
  .msg { max-width: 64%; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .chat-empty-seal { width: 64px; height: 64px; }
}
@media (max-width: 380px) {
  .msg { max-width: 90%; }
  .avatar { width: 48px; height: 48px; }
}
