:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  --bg: #f2f2f7;
  --bg-soft: #ffffff;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --bg-input: #ffffff;
  --text: #111114;
  --text-2: #6c6c74;
  --text-3: #9b9ba3;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.2);
  --blue: #0a7cff;
  --blue-2: #0066e6;
  --bubble-in: #ffffff;
  --bubble-out: linear-gradient(140deg, #1b93ff 0%, #0a6cff 100%);
  --bubble-out-text: #ffffff;
  --shadow-sm: 0 2px 10px rgba(20, 24, 40, 0.05);
  --shadow-md: 0 12px 40px rgba(20, 24, 40, 0.12);
  --shadow-lg: 0 28px 80px rgba(20, 24, 40, 0.22);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-soft: #1c1c1e;
    --bg-elevated: rgba(28, 28, 30, 0.82);
    --bg-input: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a8;
    --text-3: #727279;
    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.18);
    --bubble-in: #26262a;
    --bubble-out: linear-gradient(140deg, #168cff 0%, #0067ff 100%);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 14px 48px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
svg { display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(10, 124, 255, 0.25); }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  height: var(--app-h);
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 820px) and (min-height: 720px) {
  body {
    background:
      radial-gradient(900px 600px at 8% 8%, rgba(10, 124, 255, 0.12), transparent 60%),
      radial-gradient(800px 600px at 92% 92%, rgba(130, 90, 255, 0.12), transparent 62%),
      #ececf2;
  }
  @media (prefers-color-scheme: dark) {
    body { background: radial-gradient(900px 600px at 8% 8%, rgba(10, 124, 255, 0.14), transparent 60%), radial-gradient(800px 600px at 92% 92%, rgba(130, 90, 255, 0.12), transparent 62%), #09090b; }
  }
  .app {
    height: min(920px, calc(var(--app-h) - 40px));
    margin-top: 20px;
    border-radius: 30px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
  }
}

.offline-bar {
  position: absolute;
  z-index: 90;
  top: calc(var(--safe-top) + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 15px;
  border-radius: 999px;
  background: #ff9f0a;
  color: #1b1200;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---------- header ---------- */
.chat-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 9px) 14px 9px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -1px;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.32), transparent 45%),
    linear-gradient(145deg, #3ca4ff, #0064f0 58%, #5b4dff);
  box-shadow: 0 4px 14px rgba(0, 100, 240, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.brand-avatar span { transform: translateY(-0.5px); }
.brand-avatar img { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; }
.presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b6b6bd;
  border: 2.5px solid var(--bg-soft);
}
.presence.is-online { background: #30d158; }
.presence.is-online::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(48, 209, 88, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text p {
  margin: 1px 0 0;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  transition: background 0.18s ease, transform 0.18s ease;
}
.icon-btn:hover { background: rgba(127, 127, 140, 0.12); }
.icon-btn:active { transform: scale(0.92); background: rgba(127, 127, 140, 0.18); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }
.notify-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff453a;
  border: 2px solid var(--bg-soft);
}

/* ---------- chat ---------- */
.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 18px;
  scrollbar-width: thin;
}
.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.chat-inner { display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.day-chip {
  align-self: center;
  margin: 6px 0 15px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.12);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.1px;
}

.message-list { display: flex; flex-direction: column; gap: 3px; }
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-top: 7px;
  animation: messageIn 0.28s cubic-bezier(0.22, 0.9, 0.28, 1);
}
.msg-row.grouped { margin-top: 2px; }
.msg-row.out { justify-content: flex-end; }
.msg-row.in { justify-content: flex-start; }
.msg-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  background: linear-gradient(145deg, #3ca4ff, #0064f0 60%, #5b4dff);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2px;
}
.msg-row.grouped .msg-avatar { visibility: hidden; }
.msg-avatar img { width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: cover; }

.bubble {
  position: relative;
  max-width: min(78%, 520px);
  padding: 9px 13px 7px;
  border-radius: 19px;
  background: var(--bubble-in);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.42;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--line);
}
.msg-row.out .bubble {
  color: var(--bubble-out-text);
  background: var(--bubble-out);
  border: 0;
  border-bottom-right-radius: 7px;
  box-shadow: 0 5px 18px rgba(0, 100, 240, 0.22);
}
.msg-row.in .bubble { border-bottom-left-radius: 7px; }
.msg-row.grouped.in .bubble { border-bottom-left-radius: 7px; }
.msg-row.grouped.out .bubble { border-bottom-right-radius: 7px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: break-word; }
.bubble-text p, .bubble-text ul, .bubble-text ol, .bubble-text blockquote, .bubble-text pre { margin: 0 0 6px; }
.bubble-text > :last-child { margin-bottom: 0; }
.bubble-text ul, .bubble-text ol { padding-left: 20px; }
.bubble-text li { margin: 2px 0; }
.bubble-text blockquote { padding-left: 9px; border-left: 2px solid currentColor; opacity: 0.82; }
.bubble-text code { padding: 1px 5px; border-radius: 5px; background: rgba(120, 120, 128, 0.16); font-size: 0.92em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.bubble-text pre { padding: 8px 10px; border-radius: 9px; background: rgba(120, 120, 128, 0.14); overflow-x: auto; }
.bubble-text pre code { padding: 0; background: none; }
.bubble-text a { word-break: break-word; }
.bubble-text a.md-link { color: var(--blue); text-decoration: none; border-bottom: 1px solid rgba(10, 124, 255, 0.35); }
.bubble-text a.md-url {
  display: inline-block;
  max-width: 100%;
  padding: 1px 7px;
  margin: 1px 0;
  border-radius: 7px;
  background: rgba(10, 124, 255, 0.10);
  color: var(--blue);
  text-decoration: none;
  font-size: 0.94em;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.bubble-text .md-h { font-weight: 650; }
.bubble-text strong, .bubble-text b { font-weight: 680; }
.bubble-text + .bubble-foot { margin-top: 3px; }
.bubble-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1;
  user-select: none;
}
.msg-row.out .bubble-foot { color: rgba(255, 255, 255, 0.68); }
.msg-status { font-size: 10px; }
.bubble.media-only { padding: 4px; overflow: hidden; }
.bubble.media-only .bubble-foot { padding: 0 6px 3px; }
.bubble.no-text .bubble-foot { position: absolute; right: 9px; bottom: 7px; padding: 2px 5px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); color: rgba(255, 255, 255, 0.95); }

.msg-system .bubble { border-bottom-left-radius: 19px; }
.system-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.media-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 340px;
  min-width: 120px;
  border-radius: 15px;
  object-fit: cover;
  background: rgba(120, 120, 128, 0.14);
  cursor: zoom-in;
}
.media-video {
  display: block;
  width: min(300px, 64vw);
  max-height: 380px;
  border-radius: 15px;
  background: #000;
}
.media-video.is-sticker {
  width: min(190px, 46vw);
  max-height: 190px;
  background: transparent;
  object-fit: contain;
  cursor: zoom-in;
}
.media-audio { width: min(270px, 64vw); height: 38px; margin: 4px 0 2px; }
.audio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 238px;
  max-width: 310px;
  padding: 8px 9px;
  border: 0.5px solid var(--line);
  border-radius: 14px;
  background: rgba(120, 120, 128, 0.065);
}
.audio-play {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(10, 124, 255, 0.22);
}
.audio-play:active { transform: scale(0.93); }
.audio-main { flex: 1; min-width: 0; }
.audio-name {
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.audio-track {
  height: 4px;
  margin: 7px 0 4px;
  border-radius: 99px;
  background: rgba(120, 120, 128, 0.18);
  cursor: pointer;
}
.audio-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.12s linear;
}
.audio-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.audio-download {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(10, 124, 255, 0.1);
  color: var(--blue);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.audio-el { display: none; }
.bubble.audio-bubble.no-text .bubble-foot {
  position: static;
  justify-content: flex-end;
  padding: 4px 2px 0;
  background: transparent;
  color: var(--text-3);
}
.msg-row.out .bubble.audio-bubble.no-text .bubble-foot { color: rgba(255, 255, 255, 0.7); }
.msg-row.out .audio-card { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.22); }
.msg-row.out .audio-play { background: #fff; color: var(--blue); box-shadow: none; }
.msg-row.out .audio-name { color: #fff; }
.msg-row.out .audio-meta { color: rgba(255, 255, 255, 0.72); }
.msg-row.out .audio-track { background: rgba(255, 255, 255, 0.28); }
.msg-row.out .audio-track i { background: #fff; }
.msg-row.out .audio-download { background: rgba(255, 255, 255, 0.2); color: #fff; }
.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 232px;
  max-width: 320px;
  padding: 8px 9px;
  border: 0.5px solid var(--line);
  border-radius: 14px;
  background: rgba(120, 120, 128, 0.065);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.file-card:active { transform: scale(0.985); background: rgba(120, 120, 128, 0.11); }
.file-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(160deg, #eef5ff, #dcecff);
  color: #0a6cff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
}
@media (prefers-color-scheme: dark) { .file-icon { background: linear-gradient(160deg, #1d3550, #14263a); color: #69b1ff; } }
.file-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.file-info strong { display: block; color: var(--text); font-size: 13px; font-weight: 650; line-height: 1.3; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info span { color: var(--text-2); font-size: 11px; }
.file-download {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(10, 124, 255, 0.1);
  color: var(--blue);
  font-size: 16px;
  font-weight: 700;
}
.msg-row.out .file-card { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.22); }
.msg-row.out .file-card:active { background: rgba(255, 255, 255, 0.22); }
.msg-row.out .file-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }
.msg-row.out .file-info strong { color: #fff; }
.msg-row.out .file-info span { color: rgba(255, 255, 255, 0.72); }
.msg-row.out .file-download { background: rgba(255, 255, 255, 0.2); color: #fff; }

.chat-loading { display: flex; flex-direction: column; gap: 14px; padding: 10px 2px 20px; }
.skeleton-row { display: flex; gap: 8px; align-items: flex-end; }
.skeleton-row.right { justify-content: flex-end; }
.skeleton { display: block; background: linear-gradient(90deg, rgba(120,120,128,0.08), rgba(120,120,128,0.16), rgba(120,120,128,0.08)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 16px; }
.avatar-skeleton { width: 26px; height: 26px; border-radius: 50%; }
.bubble-skeleton { width: 58%; height: 46px; border-radius: 18px; }
.bubble-skeleton.short { width: 36%; }

.chat-empty { text-align: center; padding: 36px 0 26px; color: var(--text-2); }
.empty-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 22px;
  color: #fff;
  font-size: 27px;
  font-weight: 650;
  background: linear-gradient(145deg, #3ca4ff, #0064f0 58%, #5b4dff);
  box-shadow: 0 12px 28px rgba(0, 100, 240, 0.24);
}
.chat-empty p { margin: 0; font-size: 13.5px; }

.jump-latest {
  position: absolute;
  z-index: 15;
  right: 50%;
  bottom: calc(138px + var(--safe-bottom));
  transform: translateX(50%);
  border: 0.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: floatIn 0.26s ease;
}
.jump-latest span { display: inline-block; margin-left: 2px; }

/* ---------- composer ---------- */
.composer-wrap {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: 6px 12px 0;
  background: linear-gradient(to bottom, rgba(242, 242, 247, 0.65), var(--bg) 24%);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid transparent;
}
@media (prefers-color-scheme: dark) { .composer-wrap { background: linear-gradient(to bottom, rgba(0,0,0,0.55), var(--bg) 24%); } }
.safe-bottom { height: calc(8px + var(--safe-bottom)); }

.quick-bar {
  display: flex;
  gap: 7px;
  padding: 3px 1px 9px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-bar::-webkit-scrollbar { display: none; }
.quick-chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border: 0.5px solid rgba(10, 124, 255, 0.26);
  border-radius: 999px;
  background: rgba(10, 124, 255, 0.075);
  color: var(--blue);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
}
.quick-chip:active { transform: scale(0.95); background: rgba(10, 124, 255, 0.16); }
.quick-chip[disabled] { opacity: 0.5; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 7px 6px 6px;
  background: var(--bg-input);
  border: 0.5px solid var(--line);
  border-radius: 23px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.composer:focus-within { border-color: rgba(10, 124, 255, 0.42); box-shadow: 0 4px 18px rgba(10, 124, 255, 0.12); }
.plus-btn, .send-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}
.plus-btn { background: rgba(120, 120, 128, 0.12); color: var(--text-2); }
.plus-btn:active { transform: scale(0.9); }
.plus-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#messageInput {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 118px;
  padding: 7px 0 6px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.36;
  scrollbar-width: none;
}
#messageInput::-webkit-scrollbar { display: none; }
#messageInput::placeholder { color: var(--text-3); }
.send-btn { background: var(--blue); color: #fff; opacity: 1; }
.send-btn:disabled { background: rgba(120, 120, 128, 0.16); color: var(--text-3); }
.send-btn:not(:disabled):active { transform: scale(0.9); }
.send-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.send-btn.is-sending svg { display: none; }
.send-btn.is-sending::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 2px 9px;
  padding: 8px;
  border-radius: 15px;
  background: var(--bg-soft);
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow-sm);
  animation: floatIn 0.2s ease;
}
.attach-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: rgba(120, 120, 128, 0.12) center/cover no-repeat;
  display: grid;
  place-items: center;
  font-size: 20px;
  overflow: hidden;
}
.attach-thumb img, .attach-thumb video { width: 100%; height: 100%; object-fit: cover; }
.attach-meta { min-width: 0; flex: 1; }
.attach-meta strong { display: block; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attach-meta span { color: var(--text-2); font-size: 11.5px; }
.attach-remove {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 0; border-radius: 50%;
  background: rgba(120, 120, 128, 0.14);
  color: var(--text-2);
  font-size: 19px;
  line-height: 1;
}
.upload-progress {
  margin: 1px 2px 9px;
  padding: 10px 13px;
  border-radius: 15px;
  background: var(--bg-soft);
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.progress-top { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); font-size: 12px; }
.progress-track { height: 5px; margin: 7px 0 6px; border-radius: 99px; background: rgba(120, 120, 128, 0.16); overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #34a4ff, #0a6cff); transition: width 0.18s ease; }
.link-btn { padding: 0; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 550; }

/* ---------- modal / sheets ---------- */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.modal-card {
  position: absolute;
  z-index: 60;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100% - 40px));
  padding: 28px 22px 20px;
  transform: translate(-50%, -50%);
  border: 0.5px solid var(--line);
  border-radius: 28px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn 0.3s cubic-bezier(0.22, 1.05, 0.35, 1);
}
.modal-close {
  position: absolute;
  top: 12px; right: 13px;
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: rgba(120, 120, 128, 0.13);
  color: var(--text-2);
  font-size: 18px; line-height: 1;
}
.bell-illustration {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(10, 124, 255, 0.16), rgba(110, 80, 255, 0.14));
}
.bell-illustration svg { width: 46px; height: 46px; fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.bell-illustration .bell-badge { fill: #ff453a; stroke: var(--bg-soft); stroke-width: 2; }
.modal-card h2 { margin: 0 0 7px; font-size: 20px; font-weight: 680; letter-spacing: -0.4px; }
.modal-desc { margin: 0 0 15px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.notify-points { list-style: none; margin: 0 0 18px; padding: 0; text-align: left; border: 0.5px solid var(--line); border-radius: 15px; overflow: hidden; }
.notify-points li { display: flex; align-items: center; gap: 9px; padding: 10px 13px; color: var(--text-2); font-size: 12.5px; border-top: 0.5px solid var(--line); background: rgba(120, 120, 128, 0.045); }
.notify-points li:first-child { border-top: 0; }
.notify-points li span { width: 18px; text-align: center; }
.primary-btn, .ghost-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.16s ease, background 0.16s ease;
}
.primary-btn { background: var(--blue); color: #fff; box-shadow: 0 8px 22px rgba(10, 124, 255, 0.26); }
.primary-btn:active { transform: scale(0.98); background: var(--blue-2); }
.ghost-btn { margin-top: 6px; background: transparent; color: var(--text-2); font-weight: 500; }
.fine-print { margin: 13px 0 0; color: var(--text-3); font-size: 10.5px; line-height: 1.45; }

.action-sheet {
  position: absolute;
  z-index: 60;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--safe-bottom));
  animation: sheetIn 0.32s cubic-bezier(0.22, 1.02, 0.36, 1);
}
.sheet-group {
  overflow: hidden;
  border: 0.5px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-lg);
  margin-bottom: 8px;
}
.sheet-title { margin: 0 8px 7px; color: var(--text-2); font-size: 12px; font-weight: 550; text-align: center; }
.sheet-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 15px 17px;
  border: 0;
  border-top: 0.5px solid var(--line);
  background: transparent;
  font-size: 16px;
  text-align: left;
}
.sheet-item:first-child { border-top: 0; }
.sheet-item:active { background: rgba(120, 120, 128, 0.1); }
.sheet-item > span:first-child { width: 23px; text-align: center; font-size: 17px; }
.sheet-item .grow { flex: 1; }
.sheet-item .check { color: var(--text-2); font-size: 14px; }
.sheet-cancel {
  display: block;
  width: 100%;
  padding: 15px;
  border: 0.5px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}
.attach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; padding: 6px; background: var(--line); }
.attach-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 18px 8px;
  border: 0;
  border-radius: 13px;
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 550;
}
.attach-option:active { background: rgba(120, 120, 128, 0.12); }
.attach-ico { font-size: 25px; }
.install-help { padding: 14px 18px 18px; border: 0.5px solid var(--line); border-radius: 18px; background: var(--bg-elevated); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); box-shadow: var(--shadow-lg); margin-bottom: 8px; }
.install-help p { margin: 0 0 11px; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.install-help p:last-child { margin-bottom: 0; }
.install-help b { color: var(--text); }

/* ---------- lightbox / toast ---------- */
.lightbox {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.18s ease;
}
.lightbox img { max-width: 100%; max-height: 88%; border-radius: 12px; object-fit: contain; }
.lightbox video { max-width: 100%; max-height: 88%; border-radius: 12px; background: #000; }
.lightbox-close {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: 14px;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}
.toast {
  position: absolute;
  z-index: 120;
  left: 50%;
  bottom: calc(128px + var(--safe-bottom));
  max-width: calc(100% - 48px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.22s ease;
}
@media (prefers-color-scheme: light) { .toast { background: rgba(30, 30, 34, 0.9); } }

.in-app-banner {
  position: absolute;
  z-index: 85;
  top: calc(var(--safe-top) + 58px);
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 17px;
  background: rgba(30, 30, 34, 0.92);
  color: #fff;
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow-lg);
  animation: bannerIn 0.3s cubic-bezier(0.22, 1.03, 0.32, 1);
}
.in-app-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: linear-gradient(145deg, #3ca4ff, #0064f0 58%, #5b4dff);
  font-size: 15px;
  font-weight: 650;
}
.in-app-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.in-app-copy strong { font-size: 12.5px; font-weight: 650; }
.in-app-copy span { margin-top: 2px; color: rgba(255, 255, 255, 0.7); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-app-close { width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff; font-size: 16px; line-height: 1; }
.blocked-screen {
  position: absolute;
  z-index: 110;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  background: var(--bg);
}
.blocked-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 21px;
  background: rgba(255, 69, 58, 0.1);
  color: #ff453a;
  font-size: 28px;
  font-weight: 700;
}
.blocked-screen h2 { margin: 0 0 8px; font-size: 20px; font-weight: 680; letter-spacing: -0.3px; }
.blocked-screen p { max-width: 300px; margin: 0 0 18px; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.secondary-btn {
  border: 0;
  border-radius: 13px;
  padding: 11px 20px;
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.secondary-btn:active { transform: scale(0.97); }

/* ---------- states ---------- */
.app.is-loading .composer-wrap { opacity: 0.65; pointer-events: none; }
.composer-wrap.is-disabled { opacity: 0.6; }
.composer-wrap.is-disabled .quick-bar { pointer-events: none; }

@keyframes messageIn { from { opacity: 0; transform: translateY(7px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.94); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes floatIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bannerIn { from { opacity: 0; transform: translateY(-12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 0.6; transform: scale(0.8); } 75%, 100% { opacity: 0; transform: scale(1.6); } }

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

@media (max-width: 380px) {
  .bubble { max-width: 82%; font-size: 15px; }
  .chat-scroll { padding-left: 9px; padding-right: 9px; }
  .composer-wrap { padding-left: 9px; padding-right: 9px; }
  .header-actions .icon-btn { width: 35px; height: 35px; }
}
