: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: 58px;
  --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;
  /* Floating dock: sit on the physical bottom. Do NOT add full safe-area
     here — iOS PWA visual viewport already accounts for the home indicator,
     so env(safe-area-inset-bottom) double-counts and lifts the menu. */
  --dock-bottom: 8px;
  --dock-vv-inset: 0px;
  --dock-space: calc(var(--nav-h) + 16px + var(--dock-bottom));
  --kb-inset: 0px;
  --kb-overlap: 0px;
  --composer-stack-h: 72px;
  --pattern: url('/app/img/fone-tile.png');
  --pattern-size: 32px auto;
  --pattern-opacity: .1;
  --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;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
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 {
  position: fixed;
  inset: 0;
  width: 100%;
  /* lvh = layout size, does not shrink when the keyboard opens */
  height: 100%;
  height: 100dvh;
  height: 100lvh;
  min-height: 100lvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  background: var(--auth-grad);
  z-index: 200;
  box-sizing: border-box;
}
html.auth-open,
html.auth-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}
.auth-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  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: contain;
  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; }
.pwd-field {
  position: relative;
  display: block;
}
.pwd-field input {
  width: 100%;
  padding-right: 3rem !important;
}
.pwd-toggle {
  position: absolute;
  right: .35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.pwd-toggle:hover { color: var(--text); }
.pwd-toggle .ico { width: 20px; height: 20px; }
.auth-credit {
  margin: 1.1rem 0 0;
  text-align: center;
  line-height: 1.4;
}
.auth-credit a {
  color: var(--accent-mint, var(--green));
  text-decoration: none;
  font-weight: 650;
}
.auth-credit a:hover { text-decoration: underline; }
.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: 14px;
  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: 1px solid var(--glass-border);
  background:
    linear-gradient(180deg, rgba(255,255,255,.16), transparent 55%),
    var(--glass-bg);
  cursor: pointer; color: var(--text);
  display: grid; place-items: center; flex: 0 0 auto;
  font-size: 1.1rem; line-height: 1;
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  box-shadow: var(--glass-highlight), 0 4px 14px rgba(0,0,0,.08);
  transition: background .18s var(--spring), transform .16s var(--spring), border-color .18s ease, box-shadow .18s ease;
}
.icon-btn:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,.22), transparent 55%),
    var(--soft-fill);
  border-color: rgba(47,158,107,.35);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.flat,
.settings-nav .icon-btn,
.modal-card header .icon-btn,
.media-panel-head .icon-btn {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.icon-btn.flat:hover,
.settings-nav .icon-btn:hover,
.modal-card header .icon-btn:hover,
.media-panel-head .icon-btn:hover {
  background: var(--soft-fill) !important;
  border-color: transparent !important;
  color: var(--text);
}
html[data-theme="light"] .icon-btn.flat,
html[data-theme="light"] .settings-nav .icon-btn,
html[data-theme="light"] .modal-card header .icon-btn,
html[data-theme="light"] .media-panel-head .icon-btn {
  background: transparent !important;
  box-shadow: none !important;
}
html[data-theme="light"] .icon-btn {
  background:
    linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.35) 55%),
    rgba(255,255,255,.55);
  border-color: rgba(31,138,88,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 4px 14px rgba(18,50,35,.06);
}
html[data-theme="light"] .icon-btn:hover {
  background:
    linear-gradient(180deg, #fff, rgba(255,255,255,.5) 55%),
    rgba(232,246,238,.9);
}
.search {
  flex: 1; min-width: 0; height: 36px; padding: 0 .9rem;
  border-radius: 12px; background: var(--field-bg); border: 1px solid var(--line);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}

.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: .7rem;
  padding: .72rem .9rem;
  cursor: pointer;
  min-height: 64px;
  border-bottom: 1px solid transparent;
  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.support-chat .avatar.channel {
  background: linear-gradient(145deg, #1f8a58, #0d3d28);
  color: #b7f0d0;
}
.chat-item.support-chat .preview {
  color: var(--accent-mint, var(--green));
  opacity: .85;
}
.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 — pinned to visual bottom; do not override `bottom` ad-hoc */
.bottom-nav {
  display: none;
  position: fixed;
  left: max(10px, env(safe-area-inset-left, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: 8px;
  height: 58px;
  min-height: 58px;
  padding: 4px;
  box-sizing: border-box;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 28px;
  /* Opaque dock — heavy blur smears / shifts chrome on newer iOS PWAs */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:
    0 12px 40px rgba(0,0,0,.28),
    0 2px 8px rgba(0,0,0,.12),
    inset 0 1px 0 rgba(255,255,255,.12);
  z-index: 100;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  max-width: 440px;
  margin: 0 auto;
  gap: 0;
  overflow: hidden;
  isolation: auto;
  transform: none;
}
.bottom-nav .nav-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 25%;
  border-radius: 22px;
  pointer-events: none;
  z-index: 0;
  background: var(--green-soft);
  border: 1px solid rgba(47,158,107,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition:
    transform .42s cubic-bezier(.22, 1, .36, 1),
    width .42s cubic-bezier(.22, 1, .36, 1),
    opacity .2s ease;
  will-change: transform, width;
}
html[data-theme="light"] .bottom-nav {
  background: #ffffff;
  border-color: rgba(20, 60, 40, .12);
  box-shadow:
    0 12px 36px rgba(18, 50, 35, .14),
    0 2px 8px rgba(18, 50, 35, .06);
}
html[data-theme="light"] .bottom-nav .nav-pill {
  display: block !important;
  background: rgba(31,138,88,.12);
  border-color: rgba(31,138,88,.22);
  box-shadow: none;
}
.bottom-nav button {
  border: 0; background: transparent;
  color: var(--nav-idle, #8a9a90);
  display: grid;
  justify-items: center;
  align-content: center;
  grid-template-rows: 28px auto;
  gap: .15rem;
  font-size: .62rem; font-weight: 600; cursor: pointer;
  padding: .2rem 0 .15rem;
  min-width: 0;
  transition: color .22s ease, transform .16s 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.1;
  height: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .28s var(--spring), font-weight .28s ease, opacity .28s ease;
  opacity: .8;
  white-space: nowrap;
}
.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(.94);
}
.bottom-nav .nav-ico {
  width: 34px; height: 28px;
  display: grid; place-items: center;
  border-radius: 12px;
  transition: transform .38s var(--spring), filter .28s ease;
}
.bottom-nav button.active .nav-ico {
  background: transparent;
  box-shadow: none;
  transform: translateY(-0.5px) scale(1.04);
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.2));
}
html[data-theme="light"] .bottom-nav button.active .nav-ico {
  background: transparent;
  box-shadow: none;
}
.bottom-nav .nav-ico .ico {
  width: 26px; height: 26px;
}
.bottom-nav .nav-ico-avatar {
  width: 34px;
  height: 30px;
}
.bottom-nav .nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #245c43;
  display: grid;
  place-items: center;
  font-size: .7rem;
  font-weight: 700;
  border: 0;
  box-sizing: border-box;
  overflow: hidden;
  flex: 0 0 auto;
  color: #fff;
  line-height: 1;
  transition: box-shadow .28s var(--spring), transform .38s var(--spring);
}
.bottom-nav button.active .nav-avatar {
  box-shadow: 0 0 0 2px var(--nav-active, #2f9e6b);
  transform: scale(1.04);
}
.bottom-nav .nav-slot {
  position: relative;
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
}
.bottom-nav .nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e25b5b;
  color: #fff;
  font-size: .62rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 0 2px var(--panel);
}
.bottom-nav.hidden { display: none !important; }
.bottom-nav .nav-badge.hidden {
  display: none !important;
}

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-list-empty {
  padding: 1.35rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}
.thread-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .45rem;
  padding: 2rem 1.35rem;
  margin: auto;
  max-width: 300px;
  min-height: min(42vh, 320px);
  color: var(--text);
}
.thread-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--accent-mint);
  margin-bottom: .25rem;
}
.thread-empty strong {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.thread-empty p {
  margin: 0;
  font-size: .88rem;
  line-height: 1.45;
  color: var(--muted);
}
.messages.is-empty {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.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;
}
/* DM chats keep wallpaper pattern */
.chat-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--pattern);
  background-size: var(--pattern-size, 340px auto);
  background-position: center top;
  background-repeat: repeat;
  opacity: var(--wp-pattern-opacity, var(--pattern-opacity));
  filter: var(--wp-pattern-filter, none);
  pointer-events: none;
  z-index: 0;
}
/* Flood / general chat: same wallpaper system as DMs (splash + tile) */
.flood-view {
  background-color: #0a1c14;
}
html[data-theme="light"] .flood-view {
  background-color: #dceee4;
}
html[data-theme="light"] .flood-view::before {
  --wp-pattern-opacity: .2;
  --wp-pattern-filter: invert(1) brightness(.55) contrast(1.15);
}
.flood-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--pattern);
  background-size: var(--pattern-size, 340px auto);
  background-position: center top;
  background-repeat: repeat;
  opacity: var(--wp-pattern-opacity, .16);
  filter: var(--wp-pattern-filter, none);
  pointer-events: none;
  z-index: 0;
}
.market-view {
  background: var(--panel);
  background-color: var(--panel);
}
.chat-view.wp-tone-light::before,
.flood-view.wp-tone-light::before {
  /* light bg → dark fone.png, flipped + stretched to chat */
  background-image: url('/app/img/fone.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: invert(1);
  opacity: .1;
  transform: scaleX(-1);
  transform-origin: center center;
}
.chat-view.wp-tone-dark::before,
.flood-view.wp-tone-dark::before {
  background-image: url('/app/img/fone.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: none;
  opacity: .12;
  transform: scaleX(-1);
  transform-origin: center center;
}
.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 !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}
/* Dark brand presets: keep dark base color from JS + fone.png once (light), dim */
.chat-view.has-splash-bg,
.flood-view.has-splash-bg {
  background-image: none !important;
}
.chat-view.has-splash-bg::before,
.flood-view.has-splash-bg::before {
  display: block;
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/app/img/fone.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: none;
  opacity: .12;
  transform: scaleX(-1);
  transform-origin: center center;
  pointer-events: none;
  z-index: 0;
}
.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: 6;
  overflow: visible;
}
.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;
}
/* Flat header icons — no glass tiles */
.chat-header .icon-btn,
.sidebar-header .icon-btn,
.flood-view .chat-header .icon-btn,
.market-view .chat-header .icon-btn {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: var(--muted);
}
.chat-header .icon-btn:hover,
.sidebar-header .icon-btn:hover {
  background: transparent !important;
  color: var(--text);
}
.chat-header .icon-btn:active,
.sidebar-header .icon-btn:active {
  transform: scale(.92);
  background: transparent !important;
}
.chat-header .icon-btn.active {
  background: transparent !important;
  color: var(--accent-mint);
}
.chat-header-meta strong {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: .95rem;
}
.chat-header-meta .muted,
#peerStatus {
  font-size: .72rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}
.flood-members-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: .72rem;
  line-height: 1.2;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  max-width: min(52vw, 220px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .18s ease;
}
.flood-members-btn:hover { color: var(--accent-mint); }
.flood-members-btn:active { opacity: .85; }
.flood-members-list { padding: 0 .15rem .35rem; max-height: min(62vh, 520px); }
.flood-member-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .45rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background .16s ease;
}
.flood-member-row:hover { background: var(--soft-fill); }
.flood-member-row .avatar { flex: 0 0 auto; }
.flood-member-meta { flex: 1; min-width: 0; }
.flood-member-meta strong {
  display: block;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flood-member-meta .muted {
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flood-member-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(47, 158, 107, .18);
  flex: 0 0 auto;
}

/* 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 {
  display: flex;
  flex-direction: column;
  width: max-content;
  max-width: min(78%, 480px);
  margin: .28rem 0;
  margin-right: auto;
  padding: .45rem .7rem .32rem;
  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;
  flex: 0 1 auto;
  min-width: 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;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
  font-size: .95rem;
  width: auto;
  max-width: 100%;
}
.msg.emoji-only .text {
  font-size: 1.7rem;
  line-height: 1.25;
  padding: .05rem .1rem;
  overflow: visible;
}
.msg .time {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .3rem;
  align-self: flex-end;
  width: auto;
  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: .28rem; margin-top: .35rem;
}
.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.react-chip {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  padding: 2px 8px 2px 3px;
  min-height: 26px;
  line-height: 1;
}
.reactions button.react-chip.mine {
  border-color: rgba(47,158,107,.55);
  background: var(--green-soft);
}
.react-stack {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
}
.react-av {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-left: -6px;
  box-shadow: 0 0 0 1.5px var(--panel);
  overflow: visible;
  flex: 0 0 auto;
  background: #245c43;
}
.react-stack .react-av:first-child { margin-left: 0; }
.react-av img,
.react-av .av {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: .55rem;
  font-weight: 800;
  color: #fff;
}
.react-av .react-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-size: .62rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
  pointer-events: none;
}
.react-chip .react-meta {
  display: inline-flex;
  align-items: center;
  gap: .18rem;
  font-weight: 800;
  font-size: .78rem;
}
.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; }
.dm-block-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
  padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--glass-border);
  background: var(--composer-bg);
  color: var(--muted);
  font-size: .88rem;
  text-align: center;
  flex: 0 0 auto;
}
.dm-block-bar .btn { flex: 0 0 auto; }
#chatView.is-blocked .composer-stack,
#chatView.is-blocked #quickReplies {
  display: none !important;
}
.composer-stack {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 30;
  background: var(--panel);
}
.composer-media-draft {
  flex: 0 0 auto;
  padding: .55rem .65rem 0;
  border-top: 1px solid var(--glass-border);
  background: var(--composer-bg);
}
.composer-media-draft.hidden { display: none !important; }
.composer-media-list {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: .45rem;
}
.composer-media-list::-webkit-scrollbar { display: none; }
.composer-media-item {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
}
.composer-media-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel-3) center / cover no-repeat;
  border: 1px solid var(--line);
}
.composer-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.composer-media-progress {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.composer-media-progress-bg {
  fill: rgba(0, 0, 0, .38);
  stroke: rgba(255, 255, 255, .18);
  stroke-width: 3;
}
.composer-media-progress-fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset .12s ease;
}
.composer-media-item.is-error .composer-media-thumb {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(226, 91, 91, .35);
}
.composer-media-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(18, 24, 22, .88);
  color: #fff;
  font-size: .95rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
  z-index: 2;
}
.composer-media-remove:active { transform: scale(.94); }
.composer-media-item.is-uploading .composer-media-remove {
  opacity: .92;
}
.composer {
  --composer-ctrl: 40px;
  display: flex;
  align-items: flex-end;
  gap: .3rem;
  padding: .45rem .5rem;
  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-tools,
.composer-actions {
  display: flex;
  align-items: flex-end;
  gap: 0;
  flex: 0 0 auto;
}
.composer-tool,
.icon-btn.composer-tool,
.composer .send-btn {
  width: var(--composer-ctrl);
  height: var(--composer-ctrl);
  min-width: var(--composer-ctrl);
  min-height: var(--composer-ctrl);
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  align-self: flex-end;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}
.composer-tools .composer-tool {
  width: 34px;
  min-width: 34px;
}
/* Flat composer tools — no glass tiles */
.composer-tool,
.icon-btn.composer-tool {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: var(--muted);
}
.composer-tool:hover,
.icon-btn.composer-tool:hover {
  background: transparent !important;
  color: var(--text);
  border-color: transparent !important;
}
.composer-tool:active,
.icon-btn.composer-tool:active {
  transform: scale(.9);
  background: transparent !important;
}
.composer-shell {
  flex: 1;
  min-width: 0;
  align-self: flex-end;
  display: flex;
  align-items: stretch;
  min-height: var(--composer-ctrl);
  background-color: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.composer-shell textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  box-sizing: border-box;
  min-height: calc(var(--composer-ctrl) - 2px);
  max-height: 140px;
  padding: 11px 14px;
  line-height: 1.25;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
}
.composer-field {
  flex: 1; min-width: 0;
  border: 1px solid var(--glass-border);
  background: var(--field-bg);
  border-radius: 14px;
  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: 140px; padding: 11px 14px; outline: none;
  line-height: 1.25; min-height: 42px;
  font-size: 16px;
}

.cc-picker {
  position: relative;
  margin-right: .15rem;
  z-index: 1;
}
.cc-picker:has(.cc-picker-menu:not(.hidden)) {
  z-index: 30;
}
.cc-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  max-width: min(44vw, 176px);
  min-height: 36px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text);
  border-radius: 12px;
  padding: .4rem .7rem .4rem .62rem;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.cc-picker-btn:hover,
.cc-picker-btn[aria-expanded="true"] {
  border-color: rgba(47,158,107,.45);
  background: var(--green-soft);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.cc-picker-ico {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--green);
}
.cc-picker-ico .ico { width: 15px; height: 15px; }
.cc-picker-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.cc-picker-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-left: .05rem;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform .18s ease;
}
.cc-picker-btn[aria-expanded="true"] .cc-picker-caret {
  transform: rotate(180deg);
}
.cc-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: min(72vw, 248px);
  max-height: min(52vh, 340px);
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 80;
  padding: .35rem;
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}
.cc-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .58rem;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: .62rem .72rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  transition: background .16s ease, color .16s ease;
}
.cc-picker-item:hover { background: var(--green-soft); }
.cc-picker-item.active {
  background: rgba(46,168,110,.14);
  color: var(--accent-mint);
}
.cc-picker-item-ico {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--green);
}
.cc-picker-item-ico .ico { width: 16px; height: 16px; }
.cc-picker-item.active .cc-picker-item-ico { color: var(--accent-mint); }
.cc-picker-item-label {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.cc-picker-item-pin,
.cc-picker-item-check {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  opacity: .72;
}
.cc-picker-btn-unread,
.cc-picker-item-unread {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .35);
}
.cc-picker-btn-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: .62rem;
  margin-left: .05rem;
}
.cc-picker-btn-unread.hidden {
  display: none;
}
.cc-picker-item-unread {
  min-width: 22px;
  height: 22px;
  font-size: .72rem;
}
.cc-picker-item-check { color: var(--accent-mint); opacity: 1; }
.cc-picker-item-pin .ico,
.cc-picker-item-check .ico { width: 12px; height: 12px; }

.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;
}

.topic-bar {
  display: flex; gap: .4rem; overflow-x: auto; padding: .45rem .7rem;
  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;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent);
}
.topic-bar::-webkit-scrollbar { display: none; }
.topic-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--muted);
  border-radius: 999px;
  padding: .42rem .85rem;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background .18s var(--spring), color .18s ease, border-color .18s ease, transform .16s var(--spring);
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}
.topic-chip:active { transform: scale(.96); }
.topic-chip.topic-all {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: 4px 0 12px rgba(0,0,0,.18);
}
.topic-chip.active, .topic-chip:hover {
  background: var(--green-soft); color: var(--text); border-color: rgba(47,158,107,.45);
}
.topic-chip.topic-all.active {
  background: var(--green);
  color: #fff;
  border-color: transparent;
}
.topic-chip.topic-all.active .ico { color: #fff; }
.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 {
  --tick-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath fill='%23000' d='M3.9 9.4.4 5.9l1.2-1.2 2.3 2.3L10.4.5l1.2 1.2z'/%3E%3C/svg%3E");
  position: relative;
  display: inline-block;
  width: .72em;
  height: .7em;
  margin-left: .28em;
  vertical-align: -0.08em;
  flex: 0 0 auto;
}
.msg .ticks.read {
  width: 1.05em;
  color: #8ef0bc;
}
.msg .ticks.delivered,
.msg .ticks.sent {
  color: currentColor;
  opacity: .72;
}
.msg .ticks i {
  position: absolute;
  top: 0;
  left: 0;
  width: .72em;
  height: .7em;
  background-color: currentColor;
  -webkit-mask: var(--tick-mask) center / contain no-repeat;
  mask: var(--tick-mask) center / contain no-repeat;
}
.msg .ticks i + i {
  left: .32em;
}
.msg .ticks.read i:first-child {
  opacity: .92;
}
html[data-theme="light"] .msg .ticks.read {
  color: #1a9a5c;
}
html[data-theme="light"] .msg.out .ticks.delivered,
html[data-theme="light"] .msg.out .ticks.sent {
  color: rgba(18, 50, 35, .55);
  opacity: 1;
}

/* Chat list preview ticks */
.chat-item .ticks {
  --tick-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath fill='%23000' d='M3.9 9.4.4 5.9l1.2-1.2 2.3 2.3L10.4.5l1.2 1.2z'/%3E%3C/svg%3E");
  position: relative;
  display: inline-block;
  width: .72em;
  height: .7em;
  margin-right: .2em;
  vertical-align: -0.06em;
  color: var(--muted);
}
.chat-item .ticks.read {
  width: 1.05em;
  color: var(--green);
}
.chat-item .ticks i {
  position: absolute;
  top: 0;
  left: 0;
  width: .72em;
  height: .7em;
  background-color: currentColor;
  -webkit-mask: var(--tick-mask) center / contain no-repeat;
  mask: var(--tick-mask) center / contain no-repeat;
}
.chat-item .ticks i + i {
  left: .32em;
}
.msg .edited { font-size: .68rem; opacity: .65; margin-right: .2rem; }
.msg.sending { opacity: .65; }
.msg {
  position: relative;
}
.msg .msg-select-tick {
  display: none;
}
html.msg-selecting .msg .msg-select-tick {
  display: grid;
  place-items: center;
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  background: transparent;
  box-sizing: border-box;
}
.msg.out .msg-select-tick { left: auto; right: -22px; }
html.msg-selecting .msg.is-selected .msg-select-tick {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 2px var(--panel);
}
html.msg-selecting .msg.is-selected {
  outline: 2px solid rgba(47,158,107,.45);
  outline-offset: 2px;
}
.msg.is-reply-target {
  position: relative;
  box-shadow:
    0 0 0 2px rgba(62, 207, 142, .55),
    0 10px 28px rgba(47, 158, 107, .22);
  background-image: linear-gradient(
    135deg,
    rgba(62, 207, 142, .22),
    rgba(62, 207, 142, .08) 55%,
    transparent
  );
  animation: replyTargetPulse 1.1s var(--spring);
}
.msg.out.is-reply-target {
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, .16),
    rgba(62, 207, 142, .18) 50%,
    transparent
  );
}
@keyframes replyTargetPulse {
  0% { transform: scale(.985); filter: brightness(1.08); }
  55% { transform: scale(1.015); filter: brightness(1.12); }
  100% { transform: none; filter: none; }
}
html[data-theme="light"] .msg.is-reply-target {
  box-shadow:
    0 0 0 2px rgba(31, 138, 88, .4),
    0 8px 22px rgba(31, 138, 88, .14);
  background-image: linear-gradient(
    135deg,
    rgba(31, 138, 88, .16),
    rgba(31, 138, 88, .06) 55%,
    transparent
  );
}
.msg.is-pinned {
  position: relative;
  box-shadow:
    0 0 0 2px rgba(224, 168, 74, .55),
    0 10px 26px rgba(224, 168, 74, .18);
  background-image: linear-gradient(
    135deg,
    rgba(224, 168, 74, .2),
    rgba(224, 168, 74, .07) 55%,
    transparent
  );
}
.msg.out.is-pinned {
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, .12),
    rgba(224, 168, 74, .16) 50%,
    transparent
  );
}
.msg.is-pinned::before {
  content: '';
  position: absolute;
  top: .45rem;
  right: .55rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0a84a;
  box-shadow: 0 0 0 3px rgba(224, 168, 74, .25);
  pointer-events: none;
  z-index: 2;
}
.msg.out.is-pinned::before {
  right: auto;
  left: .55rem;
}
html[data-theme="light"] .msg.is-pinned {
  box-shadow:
    0 0 0 2px rgba(184, 122, 24, .4),
    0 8px 20px rgba(184, 122, 24, .12);
  background-image: linear-gradient(
    135deg,
    rgba(224, 168, 74, .18),
    rgba(224, 168, 74, .06) 55%,
    transparent
  );
}
html[data-theme="light"] .msg.is-pinned::before {
  background: #c9922a;
}
html.msg-selecting .messages {
  padding-left: 1.65rem;
  padding-right: 1.65rem;
}
html.msg-selecting .composer-stack,
html.msg-selecting .quick-replies,
html.msg-selecting .typing {
  visibility: hidden;
  pointer-events: none;
}
.msg-select-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem calc(.55rem + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,.18);
}
.msg-select-bar.hidden { display: none !important; }
.msg-select-bar strong { flex: 1; font-size: .95rem; }
.msg-select-actions { display: flex; gap: .2rem; }
.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:
    radial-gradient(90% 120% at 50% 0%, rgba(62, 207, 142, .28), transparent 60%),
    linear-gradient(145deg, #1b4d36 0%, #0f2a1e 55%, #0a1c14 100%);
  background-repeat: no-repeat;
}
html[data-theme="light"] .profile-bg {
  background:
    radial-gradient(90% 120% at 50% 0%, rgba(31, 138, 88, .22), transparent 60%),
    linear-gradient(145deg, #2f9e6b 0%, #1f7a52 55%, #176b44 100%);
}
.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-identity {
  display: grid;
  justify-items: center;
  gap: .2rem;
  padding: .15rem 0 .35rem;
}
.profile-panel h2 {
  margin: 0;
  padding: 0 .5rem;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  font-weight: 750;
  text-align: center;
  width: 100%;
}
.profile-nick {
  display: block;
  margin: 0 auto;
  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-field-label {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin: 0 0 .35rem;
}
.profile-about {
  margin: .65rem 0 .35rem;
  padding: 0 .35rem;
}
.profile-panel .bio {
  margin: 0;
  padding: 0 .5rem;
  color: var(--text);
  font-size: .92rem;
  line-height: 1.45;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}
.profile-panel .bio a {
  color: var(--accent-mint);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.profile-panel .bio.is-empty { color: var(--muted); }
.profile-phone {
  margin: .55rem 0 .25rem;
  padding: 0 .35rem;
  text-align: center;
}
.profile-phone.hidden { display: none !important; }
.profile-phone-value {
  display: inline-block;
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  text-decoration: none;
  letter-spacing: .01em;
}
.profile-phone-value:hover { color: var(--accent-mint); }
.bio-counter {
  display: block;
  text-align: right;
  font-size: .72rem;
  color: var(--muted);
  margin-top: .25rem;
}
.bio-counter.is-limit { color: #e74c3c; }
.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));
  transition: transform .32s var(--spring), padding-bottom .24s var(--spring);
}
.drawer-user {
  display: flex; flex-direction: column; gap: .35rem; align-items: center;
  text-align: center;
  padding: 1rem .75rem 1.15rem; border-bottom: 0;
  margin-bottom: .35rem;
  flex: 0 0 auto;
}
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 .75rem .65rem;
  padding: .15rem;
  border-radius: 16px;
  background: var(--soft-fill-2);
  border: 1px solid var(--line);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible;
  flex: 0 0 auto;
  min-height: min-content;
}
.settings-view > .settings-group:last-child {
  margin-top: .35rem;
  margin-bottom: 1rem;
}
.settings-row,
.settings-view > .settings-row {
  text-align: left; border: 0; background: transparent;
  padding: .75rem .75rem; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; gap: .85rem;
  color: var(--text); font: inherit; width: 100%;
  border-bottom: 0;
  min-height: 58px;
  height: auto;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.settings-group .settings-row + .settings-row,
.settings-group .theme-row + .settings-row,
.settings-group .settings-row + .theme-row,
.settings-group .theme-row + .theme-row {
  box-shadow: inset 0 1px 0 var(--line);
}
.settings-group .settings-row:last-child { border-bottom: 0; }
.settings-row:hover { background: rgba(47,158,107,.1); }
.settings-row:active { background: rgba(47,158,107,.14); }
.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-section-title {
  margin: .35rem 0 .15rem;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-callout {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .85rem .9rem;
  border-radius: 16px;
  border: 1px solid rgba(47, 158, 107, .22);
  background: rgba(47, 158, 107, .08);
  color: var(--text);
  font-size: .86rem;
  line-height: 1.45;
}
.settings-callout .settings-note-ico {
  flex: 0 0 auto;
  margin-top: .05rem;
  color: var(--accent-mint);
}
.settings-steps {
  display: grid;
  gap: .55rem;
  margin: .25rem 0 .15rem;
}
.settings-step {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .75rem .85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.settings-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 800;
  background: var(--green-soft);
  color: var(--accent-mint);
}
.settings-step-copy {
  display: grid;
  gap: .15rem;
  min-width: 0;
}
.settings-step-copy strong {
  font-size: .9rem;
  color: var(--text);
}
.settings-step-copy span {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.35;
}
.coinclub-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 16px;
  padding: .9rem;
  display: grid;
  gap: .65rem;
}
.coinclub-card.is-linked {
  border-color: rgba(47, 158, 107, .28);
  background: linear-gradient(180deg, rgba(47,158,107,.08), var(--panel-2));
}
.coinclub-card-head {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.coinclub-card-head .settings-ico { flex: 0 0 auto; }
.coinclub-card-meta {
  display: grid;
  gap: .12rem;
  min-width: 0;
}
.coinclub-card-meta strong {
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coinclub-card-meta span,
.coinclub-card-meta a {
  font-size: .78rem;
  color: var(--muted);
  word-break: break-all;
}
.coinclub-card-meta a { color: var(--accent-mint); text-decoration: none; }
.coinclub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .15rem;
}
.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%; min-height: 0; }
.settings-page-bar {
  display: none;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
  padding: .15rem 0 .55rem;
  margin: 0 0 .15rem;
  border-bottom: 1px solid var(--line);
}
.settings-page-bar strong {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.settings-page-bar-spacer {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}
.settings-nav {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem 0 .8rem; border-bottom: 1px solid var(--line);
  margin-bottom: .5rem;
  flex: 0 0 auto;
}
.settings-body { overflow: auto; display: grid; gap: .85rem; padding-bottom: .5rem; }
.settings-view {
  display: flex; flex-direction: column; gap: .15rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 1.25rem;
  transition: padding-bottom .24s var(--spring);
}
.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: .45rem;
}
.admin-search-row .field-input { flex: 1; min-width: 0; }
.admin-users-meta { margin: 0 0 .55rem; min-height: 1.1em; }
.admin-section-title {
  margin: 1.1rem 0 .45rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.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: .55rem;
}
.admin-user-head { display: grid; gap: .45rem; }
.admin-user-open {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  min-width: 0;
}
.admin-user-copy { display: grid; gap: .12rem; min-width: 0; }
.admin-user-open strong { font-size: .95rem; }
.admin-user-open .muted {
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-chip-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.admin-chip {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--soft-fill);
  color: var(--muted);
}
.admin-chip.ok { color: #7dcea0; border-color: rgba(125,206,160,.3); background: rgba(125,206,160,.1); }
.admin-chip.danger { color: #f0a0a0; border-color: rgba(240,160,160,.35); background: rgba(240,160,160,.12); }
.admin-chip.warn { color: #e0b45a; border-color: rgba(224,180,90,.35); background: rgba(224,180,90,.12); }
.admin-chip.role-admin { color: #f0a0a0; border-color: rgba(240,160,160,.35); background: rgba(240,160,160,.12); }
.admin-chip.role-moderator { color: #c4a0f0; border-color: rgba(196,160,240,.35); background: rgba(196,160,240,.12); }
.admin-badge-block { display: grid; gap: .35rem; }
.admin-badge-edit { margin: 0; }
.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(--panel);
  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: none;
  -webkit-backdrop-filter: none;
}
.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(auto-fill, minmax(2.6rem, 1fr));
  gap: .3rem;
  padding: .65rem .7rem calc(.75rem + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-gutter: stable;
}
.emoji-grid button {
  font-size: 1.55rem;
  line-height: 1.15;
  border: 0;
  background: var(--panel-3);
  padding: .3rem;
  min-width: 0;
  min-height: 2.55rem;
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: visible;
}
.emoji-grid button:hover { background: var(--soft-fill); }
.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 {
  padding: .4rem .55rem .28rem;
}
.msg.sticker-bubble .sticker-msg {
  font-size: 2.6rem;
  line-height: 1.1;
  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: .5rem .75rem .6rem;
  position: relative;
  z-index: 8;
  overflow: visible;
}
.market-picker-row {
  display: flex;
  align-items: stretch;
  gap: .4rem;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}
.market-picker {
  margin-right: 0;
  flex: 1 1 0;
  min-width: 0;
}
.market-picker .cc-picker-btn,
.market-filter-toggle-btn {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 34px;
  box-sizing: border-box;
  gap: clamp(.22rem, 1.2vw, .42rem);
  padding: .36rem clamp(.42rem, 2vw, .7rem) .36rem clamp(.4rem, 1.8vw, .62rem);
  font-size: clamp(.68rem, 2.6vw, .78rem);
}
.market-picker .cc-picker-label,
.market-filter-toggle-btn .cc-picker-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.market-filter-toggle-btn {
  flex: 1 1 0;
  margin-right: 0;
  justify-content: center;
}
.market-filter-toggle-btn.active,
.market-filter-toggle-btn[aria-expanded="true"] {
  border-color: rgba(47,158,107,.45);
  background: var(--green-soft);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.cc-picker-menu.left {
  left: 0;
  right: auto;
}
#marketFilterBtn.active { background: var(--green-soft); color: var(--text); }
.market-filter-panel {
  display: grid; gap: .55rem;
  padding: .7rem 0 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-desc {
  margin: 0;
  font-size: .72rem;
  line-height: 1.35;
  color: var(--muted);
  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); }
.market-del-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  background: rgba(220, 70, 70, .12);
  color: #e86a6a;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.market-del-btn:hover { background: rgba(220, 70, 70, .22); }
.market-del-btn .ico { width: 15px; height: 15px; margin: 0; }
.market-del-btn.on-photo {
  position: absolute;
  top: .4rem;
  left: .4rem;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .5);
  color: #ff8b8b;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.market-del-btn.on-photo:hover {
  background: rgba(180, 40, 40, .85);
  color: #fff;
}
.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; bottom: .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-view-price .listing-status-badge,
.listing-view-price-row .listing-status-badge,
.market-meta .listing-status-badge {
  position: static;
  display: inline-flex;
  vertical-align: middle;
  margin-left: .35rem;
  background: rgba(47, 158, 107, .18);
  color: var(--text);
}
.listing-view-price .listing-status-badge.status-reserved,
.listing-view-price-row .listing-status-badge.status-reserved {
  background: rgba(201, 133, 26, .22);
}
.listing-view-price .listing-status-badge.status-sold,
.listing-view-price-row .listing-status-badge.status-sold {
  background: rgba(138, 58, 58, .22);
}
.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: 440px; width: min(440px, 96vw); overflow-x: hidden; }
.listing-view-modal > header {
  padding-bottom: .35rem;
  align-items: flex-start;
}
.listing-view-modal > header h3 {
  font-size: 1.05rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.listing-view-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  max-height: min(78vh, 820px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  z-index: 1;
}
.listing-view-content {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  position: relative;
  z-index: 2;
  background: transparent;
}
.listing-view-carousel {
  position: relative;
  margin: 0;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0,0,0,.22);
  aspect-ratio: 1 / 1;
  min-height: 220px;
  max-height: min(70vw, 420px);
  touch-action: pan-y;
  user-select: none;
  flex: 0 0 auto;
  z-index: 1;
}
.listing-view-carousel--empty {
  display: grid;
  place-items: center;
}
.listing-view-track {
  position: absolute;
  inset: 0;
  display: flex;
  height: 100%;
  width: 100%;
  transition: transform .28s cubic-bezier(.22,1,.36,1);
  will-change: transform;
  backface-visibility: hidden;
  z-index: 0;
}
.listing-view-slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  cursor: zoom-in;
  background-size: cover;
  background-position: center;
  background-color: rgba(0,0,0,.15);
  flex-shrink: 0;
}
.listing-view-slide.is-empty {
  cursor: default;
  opacity: .35;
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
}
.listing-view-del-on-photo {
  z-index: 4;
}
.listing-view-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: .88;
}
.listing-view-nav:hover { opacity: 1; }
.listing-view-nav.prev { left: .55rem; }
.listing-view-nav.next { right: .55rem; }
.listing-view-nav.hidden { display: none; }
.listing-view-dots {
  position: absolute;
  left: 0; right: 0; bottom: .55rem;
  display: flex;
  justify-content: center;
  gap: .28rem;
  z-index: 2;
  pointer-events: none;
}
.listing-view-dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,.38);
  transition: width .2s, background .2s;
}
.listing-view-dot.on {
  width: 16px;
  background: #fff;
}
.listing-view-counter {
  position: absolute;
  top: .55rem;
  right: .55rem;
  z-index: 2;
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: .22rem .55rem;
  border-radius: 99px;
}
.listing-view-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
}
.listing-view-price {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent-mint, var(--green));
}
.listing-view-icon-actions {
  display: flex;
  gap: .45rem;
  align-items: center;
  justify-content: flex-start;
}
.listing-view-ico-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
  flex: 0 0 auto;
}
.listing-view-ico-btn:active { transform: scale(.94); }
.listing-view-ico-btn.on {
  color: #ff6b8a;
  border-color: rgba(255,107,138,.35);
  background: rgba(255,107,138,.12);
}
.listing-view-ico-btn.listing-view-del {
  color: #e86a6a;
  border-color: rgba(220, 70, 70, .28);
  background: rgba(220, 70, 70, .12);
}
.listing-view-cta-stack {
  display: grid;
  gap: .45rem;
}
.listing-view-main-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 46px;
  width: 100%;
  border-radius: 12px;
  font-weight: 650;
}
.listing-view-profile-btn {
  /* same primary family, slightly softer */
  filter: saturate(.92);
  opacity: .95;
}
.listing-view-cta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
}
.listing-view-cta .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 600;
}
.listing-view-cta.single { grid-template-columns: 1fr; }
.listing-view-desc-block {
  display: grid;
  gap: .4rem;
  padding: .7rem .8rem;
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
  position: relative;
  z-index: 2;
  margin: 0;
}
.listing-view-desc-label {
  margin: 0;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.listing-view-desc {
  margin: 0;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.listing-view-desc.muted { opacity: .55; font-style: italic; }
html[data-theme="light"] .listing-view-desc-block {
  background: rgba(0,0,0,.03);
}
.listing-view-seller {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .65rem;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.listing-view-seller-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: rgba(255,255,255,.08);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
}
.listing-view-seller-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: .1rem;
}
.listing-view-seller-meta strong {
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.listing-view-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.listing-view-actions .btn { display: inline-flex; align-items: center; gap: .35rem; }

html[data-theme="light"] .listing-view-carousel {
  background: rgba(0,0,0,.06);
}
html[data-theme="light"] .listing-view-ico-btn {
  background: rgba(0,0,0,.03);
}
html[data-theme="light"] .listing-view-seller {
  background: rgba(0,0,0,.03);
}

/* 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(auto-fit, minmax(64px, 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-teal { background: linear-gradient(145deg, #3ecfcf, #1f9e9e); }
.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 {
  flex: 0 0 auto;
  box-shadow: none;
}
.market-card .market-actions .market-del-btn,
.market-row .market-actions .market-del-btn {
  align-self: center;
}
.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;
  position: relative;
}
.showcase-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .5rem .55rem .6rem;
  position: relative;
  z-index: 1;
  background: var(--soft-fill);
}
.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-del-btn.on-photo {
  margin: 0;
}
.showcase-item::before { display: none; }

.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 .18s ease-out;
}
@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 .24s 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: url('/app/img/fone.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scaleX(-1);
  transform-origin: center center;
  pointer-events: none;
  z-index: 1;
}
.wp-option.tone-light::before {
  filter: invert(1);
  opacity: .12;
}
.wp-option.tone-dark {
  background-color: #0d2419;
  background-image: none;
}
.wp-option.tone-dark[data-wp="dark-pine"] { background-color: #0a1f16; }
.wp-option.tone-dark[data-wp="dark-night"] { background-color: #06140f; }
.wp-option.tone-dark::before {
  display: block;
  filter: none;
  opacity: .14;
}
.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: .75rem .75rem;
  min-height: 58px;
  height: auto;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  border-radius: 12px;
}
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; flex-wrap: wrap;
  gap: .25rem; max-width: min(92vw, 340px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: .4rem; box-shadow: var(--shadow);
}
.reaction-picker button {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; font-size: 1.25rem; line-height: 1;
  display: grid; place-items: center; cursor: pointer; overflow: visible;
}
.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 editor */
.story-editor {
  position: fixed; inset: 0; z-index: 80;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  color: #fff;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.story-editor.hidden { display: none !important; }
body.has-story-editor { overflow: hidden; }
.story-editor-head {
  display: flex; align-items: center; gap: .55rem;
  padding: calc(.55rem + var(--safe-t, env(safe-area-inset-top, 0px))) .75rem .45rem;
  flex: 0 0 auto;
}
.story-editor-x {
  color: #fff;
  width: 40px; height: 40px;
  font-size: 1.1rem;
}
.story-editor-title {
  flex: 1; min-width: 0;
  display: grid; gap: .1rem;
}
.story-editor-title strong { font-size: .95rem; }
.story-editor-title span { font-size: .72rem; color: rgba(255,255,255,.55); }
.story-publish-btn {
  flex: 0 0 auto;
  padding: .55rem .9rem;
  font-size: .82rem;
}
.story-editor-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: .35rem .75rem;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(40,40,40,.9), #0a0a0a 70%);
}
.story-editor-stage canvas,
.story-editor-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: 12px;
  background: #111;
  touch-action: none;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.story-editor-stage.is-video canvas { display: none; }
.story-editor-caption {
  padding: .35rem .75rem 0;
  flex: 0 0 auto;
}
.story-editor-caption .field-input {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: #fff;
}
.story-editor-tools {
  display: flex; gap: .35rem;
  padding: .55rem .75rem .25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.story-editor-tools::-webkit-scrollbar { display: none; }
.story-editor-tools button {
  flex: 0 0 auto;
  border: 0;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.75);
  border-radius: 999px;
  padding: .45rem .85rem;
  font: 600 .78rem Manrope, system-ui, sans-serif;
}
.story-editor-tools button.active {
  background: var(--green, #2ecc71);
  color: #0a0a0a;
}
.story-editor.is-video .story-editor-tools button:not([data-story-tool="move"]) {
  display: none;
}
.story-editor.is-video .story-editor-panels {
  display: none;
}
.story-editor-panels {
  flex: 0 0 auto;
  min-height: 72px;
  padding: .35rem .75rem .5rem;
}
.story-editor-panel.hidden { display: none !important; }
.story-filter-list,
.story-emoji-list {
  display: flex; gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: .15rem;
}
.story-filter-list::-webkit-scrollbar,
.story-emoji-list::-webkit-scrollbar { display: none; }
.story-filter-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: #fff;
  border-radius: 10px;
  padding: .55rem .7rem;
  font: 600 .75rem Manrope, system-ui, sans-serif;
}
.story-filter-chip.active {
  border-color: var(--green, #2ecc71);
  background: rgba(46,204,113,.18);
}
.story-emoji-chip {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  font-size: 1.45rem;
}
.story-text-row {
  display: flex; gap: .4rem; align-items: center;
}
.story-text-row .field-input { flex: 1; min-width: 0; }
.story-text-row input[type="color"] {
  width: 40px; height: 40px; padding: 0; border: 0; background: none;
}
.story-text-row input[type="range"] { width: 72px; }
.story-text-row .btn { width: 40px; height: 40px; padding: 0; font-size: 1.25rem; }
.story-zoom-label {
  display: grid; gap: .35rem;
  font-size: .78rem; color: rgba(255,255,255,.7);
}
.story-zoom-label input[type="range"] { width: 100%; }
.story-editor-hint {
  margin: .45rem 0 0;
  font-size: .72rem;
  color: rgba(255,255,255,.45);
}
.story-upload-progress {
  margin: .25rem .75rem .35rem;
  padding: .65rem .75rem;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  display: grid; gap: .4rem;
  flex: 0 0 auto;
}
.story-upload-progress.hidden { display: none !important; }
.story-upload-bar {
  height: 6px; border-radius: 99px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}
.story-upload-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green, #2ecc71), #7dcea0);
  border-radius: 99px;
  transition: width .15s ease;
}
.story-upload-progress span {
  font-size: .78rem;
  color: rgba(255,255,255,.8);
}
.story-editor-cancel {
  margin: 0 .75rem .65rem;
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 0;
}

.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 .btn { margin-left: auto; flex: 0 0 auto; }
.online-row:hover { background: rgba(255,255,255,.05); }

/* —— Mobile / PWA shell (full bleed, safe-area once) —— */
@media (max-width: 900px) {
  html, body {
    /* Do NOT use position:fixed here — it becomes a containing block and
       leaves a dead strip under the dock on iOS standalone PWA. */
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    min-height: 100lvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--panel);
  }
  .app {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: none;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--panel);
    padding-top: var(--safe-t);
    padding-bottom: 0;
    box-sizing: border-box;
  }
  /* Opaque strip under status bar — kills top smear on iOS 27 translucent PWA */
  .app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--safe-t);
    background: var(--panel);
    z-index: 40;
    pointer-events: none;
  }
  /* Keyboard: pin composer above keyboard, don't shrink the whole shell */
  html.kb-open .bottom-nav {
    display: none !important;
  }
  html.kb-open.kb-composer .composer-stack {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--kb-overlap, 0px);
    z-index: 80;
    transition: bottom .2s ease-out, transform .2s ease-out;
    background: var(--panel) !important;
    /* Keyboard covers home indicator — no extra safe-area gap */
    padding-bottom: .2rem;
    box-shadow: 0 -1px 0 var(--line);
  }
  html.kb-open.kb-composer .composer-stack .composer {
    padding-bottom: .35rem !important;
    border-top-color: var(--line);
  }
  html.kb-open.kb-composer.app.chat-open .composer,
  html.kb-open.kb-composer.cc-chat-open .composer,
  html.kb-open.kb-composer .app.chat-open .composer,
  html.kb-open.kb-composer.app.flood-open .composer,
  html.kb-open.kb-composer.cc-flood-open .composer,
  html.kb-open.kb-composer .app.flood-open .composer {
    padding-bottom: .35rem !important;
  }
  html.kb-open.kb-composer .app.chat-open .messages,
  html.kb-open.kb-composer.cc-chat-open .messages,
  html.kb-open.kb-composer .app.flood-open .messages,
  html.kb-open.kb-composer.cc-flood-open .messages {
    padding-bottom: calc(var(--composer-stack-h, 72px) + var(--kb-overlap, 0px) + .5rem);
    transition: padding-bottom .2s ease-out;
  }
  /* Auth: shrink to visual viewport and scroll field above keyboard */
  html.kb-open.kb-auth .auth-screen {
    height: var(--shell-height, 100dvh) !important;
    min-height: 0 !important;
    max-height: var(--shell-height, 100dvh) !important;
    place-items: start center;
    align-content: start;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: max(.75rem, env(safe-area-inset-top, 0px));
    padding-bottom: .75rem;
  }
  html.kb-open.kb-auth .auth-card {
    max-height: none;
    margin-top: 0;
  }
  /* Modals / listing form: lift above keyboard */
  html.kb-open.kb-settings .modal {
    place-items: start center;
    align-content: start;
    padding-top: max(.5rem, env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--kb-settings-inset, var(--kb-overlap, 0px)) + .5rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  html.kb-open.kb-settings .modal-card {
    max-height: calc(var(--shell-height, 100dvh) - 1rem);
    margin-bottom: .25rem;
  }
  /* Only the active form body — not drawer-sheet + every .settings-view */
  html.kb-open.kb-settings .settings-body {
    padding-bottom: calc(var(--kb-settings-inset, 0px) + 1.25rem);
    transition: padding-bottom .24s var(--spring);
  }

  .search, .field-input, .auth-form input, .chat-search-bar input, .gif-search-wrap input {
    font-size: 16px;
  }
  .chat-view::before,
  .flood-view::before {
    --pattern-size: 28px auto;
  }

  /* Kill ALL frosted blur on chrome — iOS 27 smears it into the status bar */
  .sidebar-header,
  .chat-header,
  .composer,
  .topic-bar,
  .chat-search-bar,
  .dm-pin-bar,
  .quick-replies,
  .market-filters,
  .stories-rail,
  .folder-tabs,
  .icon-btn,
  .bottom-nav,
  .bottom-nav .nav-pill {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .sidebar-header,
  .chat-header {
    background: var(--panel) !important;
    border-bottom-color: var(--line);
  }
  .composer {
    background: var(--panel) !important;
  }
  /* Flat chrome buttons in headers */
  .chat-header .icon-btn,
  .sidebar-header .icon-btn {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .chat-header .icon-btn:hover,
  .sidebar-header .icon-btn:hover {
    background: transparent !important;
    color: var(--text);
  }
  html[data-theme="light"] .chat-header .icon-btn,
  html[data-theme="light"] .sidebar-header .icon-btn {
    background: transparent !important;
    box-shadow: none !important;
  }

  .sidebar {
    flex: 1 1 auto;
    min-height: 0;
    border-right: 0;
    padding-bottom: 0;
    width: 100%;
    overflow: hidden;
    background: var(--panel);
  }
  /* Keep category tabs (incl. Аукционы) visible on mobile — scroll horizontally */
  .folder-tabs {
    display: flex;
    padding: .35rem .7rem .45rem;
    gap: .32rem;
  }
  .folder-tabs button {
    padding: .42rem .72rem;
    font-size: .78rem;
  }

  .bottom-nav {
    display: grid;
    position: fixed;
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: 8px;
    flex: 0 0 auto;
    width: auto;
    max-width: 440px;
    margin: 0 auto;
    z-index: 100;
    height: 58px;
    min-height: 58px;
    padding: 4px;
    align-items: stretch;
    border-radius: 28px;
    border-top: 0;
    background: var(--panel-2) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none;
  }
  .bottom-nav .nav-pill {
    display: block !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .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; }
  .app {
    --dock-space: calc(58px + 16px + var(--dock-bottom));
  }
  .chat-list {
    padding-bottom: calc(var(--dock-space) + .35rem);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .stories-rail {
    padding-bottom: .45rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
  }
  .drawer {
    inset: 0 !important;
    padding: 0;
    z-index: 72;
    background: var(--panel);
  }
  .app:not(.chat-open):not(.flood-open):not(.has-profile) .toast,
  html:not(.cc-chat-open):not(.cc-flood-open):not(.cc-has-profile) .toast {
    bottom: calc(var(--dock-space) + .5rem);
  }
  body.has-drawer .toast,
  html.cc-has-drawer .toast {
    bottom: calc(.75rem + var(--safe-b));
  }

  .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,
  html.cc-chat-open .composer {
    padding-bottom: calc(.5rem + var(--safe-b));
  }

  /* Flood = full screen thread like DM (back arrow, no dock) */
  .app.flood-open .sidebar { display: none; }
  .app.flood-open .main { display: flex; }
  .app.flood-open ~ .bottom-nav,
  html.cc-flood-open .bottom-nav { display: none; }
  .app.flood-open .composer,
  html.cc-flood-open .composer {
    padding-bottom: calc(.5rem + var(--safe-b));
  }
  .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: calc(var(--dock-space) + .5rem); }

  /* Profile = separate full page on mobile / PWA */
  .profile-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    z-index: 70;
    border-left: 0;
    box-shadow: none;
    animation: profilePageIn .26s var(--spring);
    background: var(--panel);
    padding-top: var(--safe-t);
    padding-bottom: var(--safe-b);
  }
  @keyframes profilePageIn {
    from { transform: translateX(12%); opacity: .85; }
    to { transform: none; opacity: 1; }
  }
  .app.has-profile ~ .bottom-nav,
  html.cc-has-profile .bottom-nav { display: none !important; }
  .app.has-profile .sidebar,
  .app.has-profile .main {
    visibility: hidden;
    pointer-events: none;
  }
  .profile-panel #closeProfile {
    top: calc(var(--safe-t) + .35rem);
    left: .55rem;
    right: auto;
  }
  .profile-panel .profile-close {
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .row { grid-template-columns: 1fr; }
  /* Settings = separate full page (not overlay over market/dock) */
  .drawer {
    grid-template-columns: 1fr;
    z-index: 72;
    inset: 0 !important;
  }
  /* Settings page keeps the bottom dock */
  body.has-drawer .bottom-nav,
  html.cc-has-drawer .bottom-nav {
    display: grid !important;
    z-index: 100;
  }
  body.has-drawer #app .sidebar,
  body.has-drawer #app .main {
    visibility: hidden;
    pointer-events: none;
  }
  .drawer-backdrop {
    display: none !important;
  }
  .drawer-sheet,
  .drawer-right .drawer-sheet {
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0;
    border: 0;
    padding: calc(var(--safe-t) + .35rem) .75rem calc(var(--dock-space) + .55rem);
    position: relative;
    z-index: 1;
    background: var(--panel) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none;
    inset: auto;
  }
  .settings-page-bar {
    display: flex;
  }
  .settings-page-bar .icon-btn {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .msg { max-width: min(82%, 100%); }
  .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 {
    --composer-ctrl: 40px;
    gap: .25rem;
    padding: .4rem .4rem;
    align-items: flex-end;
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .composer-tools .composer-tool,
  .composer-tools .icon-btn.composer-tool {
    width: 32px;
    min-width: 32px;
    height: var(--composer-ctrl);
    min-height: var(--composer-ctrl);
  }
  .composer-tool, .icon-btn.composer-tool,
  .composer .send-btn {
    width: var(--composer-ctrl);
    height: var(--composer-ctrl);
    min-width: var(--composer-ctrl);
    min-height: var(--composer-ctrl);
    border-radius: 12px;
  }
  .composer-tool, .icon-btn.composer-tool {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .composer-shell textarea {
    padding: 10px 12px;
  }
  .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;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .sticker-grid { grid-template-columns: repeat(5, 1fr); }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(2.45rem, 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; }

  /* Headers: solid fill, no safe-t (already on .app), no blur */
  .sidebar-header {
    padding: 0 .55rem 0 .75rem;
    height: var(--header-h);
    min-height: var(--header-h);
    box-sizing: border-box;
    background: var(--panel);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .chat-header {
    padding: 0 .75rem;
    height: var(--header-h);
    min-height: var(--header-h);
    box-sizing: border-box;
    background: var(--panel);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .auth-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100lvh;
    min-height: 100lvh;
    max-height: 100lvh;
    padding: max(1rem, var(--safe-t)) 1.15rem max(1rem, var(--safe-b));
    place-items: center;
  }
  html.auth-open .app {
    visibility: hidden;
    pointer-events: none;
  }
  .cc-picker-menu,
  .stories-rail,
  .chat-search-bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--panel);
  }
}

@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); }
.voice-toggle.recording {
  color: #fff !important;
  background: linear-gradient(145deg, #ff5f5f, #d94444) !important;
  border-radius: 12px !important;
  box-shadow: 0 0 0 3px rgba(226, 91, 91, .22), 0 6px 16px rgba(226, 91, 91, .35) !important;
  animation: voicePulse 1s ease infinite;
}
.voice-toggle.recording .ico {
  color: #fff;
  filter: none;
}
.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: none !important;
  }
  .drawer-right .drawer-sheet {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    order: 0;
    animation: none;
    box-shadow: none;
    z-index: 1;
    background: var(--panel) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Composer */
.composer {
  --composer-ctrl: 40px;
  gap: .3rem;
  padding: .45rem .5rem;
  align-items: flex-end;
}
.composer-shell {
  flex: 1;
  min-width: 0;
  min-height: var(--composer-ctrl);
  border-radius: 14px;
}
.composer-shell textarea {
  min-height: calc(var(--composer-ctrl) - 2px);
  max-height: 140px;
  padding: 10px 12px;
  line-height: 1.25;
  font-size: 16px; /* prevent iOS focus zoom */
}
.composer .send-btn {
  width: var(--composer-ctrl);
  height: var(--composer-ctrl);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(31,122,82,.35);
}
.send-btn.mic-mode {
  background: linear-gradient(135deg, #45c489, #1f8a58);
}
.send-btn.is-disabled,
.send-btn:disabled {
  opacity: .42;
  pointer-events: none;
  box-shadow: none;
}
.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;
}
.msg.has-voice {
  padding: .38rem .4rem .36rem .38rem;
  min-width: 210px;
  width: min(78%, 280px);
  max-width: min(78%, 280px);
}
.msg:has(.media),
.msg:has(.listing-msg-card),
.msg:has(.poll-card) {
  width: min(78%, 280px);
}
.msg.has-voice .text { display: none; }
.voice-msg {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 188px;
  max-width: 100%;
  padding: .35rem .45rem .35rem .35rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.msg:not(.out) .voice-msg {
  background: rgba(47, 158, 107, .1);
  border-color: rgba(47, 158, 107, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.msg.out .voice-msg {
  background: rgba(0, 0, 0, .14);
  border-color: rgba(255, 255, 255, .12);
}
html[data-theme="light"] .msg:not(.out) .voice-msg {
  background: rgba(31, 138, 88, .08);
  border-color: rgba(31, 138, 88, .18);
}
html[data-theme="light"] .msg.out .voice-msg {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .22);
}
.voice-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(145deg, #4ad394, #1f8a58);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(31, 138, 88, .32);
  transition: transform .15s var(--spring), box-shadow .18s ease, background .18s ease;
}
.voice-play .ico { margin-left: 1px; }
.voice-play:active { transform: scale(.94); }
.msg.out .voice-play {
  background: rgba(255, 255, 255, .24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 12px rgba(0, 0, 0, .12);
  color: inherit;
}
.voice-msg.playing .voice-play {
  background: linear-gradient(145deg, #3ecf8e, #176b44);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, .24), 0 8px 18px rgba(31, 138, 88, .36);
}
.msg.out .voice-msg.playing .voice-play {
  background: rgba(255, 255, 255, .34);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .18);
}
.voice-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: .34rem;
}
.voice-track {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  overflow: hidden;
}
.voice-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 26px;
  padding: 0;
  position: relative;
  z-index: 1;
}
.voice-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--voice-progress, 0%);
  background: linear-gradient(90deg, rgba(62, 207, 142, .22), rgba(62, 207, 142, .08));
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  transition: width .12s linear;
}
.msg.out .voice-progress {
  background: linear-gradient(90deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .06));
}
.voice-wave i {
  display: block;
  width: 2.5px;
  border-radius: 99px;
  background: currentColor;
  opacity: .34;
  height: 36%;
  transform-origin: center;
  flex: 0 0 auto;
}
.voice-wave i:nth-child(1) { height: 28%; }
.voice-wave i:nth-child(2) { height: 48%; }
.voice-wave i:nth-child(3) { height: 72%; }
.voice-wave i:nth-child(4) { height: 40%; }
.voice-wave i:nth-child(5) { height: 92%; }
.voice-wave i:nth-child(6) { height: 56%; }
.voice-wave i:nth-child(7) { height: 78%; }
.voice-wave i:nth-child(8) { height: 34%; }
.voice-wave i:nth-child(9) { height: 64%; }
.voice-wave i:nth-child(10) { height: 100%; }
.voice-wave i:nth-child(11) { height: 46%; }
.voice-wave i:nth-child(12) { height: 70%; }
.voice-wave i:nth-child(13) { height: 38%; }
.voice-wave i:nth-child(14) { height: 84%; }
.voice-wave i:nth-child(15) { height: 52%; }
.voice-wave i:nth-child(16) { height: 42%; }
.msg:not(.out) .voice-wave i {
  background: linear-gradient(180deg, #6adb9f, #1f8a58);
  opacity: .62;
}
.msg.out .voice-wave i { opacity: .58; }
.voice-msg.playing .voice-wave i {
  opacity: .95;
  animation: waveBar .85s ease-in-out infinite;
}
.voice-msg.playing .voice-wave i:nth-child(odd) { animation-delay: .08s; }
.voice-msg.playing .voice-wave i:nth-child(3n) { animation-delay: .16s; }
.voice-msg.playing .voice-wave i:nth-child(4n) { animation-delay: .24s; }
@keyframes waveBar {
  0%, 100% { transform: scaleY(.55); }
  50% { transform: scaleY(1); }
}
.voice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
}
.voice-chip {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .02em;
  opacity: .72;
}
.voice-chip .ico {
  width: 12px;
  height: 12px;
  opacity: .85;
}
.msg:not(.out) .voice-chip { color: var(--accent-mint, #7dcca8); opacity: .9; }
.voice-dur {
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  opacity: .78;
  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: .4rem; align-items: center;
  padding: .5rem .7rem; border-bottom: 1px solid var(--line);
  background: var(--panel); flex: 0 0 auto;
}
.chat-search-bar .chat-search-ico {
  flex: 0 0 auto; color: var(--muted); display: grid; place-items: center;
}
.chat-search-bar input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background-color: var(--field-bg);
  border-radius: 999px; padding: .55rem .9rem; outline: none; height: 40px;
}
.chat-search-count {
  flex: 0 0 auto; font-size: .78rem; font-weight: 700; min-width: 2.6rem; text-align: center;
}
.chat-search-bar .icon-btn { width: 36px; height: 36px; border-radius: 12px; }
.msg.msg-search-hit {
  outline: 2px solid rgba(47,158,107,.55);
  outline-offset: 2px;
  animation: searchPulse .9s ease;
}
@keyframes searchPulse {
  0% { outline-color: rgba(47,158,107,.9); }
  100% { outline-color: rgba(47,158,107,.35); }
}

.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: pointer;
}
.dm-pin-bar .dm-pin-ico { opacity: .85; display: inline-flex; }
.dm-pin-thumb {
  width: 40px; height: 40px; border-radius: 8px;
  background-size: cover; background-position: center;
  background-color: rgba(0,0,0,.22);
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.dm-pin-thumb.hidden { display: none !important; }
.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;
  max-width: min(92vw, 320px);
  box-shadow: var(--glass-shadow);
  display: grid;
  gap: .2rem;
  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-action-reactions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: .2rem;
  padding: .35rem .35rem .45rem;
  overflow: visible;
  border-bottom: 1px solid var(--line);
  margin: 0 .15rem .15rem;
}
.msg-action-reactions::-webkit-scrollbar { display: none; }
.msg-action-reactions.hidden { display: none !important; }
.msg-action-reactions button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: visible;
  transition: transform .16s var(--spring), background .16s ease;
}
.msg-action-reactions button:hover,
.msg-action-reactions button:active {
  background: var(--green-soft);
  transform: scale(1.12);
}
.msg-action-list {
  display: grid;
}
.msg-actions .msg-action-list button {
  display: flex; align-items: center; gap: .65rem;
  border: 0; background: transparent; padding: .7rem .8rem;
  border-radius: 12px; cursor: pointer; text-align: left;
  color: inherit;
  font: inherit;
}
.msg-actions .msg-action-list button:hover { background: var(--green-soft); }
.msg-actions .msg-action-list button.danger { color: var(--danger); }
.msg-actions .ico { color: var(--green); }
.msg-actions .msg-action-list 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: 15px; height: 15px; color: var(--green); }
.topic-chip.active .ico { color: var(--accent-mint); }
.topic-chip.topic-all.active .ico { color: #fff; }

.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 {
  display: none;
}
.profile-close {
  position: absolute;
  top: .55rem;
  right: .55rem;
  z-index: 3;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(8px);
  -webkit-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: 0; }
.profile-card .bio { text-align: center; line-height: 1.45; }
.profile-card .bio.is-empty { color: var(--muted); }
.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 {
  background: var(--panel);
}
html[data-theme="light"] .emoji-grid button {
  background: var(--panel-3);
}
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,.92);
  border-color: rgba(18,50,35,.08);
  box-shadow: 0 1px 0 rgba(255,255,255,.8);
}
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; }

/* —— Auctions —— */
.auctions-pay-hint { margin: .45rem 0 0; line-height: 1.35; }
.market-mode-tabs {
  display: flex;
  gap: .35rem;
  margin: 0 0 .55rem;
  padding: .2rem;
  border-radius: 12px;
  background: var(--soft-fill-2, rgba(0,0,0,.04));
  border: 1px solid var(--line);
}
.market-mode-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  cursor: pointer;
}
.market-mode-tab.active {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(46, 168, 110, .22);
}
.auction-card {
  display: flex; flex-direction: column; gap: .45rem;
  padding: .7rem; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  cursor: pointer; text-align: left; width: 100%;
  color: inherit; font: inherit;
  transition: border-color .16s ease, transform .16s ease;
}
.auction-card:hover { border-color: rgba(47,158,107,.45); }
.auction-card:active { transform: scale(.99); }
.auction-card-photo {
  aspect-ratio: 4/3; border-radius: 10px; overflow: hidden;
  background: var(--soft-fill); position: relative;
}
.auction-card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auction-timer-pill {
  position: absolute; left: .45rem; bottom: .45rem;
  background: rgba(0,0,0,.72); color: #fff;
  font-size: .68rem; font-weight: 700;
  padding: .2rem .45rem; border-radius: 999px;
  backdrop-filter: blur(8px);
}
.auction-card-title { font-weight: 700; font-size: .92rem; line-height: 1.25; }
.auction-card-price { font-weight: 800; color: var(--accent-mint); font-size: 1rem; }
.auction-card-meta { font-size: .75rem; color: var(--muted); }
.auction-view-hero {
  display: grid; gap: .75rem;
}
@media (min-width: 720px) {
  .auction-view-hero { grid-template-columns: 1.1fr .9fr; align-items: start; }
}
.auction-view-gallery {
  display: grid; gap: .35rem;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.auction-view-gallery img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  background: var(--soft-fill);
}
.auction-timer-big {
  font-size: 1.35rem; font-weight: 800; letter-spacing: .02em;
  color: var(--accent-mint);
}
.auction-bid-list { display: flex; flex-direction: column; gap: .35rem; max-height: 280px; overflow: auto; }
.auction-bid-row {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .35rem; border-radius: 10px;
}
.auction-bid-row:nth-child(odd) { background: var(--soft-fill-2); }
.auction-bid-row .avatar { width: 32px; height: 32px; flex: 0 0 auto; }
.auction-bid-meta { flex: 1; min-width: 0; }
.auction-bid-meta strong { display: block; font-size: .88rem; }
.auction-bid-amount { font-weight: 800; color: var(--accent-mint); white-space: nowrap; }
.auction-bid-form {
  display: flex; gap: .45rem; align-items: flex-end; flex-wrap: wrap;
  margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line);
}
.auction-bid-form .field { flex: 1; min-width: 140px; margin: 0; }
.modal-card-wide { max-width: min(720px, 96vw); }
