:root {
  --bg: #07140f;
  --bg-chat: #0d2419;
  --panel: #0f1f18;
  --panel-2: #142920;
  --panel-3: #1a3328;
  --line: rgba(255,255,255,.1);
  --text: #f2f7f4;
  --muted: #8aa897;
  --green: #2f9e6b;
  --green-2: #1f7a52;
  --green-soft: rgba(47,158,107,.18);
  --bubble-out: #1a5c3f;
  --bubble-in: #2f3438;
  --bubble-in-border: rgba(255,255,255,.05);
  --danger: #e25b5b;
  --badge: #2f9e6b;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
  --radius: 14px;
  --font: Manrope, system-ui, -apple-system, sans-serif;
  --sidebar-w: 360px;
  --nav-h: 64px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --vv-top: 0px;
  --dock-inset: 12px;
  --dock-gap: 10px;
  /* Nav is in document flow — overlays only need nav height + margin */
  --dock-space: calc(var(--nav-h) + var(--dock-gap) + var(--dock-inset));
  --pattern: url('/app/img/fone-tile.png');
  --pattern-opacity: .18;
  --glass-bg: rgba(18, 36, 28, .52);
  --glass-bg-strong: rgba(14, 30, 22, .72);
  --glass-border: rgba(255, 255, 255, .16);
  --glass-blur: 28px;
  --glass-saturate: 1.55;
  --glass-shadow: 0 10px 40px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .14);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, .18);
  --header-bg: var(--glass-bg);
  --composer-bg: var(--glass-bg-strong);
  --nav-bg: var(--glass-bg-strong);
  --input-bg: rgba(255,255,255,.06);
  --field-bg: rgba(255,255,255,.07);
  --field-bg-focus: rgba(255,255,255,.1);
  --strip-bg: var(--glass-bg);
  --soft-fill: rgba(255,255,255,.08);
  --soft-fill-2: rgba(255,255,255,.05);
  --accent-mint: #9be0bc;
  --auth-card: var(--glass-bg-strong);
  --auth-grad: linear-gradient(160deg, var(--bg), #0a1a13 60%, #06110c);
  --spring: cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="light"] {
  --bg: #e8f2ec;
  --bg-chat: #dceee4;
  --panel: #f4faf6;
  --panel-2: #ffffff;
  --panel-3: #e4f0e9;
  --line: rgba(20, 60, 40, .12);
  --text: #12261c;
  --muted: #5f7a6b;
  --green: #1f8a58;
  --green-2: #176b44;
  --green-soft: rgba(31,138,88,.14);
  --bubble-out: #c8ecd8;
  --bubble-in: #ffffff;
  --bubble-in-border: rgba(20, 60, 40, .08);
  --danger: #d64545;
  --badge: #1f8a58;
  --shadow: 0 12px 36px rgba(18, 50, 35, .12);
  --pattern-opacity: .14;
  --glass-bg: rgba(255, 255, 255, .55);
  --glass-bg-strong: rgba(255, 255, 255, .78);
  --glass-border: rgba(255, 255, 255, .65);
  --glass-blur: 24px;
  --glass-saturate: 1.4;
  --glass-shadow: 0 12px 36px rgba(18, 50, 35, .12), inset 0 1px 0 rgba(255, 255, 255, .85);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, .9);
  --header-bg: var(--glass-bg);
  --composer-bg: var(--glass-bg-strong);
  --nav-bg: var(--glass-bg-strong);
  --input-bg: rgba(255,255,255,.72);
  --field-bg: rgba(255,255,255,.78);
  --field-bg-focus: rgba(255,255,255,.92);
  --strip-bg: var(--glass-bg);
  --soft-fill: rgba(20, 60, 40, .06);
  --soft-fill-2: rgba(20, 60, 40, .04);
  --accent-mint: #1f7a52;
  --auth-card: var(--glass-bg-strong);
  --auth-grad:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(31,138,88,.16), transparent 50%),
    linear-gradient(160deg, #eef7f1, #dceee4 55%, #cfe6d8);
}

/* Liquid glass surfaces */
.glass,
.glass-strong {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}
.glass-strong {
  background: var(--glass-bg-strong);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .glass-strong {
    background: var(--panel-2);
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-bg: rgba(15, 31, 24, .94);
    --glass-bg-strong: rgba(15, 31, 24, .98);
    --glass-blur: 0px;
  }
  html[data-theme="light"] {
    --glass-bg: rgba(244, 250, 246, .96);
    --glass-bg-strong: rgba(255, 255, 255, .98);
    --glass-blur: 0px;
  }
}

* { box-sizing: border-box; }
html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: 100lvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Bottom chin only — top safe-area lives on headers (avoids frosted strip under status bar) */
  padding: 0 0 var(--safe-b);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { appearance: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.small { font-size: .82rem; }

/* —— Auth —— */
.auth-screen {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--auth-grad);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  padding: 2rem 1.5rem;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}
.auth-logo, .empty-orb {
  width: 72px; height: 72px; border-radius: 18px;
  display: block;
  object-fit: cover;
  margin: 0 0 .8rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.empty-orb { margin: 0 auto 1rem; }
.avatar.channel {
  width: 56px; height: 56px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  font-weight: 800; margin-bottom: .8rem;
}
.auth-card h1 { margin: 0 0 .4rem; letter-spacing: -.03em; }
.tabs { display: flex; gap: .5rem; margin: 1.2rem 0; }
.tab {
  flex: 1; border: 0; background: transparent; padding: .7rem;
  border-radius: 999px; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--green-soft); color: var(--text); box-shadow: var(--glass-highlight); }
.auth-form { display: grid; gap: .7rem; }
.auth-form input, .search, .modal-card input:not([type="checkbox"]):not([type="radio"]),
.modal-card textarea, .modal-card select {
  width: 100%; border: 1px solid var(--glass-border); background-color: var(--field-bg);
  border-radius: 16px; height: 48px; min-height: 48px; padding: 0 1rem;
  outline: none; box-sizing: border-box; font-size: .95rem; line-height: 1.2;
  appearance: none; -webkit-appearance: none; color: var(--text);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.modal-card select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
  cursor: pointer;
}
.modal-card textarea {
  height: auto; min-height: 96px; padding: .85rem 1rem;
}
.btn {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  border-radius: 16px;
  padding: .85rem 1.1rem;
  cursor: pointer;
  font-weight: 650;
  transition: background .18s var(--spring), border-color .18s ease, transform .16s var(--spring), box-shadow .18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: var(--glass-highlight);
}
.btn:hover { background: var(--soft-fill); border-color: rgba(46,168,110,.4); }
.btn:active { transform: scale(.98); }
.btn.primary, .send-btn {
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), transparent 40%),
    linear-gradient(135deg, var(--green), var(--green-2));
  border: 1px solid rgba(255,255,255,.2);
  color: white; font-weight: 700;
  box-shadow: 0 8px 22px rgba(46, 168, 110, .3), inset 0 1px 0 rgba(255,255,255,.25);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.btn.primary:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,.22), transparent 42%),
    linear-gradient(135deg, #34b078, var(--green));
  border: 1px solid rgba(255,255,255,.22);
}
.send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; flex: 0 0 auto;
  padding: 0; box-shadow: 0 6px 16px rgba(46, 168, 110, .3), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: .45rem .55rem;
  font-weight: 600;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
.btn.ghost:hover { color: var(--text); background: var(--soft-fill); }
.btn.danger-outline,
.btn.danger-text {
  border-color: transparent;
  color: var(--danger);
  background: transparent;
  font-weight: 650;
}
.btn.danger-outline:hover,
.btn.danger-text:hover {
  background: rgba(226,91,91,.12);
  border-color: transparent;
}

/* —— App shell (Telegram-like) —— */
.app {
  height: 100%;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background: var(--panel);
  position: relative;
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 2;
}
.sidebar-header {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 0 .75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--header-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  flex: 0 0 auto;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; border: 0;
  background: transparent; cursor: pointer; color: var(--text);
  display: grid; place-items: center; flex: 0 0 auto;
  font-size: 1.1rem; line-height: 1;
  transition: background .18s var(--spring), transform .16s var(--spring);
}
.icon-btn:hover { background: var(--soft-fill); }
.icon-btn:active { transform: scale(.94); }
.search {
  flex: 1; min-width: 0; height: 38px; padding: 0 .9rem;
  border-radius: 20px; background: var(--field-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--glass-highlight);
}

.stories-rail {
  display: flex; gap: .75rem; overflow-x: auto;
  padding: .75rem .9rem .55rem;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  flex: 0 0 auto;
}
.stories-rail::-webkit-scrollbar { display: none; }
.story-chip {
  flex: 0 0 auto; width: 64px; display: grid; gap: .3rem;
  justify-items: center; cursor: pointer; background: none; border: 0;
  padding: 0; color: var(--text); min-width: 64px;
}
.story-ring {
  width: 54px; height: 54px; border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--green), #7dcea0 50%, var(--green-2));
  display: grid; place-items: center;
  box-sizing: border-box;
}
.story-ring.empty {
  background: rgba(255,255,255,.12);
}
.story-ring .avatar {
  width: 48px; height: 48px; border: 2px solid var(--panel);
  margin: 0;
}
.story-chip span {
  font-size: .68rem; color: var(--muted); max-width: 64px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center; line-height: 1.2;
}
.story-add {
  position: relative;
}
.story-add .plus {
  position: absolute; right: 4px; bottom: 18px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: .75rem;
  display: grid; place-items: center; border: 2px solid var(--panel);
  font-weight: 800; z-index: 1;
}

.folder-tabs {
  display: flex; gap: .4rem; padding: .55rem .75rem .65rem;
  overflow-x: auto; scrollbar-width: none; flex: 0 0 auto;
}
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--muted);
  padding: .55rem .95rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glass-highlight);
  transition: background .2s var(--spring), color .2s ease, border-color .2s ease, transform .16s var(--spring);
}
.folder-tabs button:hover {
  color: var(--text);
  border-color: rgba(46,168,110,.4);
}
.folder-tabs button.active {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(46, 168, 110, .28);
}
html[data-theme="light"] .folder-tabs button {
  background: rgba(255,255,255,.85);
  color: #3d5c4c;
}
html[data-theme="light"] .folder-tabs button.active {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  border-color: transparent;
  color: #fff;
}
html[data-theme="light"] .folder-tabs button.active .ico {
  color: #fff;
}

.chat-list {
  overflow: auto; flex: 1; min-height: 0;
  padding-bottom: calc(var(--dock-space) + .5rem);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chat-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .7rem .9rem;
  cursor: pointer;
  min-height: 68px;
  border: 0;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
}
.chat-item:hover { background: rgba(255,255,255,.03); }
.chat-item.active { background: var(--green-soft); }
.chat-item .meta { min-width: 0; display: grid; gap: .15rem; }
.chat-item .top {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
}
.chat-item .top strong {
  font-size: .95rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .time {
  flex: 0 0 auto; font-size: .72rem; color: var(--muted);
}
.chat-item .preview {
  color: var(--muted); font-size: .84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: .35rem;
}
.chat-item .right-meta {
  display: grid; justify-items: end; gap: .35rem; align-self: center;
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--badge);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-grid; place-items: center;
}
.badge.muted-badge { background: rgba(255,255,255,.18); color: var(--text); }
html[data-theme="light"] .badge.muted-badge {
  background: rgba(18, 50, 35, .14);
  color: var(--text);
}
.pin { font-size: .75rem; opacity: .55; }
.chat-item.archive-entry .avatar.channel,
.chat-item.archive-nav .avatar.channel {
  background: linear-gradient(135deg, #3a4a55, #243038);
  color: #c8d4dc;
}
.chat-item .mute-inline {
  display: inline-flex; vertical-align: middle; opacity: .55; margin-left: .15rem;
}
.chat-item .mute-mark {
  opacity: .45; display: inline-grid; place-items: center;
}
.chat-item .mute-mark .ico,
.chat-item .mute-inline .ico { width: 14px; height: 14px; }

.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #245c43, #153628);
  background-size: cover; background-position: center;
  flex: 0 0 auto; display: grid; place-items: center; font-weight: 700;
  overflow: hidden;
}
.avatar.clickable { cursor: pointer; }
.avatar.clickable:active { transform: scale(.96); }
.avatar.sm { width: 40px; height: 40px; font-size: .85rem; }
.avatar.lg { width: 64px; height: 64px; }
.avatar.xl {
  width: 96px; height: 96px; margin: 0 auto;
  border: 4px solid var(--panel);
}
.avatar.glow {
  box-shadow: 0 0 0 3px rgba(47,158,107,.25), 0 12px 30px rgba(0,0,0,.35);
}

/* bottom nav — in-flow flex child on mobile (never absolute/fixed) */
.bottom-nav {
  display: none;
  position: relative;
  flex: 0 0 auto;
  height: var(--nav-h);
  margin: 0 var(--dock-inset) var(--dock-gap);
  padding: 4px;
  background: var(--nav-bg);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-shadow);
  z-index: 60;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  max-width: none;
  gap: 0;
  overflow: hidden;
}
.bottom-nav .nav-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 25%;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.16), transparent 45%),
    rgba(47, 158, 107, .28);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
  pointer-events: none;
  transform: translateX(0);
  transition: transform .42s var(--spring), width .42s var(--spring);
  z-index: 0;
}
html[data-theme="light"] .bottom-nav .nav-pill {
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent 50%),
    rgba(31, 138, 88, .18);
  border-color: rgba(31, 138, 88, .16);
}
.bottom-nav button {
  border: 0; background: transparent;
  color: var(--nav-idle, #8a9a90);
  display: grid; place-items: center; gap: .15rem;
  font-size: .65rem; font-weight: 600; cursor: pointer;
  padding: .3rem 0 .2rem; min-width: 0;
  transition: color .28s var(--spring), transform .28s var(--spring);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  border-radius: 22px;
}
.bottom-nav button > span:last-child {
  letter-spacing: -.01em;
  line-height: 1;
  transition: color .28s var(--spring), font-weight .28s ease, opacity .28s ease;
  opacity: .85;
}
.bottom-nav button.active {
  color: var(--nav-active, #2f9e6b);
}
.bottom-nav button.active > span:last-child {
  font-weight: 700;
  color: var(--nav-active, #2f9e6b);
  opacity: 1;
}
.bottom-nav button:active {
  transform: scale(.92);
}
.bottom-nav .nav-ico {
  width: 30px; height: 28px;
  display: grid; place-items: center;
  transition: transform .38s var(--spring), filter .28s ease;
}
.bottom-nav button.active .nav-ico {
  transform: translateY(-1px) scale(1.1);
}
.bottom-nav .nav-ico .ico {
  width: 26px; height: 26px;
}
.bottom-nav .nav-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background-size: cover; background-position: center;
  background-color: #245c43;
  display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  border: 2px solid transparent;
  transition: border-color .28s var(--spring), box-shadow .28s var(--spring), transform .38s var(--spring);
}
.bottom-nav button.active .nav-avatar {
  border-color: var(--nav-active, #2f9e6b);
  box-shadow: 0 0 0 2px rgba(47,158,107,.18);
  transform: scale(1.06);
}

html[data-theme="light"] .bottom-nav {
  --nav-idle: #6f8578;
  --nav-active: #1f8a58;
}
html[data-theme="dark"] .bottom-nav,
:root .bottom-nav {
  --nav-idle: #8aa897;
  --nav-active: #3ecf8e;
}

/* —— Main / chat —— */
.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-chat);
}
.empty-state {
  margin: auto; text-align: center; padding: 2rem; max-width: 360px;
}
.chat-empty .empty-orb { margin: 0 auto 1rem; width: 72px; height: 72px; }

.chat-view, .flood-view, .market-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background-color: var(--bg-chat);
  overflow: hidden;
}
.chat-view::before,
.flood-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--pattern);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--wp-pattern-opacity, var(--pattern-opacity));
  filter: var(--wp-pattern-filter, none);
  pointer-events: none;
  z-index: 0;
}
/* Light color + dark line-art (invert transparent light tile) */
.chat-view.wp-tone-light::before,
.flood-view.wp-tone-light::before {
  --wp-pattern-opacity: .2;
  --wp-pattern-filter: invert(1) brightness(.55) contrast(1.15);
}
/* Dark color + original light line-art on transparent */
.chat-view.wp-tone-dark::before,
.flood-view.wp-tone-dark::before {
  --wp-pattern-opacity: .16;
  --wp-pattern-filter: none;
}
.chat-view.has-custom-bg::before,
.flood-view.has-custom-bg::before { display: none; }
.chat-view.has-custom-bg,
.flood-view.has-custom-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.chat-view > *,
.flood-view > *,
.market-view > * {
  position: relative;
  z-index: 1;
}

.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: 0 .75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--header-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-highlight);
  flex: 0 0 auto;
  z-index: 2;
}
.chat-header-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: .05rem;
}
.chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  flex: 0 0 auto;
}
.chat-header .icon-btn.active {
  background: var(--green-soft);
  color: var(--text);
}
.chat-header-meta strong {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: .95rem;
}
.chat-header-meta .muted { font-size: .78rem; }

/* messages scroll over fixed wallpaper on the parent view */
.messages {
  flex: 1;
  overflow: auto;
  padding: .75rem .9rem 1rem;
  min-height: 0;
  background: transparent;
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.msg {
  max-width: min(78%, 480px);
  margin: .28rem 0;
  margin-right: auto;
  padding: .55rem .7rem .35rem;
  border-radius: 14px 14px 14px 4px;
  background: var(--bubble-in);
  border: 1px solid var(--bubble-in-border);
  position: relative;
  box-shadow: 0 1px 0 rgba(0,0,0,.12);
  clear: both;
  -webkit-touch-callout: none;
}
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: .45rem;
  margin: .4rem 0;
  max-width: 100%;
  clear: both;
}
.msg-row.out {
  flex-direction: row;
  justify-content: flex-end;
}
.msg-row .msg {
  clear: none;
  margin: 0;
  max-width: min(72%, 440px);
}
.msg-row.out .msg.out {
  margin-left: 0;
}
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  flex: 0 0 auto;
  cursor: pointer;
  background: linear-gradient(135deg, #245c43, #153628);
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(47,158,107,.18);
  -webkit-touch-callout: none;
  user-select: none;
}
.msg-avatar:active { transform: scale(.94); }
.msg.out {
  margin-left: auto;
  margin-right: 0;
  background: var(--bubble-out);
  border-color: rgba(47,158,107,.22);
  border-radius: 14px 14px 4px 14px;
}
html[data-theme="dark"] .msg.out,
:root:not([data-theme="light"]) .msg.out { color: #f4fbf7; }
html[data-theme="light"] .msg.out { color: #123226; border-color: rgba(31,138,88,.2); }
html[data-theme="light"] .msg:not(.out) .time { color: rgba(18,38,28,.45); }
html[data-theme="light"] .msg.out .time { color: rgba(18,50,35,.5); }
.msg:not(.out) .time { color: rgba(255,255,255,.42); }
.msg.out .time { color: rgba(255,255,255,.55); }
.msg .text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; font-size: .95rem; }
.msg .time {
  display: flex; justify-content: flex-end; align-items: center; gap: .3rem;
  font-size: .68rem; color: rgba(255,255,255,.5); margin-top: .2rem;
}
.msg .media { display: grid; gap: .3rem; margin-bottom: .3rem; }
.msg .media img,
.msg .media video {
  max-width: 100%; border-radius: 10px; display: block;
  image-orientation: none;
  background: #000;
}
.msg .media img { cursor: zoom-in; }
.msg .media video {
  max-height: min(420px, 55vh);
  width: 100%;
  object-fit: contain;
}
.msg .author {
  font-size: .78rem; color: var(--accent-mint); margin-bottom: .15rem; font-weight: 700;
  cursor: pointer;
}
.reactions {
  display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem;
}
.reactions button, .reaction-picker button {
  border: 1px solid var(--line); background: var(--soft-fill);
  border-radius: 999px; padding: .12rem .4rem; cursor: pointer; font-size: .82rem;
}
.reactions button.active { border-color: var(--green); background: var(--green-soft); }
.typing {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .2rem 1rem .4rem;
  color: var(--muted);
  font-size: .82rem;
  flex: 0 0 auto;
  min-height: 0;
}
.typing-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  flex: 0 0 auto;
  cursor: pointer;
  background-color: var(--panel-3);
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px rgba(47,158,107,.22);
}
.typing-avatar:active { transform: scale(.94); }
#typingLabel { min-width: 0; }
.composer {
  display: flex; align-items: center; gap: .45rem;
  padding: .55rem .65rem calc(.55rem + var(--safe-b));
  border-top: 1px solid var(--glass-border);
  background: var(--composer-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-highlight);
  flex: 0 0 auto;
}
.composer-tool, .icon-btn.composer-tool {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  flex: 0 0 auto; align-self: center;
}
.composer-shell { align-self: center; }
.send-btn { align-self: center; }
.composer-field {
  flex: 1; min-width: 0;
  border: 1px solid var(--glass-border);
  background: var(--field-bg);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--glass-highlight);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.composer-field textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  max-height: 120px; padding: .7rem .95rem; outline: none;
  line-height: 1.35; min-height: 42px;
}

.topic-bar {
  display: flex; gap: .4rem; overflow-x: auto; padding: .5rem .75rem;
  border-bottom: 1px solid var(--glass-border); scrollbar-width: none;
  background: var(--strip-bg);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  flex: 0 0 auto;
}
.topic-bar::-webkit-scrollbar { display: none; }
.topic-chip {
  flex: 0 0 auto; border: 1px solid var(--glass-border); background: var(--glass-bg);
  color: var(--muted); border-radius: 999px; padding: .4rem .8rem;
  cursor: pointer; font-size: .8rem; white-space: nowrap;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background .18s var(--spring), color .18s ease, border-color .18s ease;
}
.topic-chip.active, .topic-chip:hover {
  background: var(--green-soft); color: var(--text); border-color: rgba(47,158,107,.45);
}
.loading-bar {
  display: flex; align-items: center; gap: .5rem; padding: .4rem 1rem;
  color: var(--muted); font-size: .85rem; flex: 0 0 auto;
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--green);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msg .ticks { letter-spacing: -.05em; }
.msg .ticks.read { color: #7dcea0; }
.msg .edited { font-size: .68rem; opacity: .65; margin-right: .2rem; }
.msg.sending { opacity: .65; }
.msg .react-avatars {
  display: inline-flex; align-items: center; margin-left: .15rem;
}
.msg .react-avatars img, .msg .react-avatars span.av {
  width: 16px; height: 16px; border-radius: 50%; margin-left: -4px;
  border: 1px solid rgba(0,0,0,.35); object-fit: cover;
  background: #245c43; font-size: .55rem; display: inline-grid; place-items: center;
}

/* —— Profile panel —— */
.profile-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  z-index: 46;
  box-shadow: -18px 0 48px rgba(0, 0, 0, .28);
  transform: translateX(0);
  animation: profileSlideIn .28s var(--spring);
}
@keyframes profileSlideIn {
  from { transform: translateX(18px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.profile-panel.hidden { display: none !important; }
.profile-bg {
  height: 150px;
  background:
    linear-gradient(135deg, #1b4d36, #0d241a),
    var(--pattern);
  background-size: cover, 100% 100%;
  background-repeat: no-repeat;
  background-blend-mode: normal, soft-light;
}
.profile-hero {
  position: relative;
  display: flex;
  justify-content: center;
  margin: -64px auto 0;
  z-index: 1;
}
.profile-avatar-wrap {
  position: relative;
  width: fit-content;
}
.profile-avatar-xl {
  width: 128px;
  height: 128px;
  margin: 0 auto;
  border: 4px solid var(--panel);
  font-size: 2.4rem;
  box-shadow: 0 0 0 3px rgba(47,158,107,.22), 0 16px 36px rgba(0,0,0,.35);
}
.online-dot {
  position: absolute; right: 10px; bottom: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #3dd68c; border: 3px solid var(--panel);
  z-index: 2;
}
.profile-avatar-wrap.has-tariff .online-dot {
  right: auto;
  left: 10px;
}
.profile-tariff-badge {
  position: absolute;
  right: -2px;
  bottom: 4px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a5c3f, #0d2419);
  border: 3px solid var(--panel);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.3), 0 0 0 2px rgba(47,158,107,.35);
  z-index: 3;
  overflow: hidden;
}
.profile-tariff-badge img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.profile-tariff {
  margin: 0 auto .75rem;
  padding: .7rem .85rem;
  max-width: 320px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid rgba(47,158,107,.35);
  box-shadow: var(--glass-highlight);
  text-align: center;
}
.profile-tariff strong {
  display: block;
  font-size: .88rem;
  font-weight: 700;
  color: var(--accent-mint);
  margin-bottom: .2rem;
}
.profile-tariff span {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.35;
}
.profile-panel h2, .profile-panel .muted, .profile-panel .bio { text-align: center; padding: 0 1rem; }
.profile-panel h2 {
  margin: .15rem 0 .15rem;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  font-weight: 750;
}
.profile-nick {
  display: block;
  margin: .1rem auto .45rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.profile-nick:hover { color: var(--accent-mint); }
.profile-panel .bio { margin: .55rem 0; color: var(--text); font-size: .92rem; }
.handle-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  margin: .25rem auto; padding: .35rem .75rem;
  border-radius: 999px; border: 1px solid rgba(31,138,88,.35);
  background: var(--green-soft); color: var(--accent-mint);
  cursor: pointer; font-weight: 600; font-size: .92rem;
}
.handle-chip.sm { font-size: .78rem; padding: .2rem .55rem; margin: .15rem 0 0; }
.handle-chip:hover { background: rgba(47,158,107,.22); }
.profile-status { text-align: center; font-size: .85rem; }
.links { display: grid; gap: .4rem; padding: 0 1rem 1rem; }
.links a {
  color: var(--accent-mint); text-decoration: none; padding: .55rem .75rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--soft-fill);
}
.panel-actions { display: grid; gap: .5rem; padding: 0 1rem 1.5rem; }
.sticky-actions {
  position: sticky; bottom: 0;
  background: linear-gradient(transparent, var(--panel) 30%);
  padding: 1rem;
}
#closeProfile { position: absolute; top: .45rem; right: .45rem; z-index: 2; }
.showcase-block { padding: 0 1rem 1rem; }
.showcase-block h4 { margin: 0 0 .6rem; font-size: .9rem; color: var(--muted); }

/* —— Drawer / settings (Telegram style) —— */
.drawer {
  position: fixed; inset: 0; z-index: 40;
  display: grid; grid-template-columns: minmax(380px, 50vw) 1fr;
}
.drawer-backdrop {
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.drawer-sheet {
  background: var(--glass-bg-strong);
  border-right: 1px solid var(--glass-border);
  padding: .75rem;
  display: flex; flex-direction: column; gap: .15rem;
  box-shadow: var(--glass-shadow);
  overflow: auto;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}
.drawer-user {
  display: flex; gap: .8rem; align-items: center;
  padding: .65rem .55rem 1rem; border-bottom: 1px solid var(--line);
  margin-bottom: .55rem;
}
.settings-group {
  display: grid; gap: .15rem;
  margin-bottom: .7rem;
  padding: .25rem;
  border-radius: 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glass-highlight);
}
.settings-view > .settings-group:last-child {
  margin-top: auto;
  margin-bottom: .25rem;
}
.settings-row,
.settings-view > .settings-row {
  text-align: left; border: 0; background: transparent;
  padding: .7rem .65rem; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; gap: .85rem;
  color: var(--text); font: inherit; width: 100%;
}
.settings-row:hover { background: var(--green-soft); }
.settings-row-copy {
  display: grid; gap: .12rem; min-width: 0; flex: 1; text-align: left;
}
.settings-row-copy strong {
  font-size: .95rem; font-weight: 700; color: var(--text);
}
.settings-row-copy span {
  font-size: .78rem; color: var(--muted); line-height: 1.3;
}
.settings-row.danger .settings-row-copy strong { color: var(--danger); }
.settings-ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; color: #fff; line-height: 0;
}
.settings-ico .ico { width: 18px; height: 18px; display: block; margin: 0; color: inherit; }
.settings-ico.tone-blue { background: linear-gradient(145deg, #4ea1ff, #2b6de8); }
.settings-ico.tone-teal { background: linear-gradient(145deg, #3ecfcf, #1f9e9e); }
.settings-ico.tone-green { background: linear-gradient(145deg, #45c489, #1f8a58); }
.settings-ico.tone-lime { background: linear-gradient(145deg, #7ed957, #3aa83a); }
.settings-ico.tone-orange { background: linear-gradient(145deg, #ff9f43, #e67e22); }
.settings-ico.tone-amber { background: linear-gradient(145deg, #f6c945, #e0a84a); color: #3a2a00; }
.settings-ico.tone-pink { background: linear-gradient(145deg, #ff6b9d, #e8437a); }
.settings-ico.tone-cyan { background: linear-gradient(145deg, #54d0ff, #2a9fd8); }
.settings-ico.tone-gold { background: linear-gradient(145deg, #f0c24b, #d4a017); color: #3a2a00; }
.settings-ico.tone-slate { background: linear-gradient(145deg, #8aa0b4, #5f7388); }
.settings-ico.tone-red { background: linear-gradient(145deg, #ff6b6b, #e25b5b); }
.settings-row-inline {
  display: flex; align-items: center; gap: .85rem;
  padding: .55rem .65rem; border-radius: 14px;
}
.settings-lead {
  margin: 0 0 .15rem; color: var(--muted); font-size: .88rem; line-height: 1.45;
}
.settings-stack { display: grid; gap: .65rem; }
.setting-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 16px;
  padding: .85rem .9rem;
  display: grid; gap: .7rem;
}
.setting-card-head {
  display: flex; align-items: flex-start; gap: .75rem;
}
.setting-card-copy { display: grid; gap: .2rem; min-width: 0; }
.setting-card-copy strong { font-size: .95rem; color: var(--text); }
.setting-card-copy span { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.setting-card-control .chip-select { margin-top: .1rem; }
.pwd-form {
  display: grid;
  gap: .55rem;
  margin-top: .75rem;
}
.pwd-form .btn { margin-top: .15rem; }

.drawer-sheet > button:not(.settings-row):not(.icon-btn),
.settings-view > button:not(.settings-row):not(.icon-btn):not(.theme-toggle) {
  text-align: left; border: 0; background: transparent;
  padding: .85rem .75rem; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; gap: .85rem;
  color: var(--text); font: inherit; font-size: .95rem;
}
.drawer-sheet > button:not(.settings-row):hover,
.settings-view > button:not(.settings-row):not(.theme-toggle):hover {
  background: var(--green-soft);
}

.settings-shell { display: flex; flex-direction: column; height: 100%; }
.settings-nav {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem 0 .8rem; border-bottom: 1px solid var(--line);
  margin-bottom: .5rem;
}
.settings-body { overflow: auto; display: grid; gap: .85rem; padding-bottom: .5rem; }
.settings-view {
  display: flex; flex-direction: column; gap: .15rem;
  flex: 1; min-height: 0;
}
.settings-body label:not(.ui-switch):not(.file-card) {
  display: grid; gap: .35rem; font-size: .9rem; color: var(--muted);
}
.field { display: grid; gap: .4rem; }
.field-label {
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); text-transform: uppercase;
}
.field-hint { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.field-input,
.settings-body input.field-input,
.settings-body textarea.field-input,
.settings-body select.field-input {
  width: 100%; border: 1px solid var(--line);
  background-color: var(--field-bg);
  background-image: none;
  border-radius: 14px;
  height: 48px;
  min-height: 48px;
  padding: 0 1rem;
  outline: none;
  color: var(--text); font: inherit; font-size: .95rem;
  line-height: 1.2;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.settings-body textarea.field-input {
  height: auto;
  min-height: 96px;
  padding: .85rem 1rem;
  resize: vertical;
}
.field-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 168, 110, .18);
  background-color: var(--field-bg-focus);
}
select.field-input {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
  cursor: pointer;
}
.chip-select {
  display: flex; flex-wrap: wrap; gap: .4rem;
}
.chip-select .chip {
  appearance: none; border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--muted); border-radius: 999px;
  padding: .55rem .9rem; font: inherit; font-size: .88rem;
  cursor: pointer; transition: .18s var(--spring);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.chip-select .chip:hover { color: var(--text); border-color: rgba(46,168,110,.45); }
.chip-select .chip.active {
  color: #fff; border-color: rgba(255,255,255,.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), transparent 42%),
    linear-gradient(135deg, var(--green), var(--green-2));
  box-shadow: 0 6px 16px rgba(46, 168, 110, .28), inset 0 1px 0 rgba(255,255,255,.22);
}
.file-cards { display: grid; gap: .55rem; }
.file-card {
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1rem; border-radius: 16px; cursor: pointer;
  border: 1px dashed rgba(46,168,110,.35);
  background: rgba(46,168,110,.06);
  transition: border-color .15s, background .15s;
}
.file-card:hover {
  border-color: var(--green);
  background: rgba(46,168,110,.12);
}
.file-card-ico {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(135deg, rgba(46,168,110,.25), rgba(46,168,110,.08));
  color: var(--green);
}
.file-card-copy { display: grid; gap: .15rem; min-width: 0; }
.file-card-copy strong { color: var(--text); font-size: .95rem; }
.file-card-copy span { color: var(--muted); font-size: .8rem; }
.settings-note {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .9rem 1rem; border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.settings-note-ico {
  width: 36px; height: 36px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; line-height: 0;
  background: rgba(46,168,110,.12); color: var(--green);
}
.settings-note-ico .ico { display: block; margin: 0; }
.settings-note strong { display: block; color: var(--text); font-size: .92rem; }
.settings-note > div span,
.settings-note #lastLoginLabel {
  display: block; color: var(--muted); font-size: .82rem; margin-top: .15rem; line-height: 1.35;
}
.settings-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.wallet-card { display: grid; gap: .85rem; }
.wallet-card-top {
  display: flex; align-items: center; gap: .9rem;
  padding: 1.1rem 1.15rem; border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(46,168,110,.18), rgba(255,255,255,.03));
}
.wallet-ico {
  width: 48px; height: 48px; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; line-height: 0;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff; box-shadow: 0 8px 20px rgba(46,168,110,.3);
}
.wallet-ico .ico { display: block; margin: 0; }
.wallet-balance { font-size: 1.55rem; letter-spacing: -.02em; color: var(--text); }
.wallet-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.wallet-amounts .chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 999px;
  padding: .4rem .75rem;
  cursor: pointer;
  color: var(--muted);
}
.wallet-amounts .chip.active {
  color: var(--text);
  border-color: rgba(47,158,107,.5);
  background: rgba(47,158,107,.16);
}
.wallet-custom {
  display: grid;
  gap: .55rem;
}
.wallet-pay-box {
  padding: .85rem;
  border-radius: 14px;
  border: 1px dashed rgba(47,158,107,.45);
  background: rgba(47,158,107,.08);
  display: grid;
  gap: .35rem;
  font-size: .9rem;
}
.wallet-history { display: grid; gap: .55rem; }
.wallet-tx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .7rem .8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.wallet-tx > div:first-child {
  display: grid;
  gap: .15rem;
  min-width: 0;
}
.wallet-tx strong { font-size: .9rem; }
.wallet-tx .muted { font-size: .75rem; }
.wallet-tx-right {
  display: grid;
  justify-items: end;
  gap: .3rem;
  flex: 0 0 auto;
}
.wallet-tx-right .plus { color: #3ecf8e; }
.wallet-tx-right .minus { color: #e25b5b; }
.wallet-tx.pending { border-color: rgba(212,160,23,.35); }
.wallet-tx.cancelled { opacity: .65; }

.admin-search-row {
  display: flex;
  gap: .5rem;
  align-items: stretch;
  margin-bottom: .75rem;
}
.admin-search-row .field-input { flex: 1; min-width: 0; }
.admin-users-list {
  display: grid;
  gap: .65rem;
}
.admin-user-card {
  padding: .75rem .85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  display: grid;
  gap: .45rem;
}
.admin-user-open {
  display: grid;
  gap: .15rem;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.admin-user-open strong { font-size: .95rem; }
.admin-user-open .muted { font-size: .78rem; }
.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.admin-user-actions .btn.sm {
  padding: .35rem .65rem;
  font-size: .78rem;
}

.showcase-buy-block {
  display: grid;
  gap: .55rem;
  margin: .35rem 0 .75rem;
}
.showcase-buy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
}

.msg {
  position: relative;
  transition: transform .12s ease;
  touch-action: pan-y;
}
.msg.swiping { transition: none; z-index: 2; }
.msg.swipe-reply::before {
  content: '↩';
  position: absolute;
  left: -1.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .75rem;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 12px rgba(47,158,107,.35);
}
.invite-card { display: grid; gap: .85rem; }
.invite-link-row {
  display: grid; gap: .55rem;
}
.invite-link-row .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.auth-invite-hint { margin: -.35rem 0 .15rem; line-height: 1.35; }
.auth-invite-hint.error { color: var(--danger); }
.ui-select, .settings-body select { display: none; }
.ui-switch {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem .85rem; border-radius: 14px;
  background: var(--soft-fill); border: 1px solid var(--line);
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.ui-switch > span:first-child { flex: 1; min-width: 0; font-size: .95rem; color: var(--text); }
.ui-switch-control {
  position: relative;
  width: 52px; height: 32px;
  flex: 0 0 auto;
}
.ui-switch-control input {
  position: absolute; inset: 0; z-index: 2;
  width: 100% !important; height: 100% !important; min-height: 0 !important;
  margin: 0; padding: 0 !important; opacity: 0; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  border: 0 !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
.ui-switch-track {
  position: absolute; inset: 0; z-index: 1;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid var(--line);
  transition: background .22s ease, border-color .22s ease;
  pointer-events: none;
}
.ui-switch-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.ui-switch-control input:checked + .ui-switch-track {
  background: var(--green);
  border-color: transparent;
}
.ui-switch-control input:checked + .ui-switch-track::after {
  transform: translateX(20px);
}
html[data-theme="light"] .ui-switch-track {
  background: rgba(0,0,0,.12);
}

.media-panel {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(480px, 100%); max-height: 55vh;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 22px 22px 0 0; z-index: 75;
  display: flex; flex-direction: column;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}
.media-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem .85rem; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.gif-search-wrap {
  display: flex; align-items: center; gap: .45rem;
  margin: .65rem .75rem .35rem;
  padding: .15rem .25rem .15rem .7rem;
  border-radius: 999px;
  background-color: var(--field-bg);
  border: 1px solid var(--line);
}
.gif-search-wrap .ico { color: var(--muted); opacity: .85; }
.gif-search-wrap input {
  flex: 1; border: 0; background: transparent; outline: none;
  padding: .65rem .55rem; min-width: 0;
}
.media-panel .search { margin: .5rem .75rem; width: auto; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: .25rem; padding: .6rem; overflow: auto; flex: 1; min-height: 0;
}
.emoji-grid button {
  font-size: 1.75rem; border: 0; background: transparent;
  padding: .35rem; border-radius: 10px; cursor: pointer;
}
.emoji-grid button:hover { background: rgba(255,255,255,.06); }
.sticker-pack-tabs {
  display: flex; gap: .35rem; padding: .45rem .7rem 0;
  overflow-x: auto; flex: 0 0 auto; -webkit-overflow-scrolling: touch;
}
.sticker-pack-tabs button {
  flex: 0 0 auto; border: 0; border-radius: 999px;
  padding: .35rem .7rem; background: var(--soft-fill);
  color: var(--muted); font-size: .82rem; cursor: pointer;
}
.sticker-pack-tabs button.active {
  background: var(--green-soft); color: var(--text); font-weight: 600;
}
.sticker-hint { margin: .35rem .85rem 0; }
.sticker-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: .35rem; padding: .55rem .7rem .85rem;
  overflow: auto; flex: 1; min-height: 0;
}
.sticker-grid button {
  font-size: 2.35rem; line-height: 1.1; border: 0; background: transparent;
  padding: .45rem; border-radius: 14px; cursor: pointer;
}
.sticker-grid button:hover { background: rgba(255,255,255,.06); }
.sticker-empty { grid-column: 1 / -1; text-align: center; padding: 1.2rem .5rem; }
.msg.sticker-bubble {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: .15rem .2rem .35rem;
}
.msg.sticker-bubble .sticker-msg {
  font-size: 4.2rem; line-height: 1.05;
  user-select: none;
}
.msg.sticker-bubble .time { opacity: .75; }
.gif-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: .45rem; padding: .55rem .7rem .75rem;
  overflow: auto; flex: 1; min-height: 0;
  -webkit-overflow-scrolling: touch;
  align-content: start;
}
.gif-grid button {
  border: 0; padding: 0; background: var(--soft-fill); border-radius: 12px;
  overflow: hidden; cursor: pointer;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 96px;
}
.gif-grid img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.market-toolbar {
  display: flex; align-items: center; gap: .35rem;
  padding: .55rem .75rem; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--header-bg);
}
.market-toolbar .icon-btn.active { background: var(--green-soft); color: var(--text); }
.market-filters {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  padding: .45rem 0 .55rem;
}
.market-cat-chips {
  display: flex; gap: .35rem; padding: 0 .75rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.market-chip {
  flex: 0 0 auto; border: 1px solid var(--glass-border); border-radius: 999px;
  padding: .38rem .75rem; background: var(--glass-bg);
  color: var(--muted); font-size: .8rem; cursor: pointer; white-space: nowrap;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background .18s var(--spring), color .18s ease;
}
.market-chip.active {
  background: var(--green-soft); color: var(--text); font-weight: 600;
  border-color: rgba(47,158,107,.4);
}
.market-filter-row {
  display: flex; gap: .45rem; align-items: center;
  padding: .5rem .75rem 0;
}
.market-sort-field { flex: 1; min-width: 0; }
.market-sort-field .field-input {
  width: 100%; height: 38px; padding: 0 .75rem; font-size: .84rem;
}
.market-filter-toggle { flex: 0 0 auto; white-space: nowrap; padding: .45rem .7rem; }
.market-filter-toggle.active { background: var(--green-soft); }
#marketFilterBtn.active { background: var(--green-soft); color: var(--text); }
.market-filter-panel {
  display: grid; gap: .55rem;
  padding: .65rem .75rem 0;
}
.market-filter-panel.hidden { display: none; }
.market-price-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: .55rem;
}
.market-filter-actions {
  display: flex; gap: .45rem; justify-content: flex-end;
}
.market-filter-actions .btn { padding: .5rem .9rem; }
.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;
}
.market-feed {
  flex: 1;
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(.75rem + var(--safe-b));
}
.market-list { display: grid; }
.market-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .55rem;
  padding: .65rem .75rem;
}
.market-card {
  border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; background: rgba(10, 22, 17, .92); color: inherit;
  display: flex; flex-direction: column; text-align: left;
}
.market-card .market-photo {
  aspect-ratio: 1; background-size: cover; background-position: center;
  background-color: rgba(0,0,0,.25);
  position: relative;
}
.market-card .market-body {
  padding: .55rem .65rem .65rem; display: grid; gap: .3rem; flex: 1;
}
.market-card .market-title {
  font-size: .84rem; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-card .market-price { color: var(--accent-mint); font-weight: 800; font-size: .9rem; }
.market-card .market-meta { font-size: .72rem; color: var(--muted); }
.fav-btn {
  position: absolute; top: .4rem; right: .4rem;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff;
  display: grid; place-items: center; cursor: pointer; z-index: 2;
}
.fav-btn.on { color: #ff6b7a; background: rgba(255,255,255,.92); }
.fav-btn .ico { width: 16px; height: 16px; }
.listing-status-badge {
  position: absolute; left: .4rem; top: .4rem; z-index: 2;
  font-size: .68rem; font-weight: 700; padding: .2rem .45rem;
  border-radius: 999px; background: rgba(0,0,0,.55); color: #fff;
}
.listing-status-badge.status-reserved { background: #c9851a; }
.listing-status-badge.status-sold { background: #8a3a3a; }
.market-card.is-reserved .market-photo,
.market-row.is-reserved .market-row-photo { filter: saturate(.85); }
.deal-listing-list { display: grid; gap: .65rem; max-height: min(60vh, 520px); overflow: auto; padding: .15rem; }
.deal-listing-item {
  display: grid; grid-template-columns: 64px 1fr; gap: .65rem;
  padding: .55rem; border: 1px solid var(--line); border-radius: 12px;
}
.deal-listing-photo {
  width: 64px; height: 64px; border-radius: 10px;
  background-size: cover; background-position: center; background-color: rgba(0,0,0,.2);
}
.deal-listing-meta { display: grid; gap: .35rem; align-content: start; min-width: 0; }
.deal-listing-meta strong {
  font-size: .88rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.deal-listing-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.deal-listing-actions .btn { padding: .4rem .7rem; font-size: .78rem; }
.listing-view-deal { display: flex; flex-wrap: wrap; gap: .4rem; }
.listing-view-modal { max-width: 560px; width: min(560px, 96vw); }
.listing-view-body {
  padding: 0 .2rem .4rem; display: grid; gap: .75rem;
  max-height: min(72vh, 720px); overflow: auto;
}
.listing-view-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .45rem;
}
.listing-view-photo {
  aspect-ratio: 1; border: 0; border-radius: 12px; cursor: zoom-in;
  background-size: cover; background-position: center; background-color: rgba(0,0,0,.2);
}
.listing-view-price { font-size: 1.35rem; font-weight: 800; color: var(--accent-mint, var(--green)); }
.listing-view-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.listing-view-actions .btn { display: inline-flex; align-items: center; gap: .35rem; }

/* Telegram-like attach sheet */
.attach-sheet {
  position: fixed; inset: 0; z-index: 85;
  display: flex; align-items: flex-end; justify-content: center;
}
.attach-sheet.hidden { display: none !important; }
.attach-sheet-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0;
  background: rgba(0,0,0,.4); cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.attach-sheet-panel {
  position: relative; z-index: 1;
  width: min(100%, 420px);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 26px 26px 0 0;
  padding: .45rem .85rem calc(.95rem + var(--safe-b));
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  animation: attachUp .28s var(--spring);
}
@keyframes attachUp {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
.attach-sheet-handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.18);
  margin: .15rem auto .75rem;
}
.attach-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .55rem;
}
.attach-sheet-item {
  display: grid; gap: .4rem; justify-items: center;
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: .75rem; cursor: pointer; padding: .25rem;
}
.attach-sheet-ico {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; color: #fff;
}
.attach-sheet-ico.tone-blue { background: linear-gradient(145deg, #4ea1ff, #2b6de8); }
.attach-sheet-ico.tone-amber { background: linear-gradient(145deg, #f6c945, #e0a84a); color: #3a2a00; }
.attach-sheet-ico.tone-violet { background: linear-gradient(145deg, #b07cff, #7a4fd6); }
.attach-sheet-ico.tone-green { background: linear-gradient(145deg, #45c489, #1f8a58); }

/* Shared listing card in chat */
.listing-msg-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: .65rem;
  width: min(100%, 280px);
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: .45rem;
  margin: .15rem 0 .35rem;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.msg.out .listing-msg-card {
  background: rgba(0,0,0,.14);
  border-color: rgba(255,255,255,.1);
}
.listing-msg-photo {
  width: 72px; height: 72px; border-radius: 10px;
  background: var(--soft-fill) center/cover no-repeat;
}
.listing-msg-body {
  display: grid; gap: .15rem; min-width: 0; align-content: center;
}
.listing-msg-eyebrow {
  font-size: .68rem; color: var(--accent-mint); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.listing-msg-title {
  font-size: .9rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.listing-msg-price {
  font-weight: 800; color: var(--accent-mint); font-size: .92rem;
}
.listing-msg-meta {
  font-size: .72rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share-listing-actions {
  display: grid; gap: .35rem; padding: .25rem 0 .5rem;
}

html[data-theme="light"] .attach-sheet-panel {
  background: #fff;
  box-shadow: 0 -12px 36px rgba(18, 50, 35, .12);
}
html[data-theme="light"] .attach-sheet-handle {
  background: rgba(20, 60, 40, .15);
}
html[data-theme="light"] .listing-msg-card {
  background: #fff;
  border-color: rgba(20, 60, 40, .1);
}
html[data-theme="light"] .msg.out .listing-msg-card {
  background: rgba(255,255,255,.55);
}
.listing-similar h4 { margin: .35rem 0 .45rem; font-size: .95rem; }
.listing-similar-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem;
}
.listing-similar-card {
  border: 1px solid var(--line); border-radius: 12px; background: transparent;
  color: inherit; text-align: left; padding: .45rem; cursor: pointer;
  display: grid; gap: .3rem;
}
.listing-similar-photo {
  aspect-ratio: 1.2; border-radius: 10px; display: block;
  background-size: cover; background-position: center; background-color: rgba(0,0,0,.2);
}
.listing-similar-title {
  font-size: .78rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.listing-similar-price { font-size: .82rem; font-weight: 700; color: var(--accent-mint, var(--green)); }
.market-card .market-actions,
.market-row .market-actions {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; align-items: center;
}
.market-card .market-actions .btn,
.market-row .market-actions .btn {
  flex: 0 0 auto;
  padding: .5rem .85rem;
  font-size: .78rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
}
.market-card .market-actions .btn.primary,
.market-row .market-actions .btn.primary {
  flex: 1;
  min-width: 7.5rem;
}
.market-card .market-actions .btn.ghost,
.market-row .market-actions .btn.ghost,
.market-card .market-actions .btn.danger-text,
.market-row .market-actions .btn.danger-text {
  flex: 0 0 auto;
  box-shadow: none;
}
.market-card .market-actions .btn .ico,
.market-row .market-actions .btn .ico { width: 14px; height: 14px; margin: 0; }
.market-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: .7rem; align-items: start;
  padding: .7rem .8rem;
  border: 0; background: transparent;
  width: 100%; text-align: left; color: inherit;
  border-bottom: 1px solid var(--line);
}
.market-row:hover { background: rgba(255,255,255,.03); }
.market-row .market-row-photo {
  width: 72px; height: 72px; border-radius: 12px;
  background-size: cover; background-position: center;
  position: relative;
  background-color: rgba(0,0,0,.25);
}
.market-row .market-row-meta { min-width: 0; display: grid; gap: .25rem; }
.market-row .market-row-top {
  display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start;
}
.market-row .market-row-top strong {
  font-size: .92rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-row .market-price { color: var(--accent-mint); font-weight: 800; flex: 0 0 auto; }
.market-empty {
  padding: 2.5rem 1.25rem; text-align: center; color: var(--muted);
}
.story-ring.seen {
  background: rgba(255,255,255,.22);
}
.story-chip.seen span { opacity: .7; }

.listing-modal .modal-lead { margin: .25rem 0 0; line-height: 1.35; }
.listing-modal .modal-form,
.modal-form {
  display: grid;
  gap: .85rem;
}
.listing-modal .field,
.modal-form .field {
  display: grid;
  gap: .4rem;
}
.listing-modal .field-input,
.modal-form .field-input,
.modal-card .field-input {
  width: 100%;
  height: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  background-color: var(--field-bg);
  background-image: none;
  border-radius: 14px;
  padding: 0 1rem;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  line-height: 1.2;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.listing-modal textarea.field-input,
.modal-form textarea.field-input,
.modal-card textarea.field-input {
  height: auto;
  min-height: 96px;
  padding: .85rem 1rem;
  resize: vertical;
}
.listing-modal .field-input:focus,
.modal-form .field-input:focus,
.modal-card .field-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 168, 110, .18);
  background-color: var(--field-bg-focus);
}
.listing-modal select.field-input,
.modal-form select.field-input,
.modal-card select.field-input {
  background-color: var(--field-bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
  cursor: pointer;
}
.listing-modal .file-card {
  margin: 0;
  height: 48px;
  min-height: 48px;
  padding: 0 1rem;
  border-radius: 14px;
  border-style: solid;
  gap: .7rem;
}
.listing-modal .file-card-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}
.listing-modal .file-card-copy strong { font-size: .92rem; }
.listing-modal .file-card-copy span { display: none; }
.listing-photo-preview {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem;
}
.listing-photo-preview:empty { display: none; }
.listing-photo-preview img,
.listing-photo-preview .listing-photo-thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line);
  image-orientation: none;
  cursor: pointer;
  transition: transform .12s, opacity .12s;
  background-size: cover;
  background-position: center;
  padding: 0;
  display: block;
}
.listing-photo-preview img:hover,
.listing-photo-preview .listing-photo-thumb:hover { opacity: .85; transform: scale(.98); }
.modal-submit { width: 100%; padding: 1rem 1.1rem; border-radius: 16px; font-size: .98rem; }

.showcase-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
  align-items: start;
}
.showcase-item {
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--soft-fill);
  padding: 0;
  display: flex;
  flex-direction: column;
  font-size: .78rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  position: relative;
  box-shadow: none;
}
.showcase-photo {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel-3) center / cover no-repeat;
  flex: 0 0 auto;
}
.showcase-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .5rem .55rem .6rem;
}
.showcase-title {
  font-weight: 650;
  font-size: .8rem;
  line-height: 1.25;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.showcase-item .showcase-price {
  color: var(--accent-mint);
  font-weight: 800;
  font-size: .85rem;
  text-shadow: none;
  margin-top: .1rem;
}
.showcase-item .showcase-meta {
  font-size: .68rem;
  color: var(--muted);
  opacity: 1;
  margin-top: 0;
}
.showcase-item .market-mod-del {
  margin-top: .3rem;
  align-self: flex-start;
}
.showcase-item::before { display: none; }
.showcase-item > * { position: relative; z-index: 1; }

.market-mod-del {
  border: 0; background: transparent; color: var(--danger);
  border-radius: 10px; padding: .45rem .5rem; cursor: pointer; font-size: .78rem;
  font-weight: 700;
}

.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(7, 20, 15, .45);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  padding: 1rem;
  animation: modalFade .22s var(--spring);
}
@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-card {
  width: min(460px, 100%);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  padding: 1.15rem 1.15rem 1.25rem;
  display: grid;
  gap: .9rem;
  box-shadow: var(--glass-shadow);
  max-height: min(92vh, 760px);
  overflow: auto;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  animation: modalPop .32s var(--spring);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.modal-card.wide { width: min(520px, 100%); }
.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
}
.modal-card header h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.modal-card label:not(.field):not(.file-card):not(.ui-switch) {
  display: grid; gap: .35rem; font-size: .9rem; color: var(--muted);
}
.poll-options-edit {
  display: grid;
  gap: .45rem;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.file-label input { margin-top: .35rem; }
.check-row {
  display: flex !important; align-items: center; gap: .6rem;
  color: var(--text) !important; flex-direction: row !important;
}
.wallpaper-presets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem;
  margin-bottom: .85rem;
}
.wallpaper-section-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
  text-transform: uppercase;
  margin: .35rem 0 .45rem;
}
.wp-option {
  aspect-ratio: 1; border-radius: 16px; border: 2px solid transparent;
  cursor: pointer; overflow: hidden; position: relative;
  background: var(--bg-chat);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  transition: border-color .18s ease, transform .16s var(--spring);
}
.wp-option:active { transform: scale(.96); }
.wp-option.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(47,158,107,.25);
}
.wp-option::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--pattern);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.wp-option.tone-light::before {
  opacity: .38;
  filter: invert(1) brightness(.55) contrast(1.15);
}
.wp-option.tone-dark::before {
  opacity: .42;
  filter: none;
}
.wp-option.custom {
  background-size: cover;
  background-position: center;
}
.wp-option.custom::before { display: none; }
.wp-option.custom.is-empty {
  display: grid;
  place-items: center;
  background: var(--soft-fill);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
}
.wp-custom-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: .75rem;
  align-items: center;
  margin: .35rem 0 1rem;
}

.theme-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem .75rem; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  margin: .35rem 0 .55rem;
}
.theme-row.settings-row-inline {
  justify-content: flex-start;
  border: 0;
  background: transparent;
  margin: 0;
  padding: .55rem .65rem;
}
html[data-theme="light"] .theme-row { background: rgba(255,255,255,.7); }
html[data-theme="light"] .theme-row.settings-row-inline { background: transparent; }
.theme-row-copy { display: grid; gap: .15rem; min-width: 0; flex: 1; }
.theme-row-copy strong { font-size: .95rem; color: var(--text); }
.theme-row-copy span { font-size: .78rem; color: var(--muted); }
.theme-toggle {
  position: relative; width: 58px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--soft-fill);
  cursor: pointer; flex: 0 0 auto; padding: 0;
  transition: background .25s ease, border-color .25s ease;
  overflow: hidden;
}
.theme-toggle::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(255,210,120,.15), transparent 55%);
  pointer-events: none;
}
html[data-theme="light"] .theme-toggle {
  background: linear-gradient(135deg, #ffe8a8, #c8e8d4);
  border-color: rgba(46,168,110,.25);
}
.theme-knob {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(145deg, #1a2e24, #0f1f18);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), background .25s ease;
  display: grid; place-items: center;
  color: #f0d78c;
}
html[data-theme="light"] .theme-knob {
  transform: translateX(24px);
  background: linear-gradient(145deg, #fff8e8, #ffe6a8);
  color: #c47a12;
  box-shadow: 0 4px 12px rgba(196,122,18,.25);
}
.theme-knob .ico { display: block; }

.reaction-picker {
  position: fixed; z-index: 60; display: flex; gap: .25rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem; box-shadow: var(--shadow);
}
.burst-layer {
  pointer-events: none; position: fixed; inset: 0; z-index: 80; overflow: hidden;
}
.burst-particle {
  position: absolute; font-size: 1.4rem;
  animation: burstFly 1.1s ease-out forwards;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.35));
}
@keyframes burstFly {
  0% { transform: translate(0,0) scale(.4) rotate(0deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.15) rotate(var(--rot)); opacity: 0; }
}
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + var(--safe-b));
  transform: translateX(-50%);
  background: var(--glass-bg-strong);
  color: var(--text);
  border: 1px solid var(--glass-border);
  padding: .7rem 1.05rem; border-radius: 999px; z-index: 90;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  font-size: .9rem;
  font-weight: 600;
  max-width: min(92vw, 360px);
  text-align: center;
  line-height: 1.35;
}
html[data-theme="light"] .toast {
  background: var(--glass-bg-strong);
  color: var(--text);
  border-color: var(--glass-border);
}

/* Story viewer */
.story-viewer {
  position: fixed; inset: 0; z-index: 70;
  background: #000;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
.story-viewer.hidden { display: none !important; }
.story-progress {
  display: flex; gap: 3px;
  padding: calc(.45rem + var(--safe-t)) .75rem .35rem;
  flex: 0 0 auto;
}
.story-progress i {
  flex: 1; height: 2.5px; border-radius: 99px; background: rgba(255,255,255,.28);
  overflow: hidden; min-width: 0;
}
.story-progress i b {
  display: block; height: 100%; width: 0; background: #fff;
}
.story-progress i.done b { width: 100%; }
.story-progress i.active b { animation: storyFill linear forwards; }
@keyframes storyFill { from { width: 0; } to { width: 100%; } }
.story-top {
  display: flex; align-items: center; gap: .65rem;
  padding: .35rem .75rem .55rem;
  flex: 0 0 auto;
  color: #fff;
  min-width: 0;
}
.story-top .muted { color: rgba(255,255,255,.65); }
.story-top .icon-btn { color: #fff; }
.story-top strong {
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.story-media {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.story-media img, .story-media video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  image-orientation: none;
}
.story-caption {
  text-align: center;
  padding: .55rem 1rem calc(.85rem + var(--safe-b));
  color: #fff;
  font-size: .92rem;
  flex: 0 0 auto;
  word-break: break-word;
}
.story-nav-hit {
  position: absolute; top: 0; bottom: 0; width: 42%; z-index: 2;
}
.story-nav-hit.prev { left: 0; }
.story-nav-hit.next { right: 0; }

.mobile-only { display: none; }
.desktop-only { display: grid; }

.online-list { display: grid; gap: .55rem; max-height: 50vh; overflow: auto; }
.online-row {
  display: flex; gap: .7rem; align-items: center; padding: .45rem;
  border-radius: 12px; cursor: pointer;
}
.online-row:hover { background: rgba(255,255,255,.05); }

/* —— Mobile —— */
@media (max-width: 900px) {
  html, body {
    overflow: hidden;
    overscroll-behavior: none;
  }
  body {
    position: relative;
    inset: auto;
    height: 100%;
    height: 100dvh;
    height: 100lvh;
    padding: 0 0 var(--safe-b);
  }
  .app {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    overflow: hidden;
    overscroll-behavior: none;
  }
  html.kb-open body {
    height: var(--app-height, 100dvh);
    padding-bottom: 0;
  }
  .sidebar {
    flex: 1 1 auto;
    min-height: 0;
    border-right: 0;
    padding-bottom: 0;
    width: 100%;
    overflow: hidden;
  }
  .folder-tabs { display: none; }
  .bottom-nav {
    display: grid;
    position: relative;
    flex: 0 0 auto;
    left: auto;
    right: auto;
    bottom: auto;
    margin: 0 var(--dock-inset) var(--dock-gap);
    z-index: 60;
    max-width: none;
  }
  .mobile-only { display: grid; }
  .desktop-only { display: none; }
  .sidebar.collapsed { display: none; }
  .main {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
  }
  .main.collapsed { display: none; }
  .chat-list {
    padding-bottom: .75rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .stories-rail {
    padding-bottom: .65rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
  }
  .app.chat-open .bottom-nav,
  html.cc-chat-open .bottom-nav { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .main { display: flex; }
  .app.chat-open .composer {
    padding-bottom: .55rem;
  }
  .app.flood-open .sidebar { display: none; }
  .app.flood-open .main { display: flex; }
  .app.flood-open .bottom-nav,
  html.cc-flood-open .bottom-nav { display: grid; }
  .app.flood-open .composer {
    padding-bottom: .45rem;
  }
  .app.flood-open .flood-view {
    padding-bottom: 0;
  }
  .app.market-open .sidebar { display: none; }
  .app.market-open .main { display: flex; }
  .app.market-open .bottom-nav,
  html.cc-market-open .bottom-nav { display: grid; }
  .app.market-open .market-feed {
    padding-bottom: .75rem;
  }
  .app:not(.chat-open) .toast,
  html:not(.cc-chat-open) .toast {
    bottom: calc(var(--dock-space) + var(--safe-b) + .5rem);
  }
  .profile-panel {
    position: fixed;
    /* Cover content above the in-flow dock — no extra safe-b (that left a market peek gap) */
    inset: 0 0 var(--dock-space) 0;
    width: 100%;
    max-width: none;
    z-index: 55;
    padding-bottom: 0;
    border-left: 0;
    box-shadow: none;
    animation: none;
    background: var(--panel);
  }
  .profile-panel #closeProfile {
    top: calc(.45rem + var(--safe-t));
  }
  .row { grid-template-columns: 1fr; }
  .drawer {
    grid-template-columns: 1fr;
    z-index: 58;
    inset: 0 0 var(--dock-space) 0;
    top: 0;
    right: 0;
    left: 0;
    bottom: var(--dock-space);
  }
  .drawer-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
  }
  .drawer-sheet {
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0;
    border: 0;
    padding: calc(.75rem + var(--safe-t)) .75rem .75rem;
    position: relative;
    z-index: 1;
  }
  .msg { max-width: 82%; }
  .msg-row .msg { max-width: min(78%, 420px); }
  .msg-avatar { width: 34px; height: 34px; font-size: .72rem; }
  .msg,
  .msg * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  .messages { padding: .65rem .7rem 1rem; }
  .composer {
    gap: .25rem;
    padding: .45rem .45rem;
  }
  .composer-tool, .icon-btn.composer-tool {
    width: 36px; height: 36px;
  }
  .send-btn { width: 42px; height: 42px; }
  .media-panel {
    left: 0; right: 0; width: 100%;
    transform: none;
    max-height: min(62vh, 520px);
    padding-bottom: calc(var(--safe-b) + .5rem);
    z-index: 75;
  }
  .app.chat-open .media-panel {
    padding-bottom: calc(var(--safe-b) + .5rem);
  }
  .sticker-grid { grid-template-columns: repeat(5, 1fr); }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
  .gif-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gif-grid button { min-height: 120px; }
  .market-grid { grid-template-columns: 1fr 1fr; gap: .45rem; padding: .55rem .6rem; }
  .chat-item { min-height: 64px; padding: .65rem .8rem; }
  /* Header fills under status bar / Dynamic Island — solid, no backdrop blur */
  .sidebar-header {
    padding: var(--safe-t) .55rem 0 .75rem;
    height: auto;
    min-height: calc(var(--header-h) + var(--safe-t));
    box-sizing: border-box;
    background: var(--panel);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .chat-header {
    padding: var(--safe-t) .75rem 0;
    height: auto;
    min-height: calc(var(--header-h) + var(--safe-t));
    box-sizing: border-box;
    background: var(--panel);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .auth-screen {
    padding-top: var(--safe-t);
  }
  .topic-bar,
  .market-cat-chips,
  .stories-rail {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (min-width: 901px) {
  /* Profile opens as overlay — chats stay full width */
  .app.has-profile {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
  .app.has-profile .profile-panel {
    width: min(420px, 42vw);
  }
  .bottom-nav { display: none !important; }
}



/* —— Icons —— */
.ico {
  display: block;
  flex: 0 0 auto;
  transition: transform .28s var(--spring), opacity .22s ease, filter .28s ease, color .22s ease;
}
.ico-fill,
.ico-glass {
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.22));
}
.icon-btn .ico { margin: auto; }
.folder-tabs button { display: inline-flex; align-items: center; gap: .4rem; }
.folder-tabs .ico { width: 16px; height: 16px; }
.folder-tabs button.active .ico { color: #fff; filter: drop-shadow(0 1px 0 rgba(255,255,255,.3)); }
.drawer-sheet > button { gap: .85rem; }
.settings-view > button { gap: .85rem; }
.drawer-sheet > button [data-ico],
.settings-view > button [data-ico] {
  width: 38px; height: 38px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--green); flex: 0 0 auto;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--glass-highlight);
}
.settings-view .settings-ico [data-ico],
.settings-view .settings-row [data-ico] {
  width: auto; height: auto; border-radius: 0;
  display: contents; background: transparent; color: inherit;
  border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.settings-view .settings-ico .ico {
  opacity: 1; color: inherit; width: 18px; height: 18px;
}
.btn .ico { display: inline-block; vertical-align: -4px; margin-right: .35rem; width: 18px; height: 18px; }
.nav-ico .ico, .nav-ico { display: grid; place-items: center; }
.composer-tool { color: var(--muted); }
.composer-tool:hover { color: var(--text); }
.send-btn .ico {
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.2));
}
.bottom-nav button:not(.active) .nav-ico .ico {
  opacity: .7;
}
.bottom-nav button.active .nav-ico .ico {
  opacity: 1;
  filter: drop-shadow(0 2px 8px rgba(47,158,107,.4));
}
html[data-theme="light"] .bottom-nav button.active .nav-ico .ico {
  filter: drop-shadow(0 2px 6px rgba(31,138,88,.28));
}
.attach-sheet-ico .ico {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.18));
}

/* Menu on the right */
.drawer-right {
  grid-template-columns: 1fr minmax(380px, 50vw);
}
.drawer-right .drawer-sheet {
  order: 2;
  width: 100%;
  max-width: none;
  animation: slideRight .25s ease both;
}
.drawer-right .drawer-backdrop { order: 1; }
@keyframes slideRight {
  from { transform: translateX(24px); opacity: .4; }
  to { transform: none; opacity: 1; }
}
@media (max-width: 900px) {
  .drawer-right {
    grid-template-columns: 1fr;
  }
  .drawer-right .drawer-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 0;
  }
  .drawer-right .drawer-sheet {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    order: 0;
    animation: none;
    box-shadow: none;
    z-index: 1;
    padding: calc(.75rem + var(--safe-t)) .75rem calc(.75rem + var(--safe-b));
    background: var(--panel);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Composer */
.composer {
  gap: .4rem;
  padding: .55rem .7rem calc(.65rem + var(--safe-b));
  align-items: center;
}
.composer-shell {
  flex: 1; min-width: 0;
  background-color: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: .15rem .2rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.composer-shell textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  max-height: 120px; padding: .7rem .95rem; outline: none;
  line-height: 1.35; min-height: 42px;
}
.send-btn {
  width: 46px; height: 46px;
  box-shadow: 0 8px 20px rgba(31,122,82,.35);
}
.send-btn.mic-mode {
  background: linear-gradient(135deg, #45c489, #1f8a58);
}
.send-btn.recording {
  background: linear-gradient(135deg, #ff6b6b, #e25b5b);
  box-shadow: 0 8px 20px rgba(226,91,91,.35);
  animation: voicePulse 1s ease infinite;
}
@keyframes voicePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.voice-record-bar {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .8rem; border-top: 1px solid var(--line);
  background: var(--strip-bg); flex: 0 0 auto;
}
.voice-rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: voicePulse .9s ease infinite;
}
.voice-msg {
  display: flex; align-items: center; gap: .55rem;
  min-width: 180px; max-width: 260px;
  padding: .35rem .2rem .2rem;
}
.voice-play {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--green); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: 0 0 auto;
}
.msg.out .voice-play { background: rgba(255,255,255,.2); color: inherit; }
.voice-msg.playing .voice-play { background: var(--green-2); }
.voice-wave {
  flex: 1; display: flex; align-items: center; gap: 3px; height: 22px;
}
.voice-wave i {
  display: block; width: 3px; border-radius: 99px;
  background: currentColor; opacity: .45;
  height: 40%;
}
.voice-wave i:nth-child(2) { height: 70%; }
.voice-wave i:nth-child(3) { height: 100%; }
.voice-wave i:nth-child(4) { height: 55%; }
.voice-wave i:nth-child(5) { height: 85%; }
.voice-wave i:nth-child(6) { height: 45%; }
.voice-wave i:nth-child(7) { height: 75%; }
.voice-wave i:nth-child(8) { height: 35%; }
.voice-msg.playing .voice-wave i {
  opacity: .85;
  animation: waveBar .8s ease-in-out infinite;
}
.voice-msg.playing .voice-wave i:nth-child(2) { animation-delay: .05s; }
.voice-msg.playing .voice-wave i:nth-child(3) { animation-delay: .1s; }
.voice-msg.playing .voice-wave i:nth-child(4) { animation-delay: .15s; }
.voice-msg.playing .voice-wave i:nth-child(5) { animation-delay: .2s; }
.voice-msg.playing .voice-wave i:nth-child(6) { animation-delay: .25s; }
.voice-msg.playing .voice-wave i:nth-child(7) { animation-delay: .3s; }
.voice-msg.playing .voice-wave i:nth-child(8) { animation-delay: .35s; }
@keyframes waveBar {
  0%, 100% { transform: scaleY(.55); }
  50% { transform: scaleY(1); }
}
.voice-dur {
  font-size: .75rem; opacity: .75; min-width: 2.2rem; text-align: right;
}
.voice-msg audio { display: none; }

/* Reply / mention / search */
.reply-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .8rem; border-top: 1px solid var(--line);
  background: var(--strip-bg); flex: 0 0 auto;
}
.reply-bar-body { flex: 1; min-width: 0; display: grid; gap: .1rem; border-left: 3px solid var(--green); padding-left: .65rem; }
.reply-bar.is-edit .reply-bar-body { border-left-color: #e0a84a; }
.reply-bar-body strong { font-size: .78rem; color: var(--accent-mint); }
.reply-bar.is-edit .reply-bar-body strong { color: #e0a84a; }
.reply-bar-body span { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn.editing { box-shadow: 0 8px 20px rgba(224,168,74,.35); }
.mention-popup {
  position: absolute; left: .75rem; right: .75rem; bottom: 72px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; max-height: 200px; overflow: auto;
  z-index: 8; box-shadow: var(--shadow);
}
.mention-popup button {
  width: 100%; display: flex; gap: .65rem; align-items: center;
  border: 0; background: transparent; padding: .65rem .8rem; cursor: pointer; text-align: left;
}
.mention-popup button:hover { background: var(--green-soft); }
.chat-search-bar {
  display: flex; gap: .5rem; align-items: center;
  padding: .45rem .75rem; border-bottom: 1px solid var(--line);
  background: var(--strip-bg); flex: 0 0 auto;
}
.chat-search-bar input {
  flex: 1; border: 1px solid var(--line); background-color: var(--field-bg);
  border-radius: 999px; padding: .55rem .9rem; outline: none;
}

.dm-pin-bar {
  display: flex; align-items: center; gap: .45rem;
  padding: .4rem .75rem; border-bottom: 1px solid var(--line);
  background: var(--green-soft); flex: 0 0 auto; cursor: default;
}
.dm-pin-bar .dm-pin-ico { opacity: .85; display: inline-flex; }
.dm-pin-body { flex: 1; min-width: 0; display: grid; gap: .05rem; }
.dm-pin-body strong { font-size: .72rem; color: var(--accent-mint); }
.dm-pin-body span { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.quick-replies {
  display: flex; gap: .4rem; flex-wrap: nowrap; overflow-x: auto;
  padding: .35rem .75rem; border-top: 1px solid var(--glass-border);
  background: var(--strip-bg); flex: 0 0 auto;
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply-chip {
  flex: 0 0 auto; border: 1px solid var(--glass-border); background: var(--glass-bg);
  color: var(--text); border-radius: 999px; padding: .35rem .75rem;
  font-size: .78rem; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .35rem;
  max-width: min(78vw, 280px);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--glass-highlight);
}
.quick-reply-chip > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px;
}
.quick-reply-chip:hover { border-color: var(--green); background: var(--green-soft); }
.quick-reply-chip.custom { padding-right: .45rem; }
.qr-del {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .85rem; line-height: 1;
  color: var(--muted); background: rgba(0,0,0,.18);
  flex: 0 0 auto;
}
.qr-del:hover { color: var(--danger); background: rgba(226,91,91,.18); }
.quick-reply-add {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px dashed rgba(47,158,107,.45);
  background: var(--green-soft);
  color: var(--accent-mint);
  font-size: 1.25rem; font-weight: 700; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
}
.quick-reply-add:hover {
  border-style: solid;
  border-color: var(--green);
  background: rgba(47,158,107,.28);
}

.msg-separator-new {
  display: flex; align-items: center; justify-content: center;
  margin: .55rem 0 .35rem; width: 100%;
}
.msg-separator-new span {
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-mint); background: var(--green-soft);
  border: 1px solid rgba(31,122,82,.35); border-radius: 999px;
  padding: .28rem .7rem;
}

.forward-label {
  font-size: .72rem; color: var(--accent-mint); margin-bottom: .25rem; opacity: .9;
}
.forward-preview {
  margin: 0 0 .75rem; padding: .55rem .7rem; border-left: 3px solid var(--green);
  background: var(--soft-fill); border-radius: 8px; font-size: .85rem;
}
.forward-peer-list { display: grid; gap: .35rem; max-height: 320px; overflow: auto; }
.forward-peer-item {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: .55rem .7rem; cursor: pointer; text-align: left;
}
.forward-peer-item:hover { border-color: var(--green); background: var(--green-soft); }
.forward-peer-item.selected {
  border-color: var(--green);
  background: var(--green-soft);
}
.forward-peer-name { flex: 1; min-width: 0; }
.forward-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); flex: 0 0 auto;
}
.forward-peer-item.selected .forward-check {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 3px var(--panel-2);
}
#forwardSubmitBtn { width: 100%; margin-top: .75rem; }
.chat-item .preview.has-draft { color: var(--green); }
.chat-item .draft-label { font-weight: 700; margin-right: .2rem; }

/* Message extras */
.msg .reply-quote {
  border-left: 3px solid rgba(155,224,188,.55);
  background: var(--soft-fill);
  border-radius: 8px; padding: .35rem .55rem; margin-bottom: .4rem;
  font-size: .8rem; cursor: pointer;
}
.msg .reply-quote strong { color: var(--accent-mint); display: block; font-size: .72rem; }
.msg .mention { color: var(--accent-mint); font-weight: 700; cursor: pointer; }
.msg.deleted { opacity: .55; font-style: italic; }
.msg-actions {
  position: fixed; z-index: 65;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 18px; padding: .35rem; min-width: 210px;
  box-shadow: var(--glass-shadow);
  display: grid;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  animation: modalPop .24s var(--spring);
}
.msg-actions button {
  display: flex; align-items: center; gap: .65rem;
  border: 0; background: transparent; padding: .7rem .8rem;
  border-radius: 12px; cursor: pointer; text-align: left;
}
.msg-actions button:hover { background: var(--green-soft); }
.msg-actions button.danger { color: var(--danger); }
.msg-actions .ico { color: var(--green); }
.msg-actions button.danger .ico { color: var(--danger); }

.poll-card {
  background: var(--soft-fill); border-radius: 12px; padding: .55rem;
  margin: .2rem 0 .35rem; display: grid; gap: .4rem;
}
.poll-card h5 { margin: 0; font-size: .9rem; }
.poll-opt {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; cursor: pointer; overflow: hidden; background: var(--soft-fill-2);
}
.poll-opt .bar {
  position: absolute; inset: 0 auto 0 0; background: rgba(47,158,107,.22);
  z-index: 0;
}
.poll-opt .row { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }
.poll-opt.mine { border-color: rgba(47,158,107,.55); }
.poll-options-edit { display: grid; gap: .45rem; }

.topic-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .85rem;
}
.topic-chip .ico { width: 16px; height: 16px; color: var(--green); }
.topic-chip.active .ico { color: var(--accent-mint); }

.badge {
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--badge);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-grid; place-items: center;
}

/* Profile wow */
.profile-panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-3) 100%);
}
.profile-bg {
  height: 180px; position: relative; overflow: hidden;
  background: linear-gradient(145deg, #1f6a48, #0d241a 55%, #07140f);
}
.profile-bg-pattern {
  position: absolute; inset: 0;
  background-image: var(--pattern);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--pattern-opacity); pointer-events: none;
}
.profile-close { position: absolute; top: .55rem; right: .55rem; z-index: 3;
  background: rgba(0,0,0,.35); backdrop-filter: blur(8px); }
.profile-hero { margin-top: -64px; }
.profile-card {
  margin: .55rem 1rem 1rem;
  padding: 1.05rem 1rem 1.15rem;
  border-radius: 22px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  text-align: center;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.profile-card h2 { margin: .15rem 0 .1rem; }
.profile-card .bio { text-align: center; color: var(--muted); line-height: 1.45; }
.panel-actions .btn { display: flex; align-items: center; justify-content: center; gap: .4rem; }
.showcase-block { padding: 0 1rem 1.5rem; }

.profile-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  margin: .35rem 0 .15rem;
  font-size: .88rem;
}
.profile-rating strong { color: var(--text); font-weight: 650; }
.stars { letter-spacing: .06em; color: rgba(128,128,128,.35); }
.stars .on { color: #d4a017; }
.stars.sm { font-size: .85rem; }

.profile-badges { margin: .25rem 0 .15rem; }
.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .35rem;
}
.user-badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .02em;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
}
.user-badge.badge-verified { color: #5ec4ff; border-color: rgba(94,196,255,.35); background: rgba(94,196,255,.12); }
.user-badge.badge-collector { color: #e0b45a; border-color: rgba(224,180,90,.35); background: rgba(224,180,90,.12); }
.user-badge.badge-shop { color: #7dcea0; border-color: rgba(125,206,160,.35); background: rgba(125,206,160,.12); }
.user-badge.badge-admin { color: #f0a0a0; border-color: rgba(240,160,160,.35); background: rgba(240,160,160,.12); }
.user-badge.badge-mod { color: #c4a0f0; border-color: rgba(196,160,240,.35); background: rgba(196,160,240,.12); }
.badge-edit {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
  margin-top: .55rem;
}
.badge-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: .28rem .65rem;
  font-size: .75rem;
  cursor: pointer;
}
.badge-toggle.on {
  color: var(--text);
  border-color: rgba(47,158,107,.45);
  background: rgba(47,158,107,.16);
}
.verified-mark {
  color: #5ec4ff;
  font-weight: 700;
  font-size: .85em;
}

.profile-qr-block {
  margin: .85rem auto 0;
  padding: .85rem .75rem .65rem;
  max-width: 240px;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--glass-border);
  display: grid;
  gap: .45rem;
  justify-items: center;
}
.profile-qr-block canvas {
  width: 180px;
  height: 180px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
}
.profile-qr-block .small {
  margin: 0;
  text-align: center;
  line-height: 1.3;
}
.profile-qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  justify-content: center;
}
.profile-qr-actions .btn {
  font-size: .78rem;
  padding: .35rem .55rem;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.qr-card .qr-body {
  display: grid;
  gap: .75rem;
  justify-items: center;
  padding: .25rem .25rem 1rem;
}
.qr-card canvas {
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.qr-card #qrLink {
  width: 100%;
  text-align: center;
  font-size: .82rem;
}
.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  width: 100%;
}
.qr-actions .btn { flex: 1; min-width: 140px; }

.reviews-block {
  padding: 0 1rem 1rem;
}
.reviews-block h4 {
  margin: 0 0 .65rem;
  font-size: .9rem;
  color: var(--muted);
}
.review-form {
  display: grid;
  gap: .55rem;
  margin-bottom: .85rem;
  padding: .85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.star-picker {
  display: flex;
  justify-content: center;
  gap: .15rem;
}
.star-picker button {
  border: 0;
  background: transparent;
  color: rgba(128,128,128,.35);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  padding: .1rem .2rem;
}
.star-picker button.on { color: #d4a017; }
.review-form textarea.field-input {
  resize: vertical;
  min-height: 64px;
}
.btn.sm { padding: .45rem .85rem; font-size: .86rem; }
.reviews-list { display: grid; gap: .65rem; }
.review-item {
  padding: .7rem .8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  text-align: left;
}
.review-item p {
  margin: .35rem 0 .25rem;
  line-height: 1.4;
  font-size: .92rem;
}
.review-item time { font-size: .75rem; }
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.review-author {
  border: 0;
  background: none;
  color: var(--text);
  font-weight: 600;
  font-size: .88rem;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.review-empty { padding: .35rem 0 .5rem; font-size: .88rem; }

html[data-theme="light"] .review-form,
html[data-theme="light"] .review-item {
  background: rgba(255,255,255,.72);
}

html[data-theme="light"] .market-card,
html[data-theme="light"] .market-row {
  background: rgba(255,255,255,.88);
}
html[data-theme="light"] .media-panel,
html[data-theme="light"] .modal-card,
html[data-theme="light"] .drawer-sheet,
html[data-theme="light"] .attach-sheet-panel,
html[data-theme="light"] .msg-actions,
html[data-theme="light"] .auth-card {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border);
}
html[data-theme="light"] .listing-modal .field-input,
html[data-theme="light"] .modal-form .field-input,
html[data-theme="light"] .modal-card .field-input,
html[data-theme="light"] .field-input,
html[data-theme="light"] .auth-form input,
html[data-theme="light"] .search,
html[data-theme="light"] .composer-shell,
html[data-theme="light"] .composer-field,
html[data-theme="light"] .chat-search-bar input,
html[data-theme="light"] .gif-search-wrap,
html[data-theme="light"] .chip-select .chip:not(.active) {
  background-color: var(--field-bg);
  border-color: rgba(20, 60, 40, .12);
}
html[data-theme="light"] .listing-modal select.field-input,
html[data-theme="light"] .modal-form select.field-input,
html[data-theme="light"] .modal-card select.field-input,
html[data-theme="light"] select.field-input,
html[data-theme="light"] .modal-card select {
  background-color: var(--field-bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
html[data-theme="light"] .chip-select .chip:not(.active) {
  color: #3d5c4c;
}
html[data-theme="light"] .msg .author { color: #1f7a52; }
html[data-theme="light"] .profile-card {
  background: rgba(255,255,255,.75);
}
html[data-theme="light"] .msg .reply-quote {
  border-left-color: rgba(31,138,88,.45);
}
html[data-theme="light"] .profile-bg {
  background: linear-gradient(145deg, #3aa873, #1f8a58 55%, #176b44);
}
html[data-theme="light"] .settings-group {
  background: rgba(255,255,255,.72);
}
html[data-theme="light"] .setting-card {
  background: #fff;
  box-shadow: 0 6px 18px rgba(18, 50, 35, .06);
}
html[data-theme="light"] .reply-bar.is-edit .reply-bar-body strong { color: #b87a18; }
html[data-theme="light"] .reply-bar.is-edit .reply-bar-body { border-left-color: #c9922a; }

.avatar.channel {
  margin-bottom: 0;
  display: grid; place-items: center;
}
.avatar.channel .ico { color: #fff; width: 18px; height: 18px; }
