:root,
[data-theme="dark"] {
  --bg: #0d1612;
  --bg-2: #15211b;
  --panel: #14201a;
  --line: #24362c;
  --text: #e6f2ea;
  --muted: #8aa396;
  --accent: #2fc974;
  --accent-strong: #3ddb84;
  --accent-soft: rgba(47, 201, 116, 0.14);
  --ok: #2fc974;
  --bad: #f07171;
  --warn: #e0a84a;
  --tg: #2aabee;
  --bale: #00a693;
  --input-bg: #0f1a15;
  --surface: #101c17;
  --surface-2: #18261f;
  --topbar-bg: rgba(13, 22, 18, 0.88);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --glow-1: rgba(47, 201, 116, 0.12);
  --glow-2: rgba(24, 138, 74, 0.1);
  --method-active-bg: #1a2b22;
  --badge-warn-bg: rgba(224, 168, 74, 0.18);
  --badge-bad-bg: rgba(240, 113, 113, 0.16);
  --bubble-bg: #1a2b22;
  --danger-soft: rgba(240, 113, 113, 0.14);
  --radius: 18px;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  color: var(--text);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3faf5;
  --bg-2: #e7f5ec;
  --panel: #ffffff;
  --line: #d7e8dd;
  --text: #143528;
  --muted: #5f7a69;
  --accent: #1f9d57;
  --accent-strong: #178a4a;
  --accent-soft: #e4f6eb;
  --ok: #1f9d57;
  --bad: #d64545;
  --warn: #c9891a;
  --input-bg: #fbfffc;
  --surface: #fbfffc;
  --surface-2: #f8fcf9;
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 50px rgba(20, 53, 40, 0.08);
  --glow-1: #cfeedd;
  --glow-2: #dff5e8;
  --method-active-bg: #fff;
  --badge-warn-bg: #fff4df;
  --badge-bad-bg: #fdecec;
  --bubble-bg: #eef6f1;
  --danger-soft: #fdecec;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(900px 420px at 100% -10%, var(--glow-1) 0%, transparent 55%),
    radial-gradient(700px 380px at -10% 20%, var(--glow-2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bg-glow { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  padding-top: max(0.7rem, env(safe-area-inset-top));
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.theme-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.75rem;
  background: linear-gradient(145deg, #2bbf6a, #178a4a);
  box-shadow: 0 8px 18px rgba(31, 157, 87, 0.28);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0.55rem 0.45rem 0.55rem 0.7rem;
  border: 2px solid #fff;
  border-radius: 999px 999px 999px 0.35rem;
  transform: rotate(-28deg);
  opacity: 0.95;
}
.brand strong { display: block; font-size: 1.05rem; font-weight: 700; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 0.78rem; }
.topbar-user { color: var(--muted); font-size: 0.88rem; text-align: left; }

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.1rem 2.5rem; }

.app-layout { display: grid; gap: 1rem; }
.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.tabs button[data-tab] {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
}
.tabs button[data-tab].active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.tabs-spacer { flex: 1; }

.bottom-nav { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.25rem;
}
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.panel-head p { margin: 0.3rem 0 1rem; color: var(--muted); font-size: 0.9rem; }
.account-actions {
  display: none;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.auth-layout {
  min-height: calc(100vh - 8rem);
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(100%, 440px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.35rem 1.25rem;
}
.auth-hero h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-hero p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.method-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin: 1rem 0 0.9rem;
  padding: 0.28rem;
  background: var(--bg-2);
  border-radius: 14px;
}
.credentials {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
  grid-template-columns: 1fr;
}
@media (max-width: 560px) {
  .method-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-layout { min-height: calc(100dvh - 5.5rem); align-items: start; padding-top: 0.5rem; }
  .phone-row input, input, button, textarea { font-size: 16px; }
}
.method-panel {
  margin: 0;
  animation: fade 0.18s ease;
}
.messenger-box {
  margin-top: 0.7rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}
.status-msg {
  min-height: 1.2rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.field { display: grid; gap: 0.4rem; }
.field > span { font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.phone-row {
  display: flex;
  flex-direction: row;
  direction: ltr;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--input-bg);
}
.dial {
  display: grid;
  place-items: center;
  padding: 0 0.85rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  border-right: 1px solid var(--line);
  min-width: 3.6rem;
}
.phone-row input {
  border: 0;
  background: transparent;
  border-radius: 0;
  text-align: left;
  flex: 1;
}
.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
}
.method-icon, .btn-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.back-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.back-link:hover { color: var(--accent-strong); }
.otp-input {
  letter-spacing: 0.35em;
  font-size: 1.35rem;
  text-align: center;
  font-weight: 700;
}
.otp-timer {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

input, button, textarea {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  padding: 0.72rem 0.9rem;
}
input:focus, button:focus-visible {
  outline: 2px solid rgba(47, 201, 116, 0.35);
  outline-offset: 1px;
}
button { cursor: pointer; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.method {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.2rem;
  border-radius: 10px;
  font-size: 0.86rem;
}
.method.active {
  background: var(--method-active-bg);
  color: var(--accent-strong);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.btn-primary {
  background: linear-gradient(180deg, #27b464, #178a4a);
  color: #fff;
  border: 0;
  box-shadow: 0 10px 22px rgba(31, 157, 87, 0.25);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-telegram {
  background: linear-gradient(180deg, #49b8f2, var(--tg));
  color: #fff;
  border: 0;
}
.btn-bale {
  background: linear-gradient(180deg, #18b8a5, var(--bale));
  color: #fff;
  border: 0;
}
.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }
.ghost.danger { color: var(--bad); }
.ghost.danger:hover { background: var(--danger-soft); }

.mt { margin-top: 0.75rem; }
.messenger-box a { color: var(--accent-strong); font-weight: 600; }

.list { display: grid; gap: 0.7rem; }
.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  text-align: right;
  width: 100%;
}
.item-btn {
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: block;
}
.item-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.item-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  border-inline-start: 3px solid var(--accent);
}
.item strong { display: block; margin-bottom: 0.25rem; font-size: 0.98rem; }
.chats-side .item {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
}
.chats-side .item strong {
  font-size: 0.88rem;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chats-side .item .sub {
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item .sub, .meta, .empty, .muted {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}
.item .actions { margin-top: 0.65rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.item button, .detail-actions button {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}
.item button.ok-btn { background: var(--accent-soft); color: var(--accent-strong); }
.item button.danger-btn { background: var(--danger-soft); color: var(--bad); }

.detail-pane { animation: fade 0.18s ease; }
.detail-grid {
  display: grid;
  gap: 0.55rem;
  margin: 0.5rem 0 1rem;
}
.kv {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.kv > span { color: var(--muted); }
.kv strong { font-weight: 600; word-break: break-word; }
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
}
.detail-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
}
.detail-sub {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}
.detail-links {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.media-link, .linkish {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  direction: ltr;
  unicode-bidi: isolate;
}
.api-hint {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  word-break: break-all;
}

.panel-chat {
  padding: 0.75rem;
  overflow: hidden;
}
.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 0.75rem;
  height: calc(100dvh - 9.5rem);
  max-height: calc(100dvh - 9.5rem);
  min-height: 360px;
  align-items: stretch;
}
.chats-side {
  height: 100%;
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.chat-pane {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  line-height: 1.7;
}
.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--line);
  min-height: 0;
}
.chat-back {
  display: none;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-head-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  overflow: hidden;
}
.chat-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.chat-head .detail-links {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head .detail-links:empty { display: none; }
.chat-presence {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.2;
  font-weight: 600;
  white-space: nowrap;
}
.chat-presence.hidden { display: none !important; }
.chat-presence.is-online { color: var(--accent-strong); }
.chat-presence.is-offline { color: var(--muted); }
.chat-typing {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--accent-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 0.55rem;
  align-content: start;
  padding: 0.75rem 0.85rem;
  margin: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}
.mam-older {
  flex-shrink: 0;
  margin: 0.35rem 0.85rem 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel, transparent);
  color: var(--muted, inherit);
  font: inherit;
  cursor: pointer;
}
.mam-older:disabled {
  opacity: 0.6;
  cursor: wait;
}
.attach-preview {
  flex-shrink: 0;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.85rem;
  border-top: 1px solid var(--line);
}
.reply-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-top: 1px solid var(--line);
  background: var(--accent-soft);
}
.reply-bar.hidden { display: none !important; }
.reply-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.8rem;
}
.reply-bar-text strong { color: var(--accent-strong); }
.reply-bar-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.msg-reply-quote {
  display: block;
  width: 100%;
  text-align: start;
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-inline-start: 3px solid rgba(255,255,255,0.55);
  border-radius: 8px;
  background: rgba(0,0,0,0.12);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble:not(.me) .msg-reply-quote {
  border-inline-start-color: var(--accent-strong);
  background: rgba(0,0,0,0.06);
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.msg-reply-btn {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.msg-reply-btn:hover { opacity: 1; text-decoration: underline; }
.bubble-flash {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
}
.attach-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.85rem;
}
.composer {
  flex-shrink: 0;
  display: flex;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  align-items: center;
  background: var(--panel);
}
.composer input#msg-input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* avoid iOS zoom */
}
.attach-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.btn-send { flex-shrink: 0; white-space: nowrap; }
.xmpp-meta {
  flex-shrink: 0;
  margin: 0;
  padding: 0.2rem 0.75rem 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
  word-break: break-all;
}

/* —— Mobile first shell —— */
@media (max-width: 860px) {
  main {
    padding: 0.75rem 0.7rem calc(4.75rem + env(safe-area-inset-bottom));
  }
  .site-foot { display: none; }
  .tabs-desktop { display: none !important; }
  #view-app .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 40;
    width: 100%;
    background: var(--topbar-bg);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
  }
  #view-app.hidden .bottom-nav { display: none !important; }
  .bottom-nav button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.45rem 0.2rem;
    border-radius: 10px;
  }
  .bottom-nav button.active {
    color: var(--accent-strong);
    background: var(--accent-soft);
  }
  .account-actions { display: flex; }
  .panel {
    border-radius: 14px;
    padding: 0.9rem 0.85rem 1rem;
  }
  .panel-chat {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .chat-layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - 7.25rem - env(safe-area-inset-bottom));
    max-height: none;
    gap: 0;
  }
  .chats-side {
    max-height: none;
    height: 100%;
  }
  .chat-pane {
    border-radius: 0;
    border: 0;
    display: none;
  }
  .chat-layout.is-thread .chats-side { display: none; }
  .chat-layout.is-thread .chat-pane {
    display: flex;
    height: 100%;
  }
  .chat-back { display: inline-grid; place-items: center; }
  .chat-empty { display: none; }
  .chat-head {
    padding: 0.28rem 0.5rem;
    align-items: center;
  }
  .chat-title {
    font-size: 0.8rem;
    font-weight: 600;
  }
  .chat-head .detail-links { font-size: 0.62rem; }
  .chat-typing { font-size: 0.62rem; }
  .xmpp-meta { display: none; }
  .auth-card {
    width: 100%;
    border-radius: 16px;
    padding: 1.15rem 1rem 1rem;
  }
  .method-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-user {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem;
  }
  .kv { grid-template-columns: 6.5rem 1fr; font-size: 0.85rem; }
  .detail-actions { flex-direction: column; }
  .detail-actions .btn-primary,
  .detail-actions .ghost { width: 100%; }
  body.chat-thread-open #view-app .bottom-nav { display: none !important; }
  body.chat-thread-open main {
    padding-bottom: 0.5rem;
  }
  body.chat-thread-open .chat-layout {
    height: calc(100dvh - 3.6rem - env(safe-area-inset-top));
  }
}

@media (min-width: 861px) {
  .chat-back { display: none !important; }
  .bottom-nav { display: none !important; }
}
.bubble {
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  background: var(--bubble-bg);
  max-width: 85%;
  line-height: 1.5;
}
.bubble.me {
  background: linear-gradient(180deg, #2bbf6a, #1f9d57);
  color: #fff;
  margin-inline-start: auto;
}
.bubble.me .sub { color: rgba(255,255,255,0.78); }
.msg-files { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bubble-media .msg-files { margin-top: 0; }
.msg-thumb {
  max-width: min(240px, 70vw);
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  display: block;
  background: rgba(0,0,0,0.12);
}
.msg-thumb[src=""], .msg-thumb:not([src]) { display: none; }
.msg-thumb-btn {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: 10px;
  line-height: 0;
}
.img-lightbox {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
}
.img-lightbox.is-open {
  display: flex !important;
}
.img-lightbox.hidden,
.img-lightbox[hidden] { display: none !important; }
.img-lightbox img {
  max-width: min(96vw, 920px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.img-lightbox-close {
  position: absolute;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
body.lightbox-open { overflow: hidden; }

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--badge-warn-bg);
  color: var(--warn);
}
.badge.ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge.bad { background: var(--badge-bad-bg); color: var(--bad); }

.account-card {
  max-width: 420px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.err { color: var(--bad); white-space: pre-wrap; margin: 0.5rem 0 0; }
.hidden { display: none !important; }
.site-foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 1rem 1.5rem;
}
