/* ================================================================
   STASHBOX — phase 3 redesign
   dark cyber-cute. split panels. tabbed. motion everywhere.
   ================================================================ */
:root {
  --bg: #0b0715;
  --bg-2: #120d22;
  --card: #17122c;
  --card-2: #221a3f;
  --ink: #f4eeff;
  --muted: #8b7fb0;
  --muted-2: #5f5683;
  --line: #2e2352;
  --lime: #c8ff3d;
  --pink: #ff5fa8;
  --cyan: #4de3ff;
  --orange: #ffa63d;
  --purple: #8a7dff;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --topbar-h: 64px;
  --tabbar-h: 68px;
  --sidebar-w: 240px;
  --rightbar-w: 260px;
  --shadow-btn: 0 4px 0 #000;
  --shadow-card: 0 6px 0 0 rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--lime); color: #17102b; }

/* animated background */
.blobs {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 500px at 0% 0%, rgba(255, 95, 168, .18), transparent 65%),
    radial-gradient(700px 600px at 100% 10%, rgba(77, 227, 255, .14), transparent 65%),
    radial-gradient(700px 700px at 50% 110%, rgba(200, 255, 61, .10), transparent 65%);
  animation: drift 30s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { background-position: 0 0, 0 0, 0 0; }
  100% { background-position: 60px 40px, -60px 30px, 20px -40px; }
}

/* ================================================================
   SHELL (desktop: 3 columns, mobile: single + tabs)
   ================================================================ */
.shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}
@media (min-width: 960px) {
  .shell {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
}
@media (min-width: 1280px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rightbar-w);
  }
}

/* -------- sidebar (desktop only) -------- */
.sidebar { display: none; }
@media (min-width: 960px) {
  .sidebar {
    display: flex; flex-direction: column;
    padding: 20px 16px;
    border-right: 2px solid var(--line);
    position: sticky; top: 0; height: 100vh;
    background: linear-gradient(180deg, rgba(23,18,44,.9), rgba(11,7,21,.9));
    backdrop-filter: blur(10px);
  }
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 22px; letter-spacing: -.5px;
  margin: 4px 6px 24px;
  transform: rotate(-2deg);
}
.brand .box {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--lime); color: #0b0715;
  display: grid; place-items: center;
  border: 2px solid #000; box-shadow: 3px 3px 0 var(--pink);
  font-size: 18px;
}
.brand span { color: var(--lime); }

.nav { display: grid; gap: 4px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  border: 2px solid transparent; background: transparent; color: var(--muted);
  font-weight: 700; font-size: 15px; cursor: pointer; text-align: left;
  transition: all .15s;
}
.nav-btn:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.nav-btn.on { background: var(--card); color: var(--ink); border-color: var(--line); }
.nav-btn .ic { font-size: 18px; width: 22px; text-align: center; }
.nav-btn .badge {
  margin-left: auto; background: var(--pink); color: #17102b;
  font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px;
}

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 2px solid var(--line); }
.me-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 14px;
  background: var(--card); border: 2px solid var(--line);
}
.me-card b { font-size: 14px; display: block; }
.me-card small { color: var(--muted); font-size: 12px; }
.me-card .crown { color: var(--orange); }

/* -------- main column -------- */
.main {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
}
@media (min-width: 960px) {
  .main { padding-bottom: 40px; }
}

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(11,7,21,.85);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.3px; flex: 1; }
.topbar .brand-mobile { display: flex; align-items: center; gap: 8px; font-weight: 800; flex: 1; }
.topbar .brand-mobile .box {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--lime); color: #0b0715; display: grid; place-items: center;
  border: 2px solid #000; font-size: 14px;
}
@media (min-width: 960px) { .topbar .brand-mobile { display: none; } }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card); border: 2px solid var(--line); color: var(--ink);
  cursor: pointer; font-size: 16px;
  transition: all .12s;
}
.icon-btn:hover { border-color: var(--lime); transform: translateY(-1px); }

/* content area */
.content { padding: 16px; max-width: 900px; margin: 0 auto; }
@media (min-width: 960px) { .content { padding: 24px 28px; max-width: 760px; } }
@media (min-width: 1280px) { .content { max-width: 720px; } }

/* -------- right rail (largest screens) -------- */
.rightbar { display: none; }
@media (min-width: 1280px) {
  .rightbar {
    display: flex; flex-direction: column; gap: 16px;
    padding: 24px 16px; border-left: 2px solid var(--line);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
}
.rail-card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--r); padding: 14px;
}
.rail-card h4 {
  margin: 0 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); font-weight: 800;
}
.online-list { display: grid; gap: 8px; }
.online-user { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.online-user .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--lime);
  border: 1px solid #000; box-shadow: 0 0 0 3px rgba(200,255,61,.15);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(200,255,61,.05); } }

/* -------- tabbar (mobile only) -------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; align-items: stretch;
  background: rgba(11,7,21,.92);
  backdrop-filter: blur(14px);
  border-top: 2px solid var(--line);
}
@media (min-width: 960px) { .tabbar { display: none; } }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: transparent; border: none; color: var(--muted);
  font-size: 11px; font-weight: 700; cursor: pointer;
  transition: color .12s;
  position: relative;
}
.tab .ic { font-size: 20px; line-height: 1; }
.tab.on { color: var(--ink); }
.tab.on .ic { color: var(--lime); }
.tab .badge {
  position: absolute; top: 8px; right: calc(50% - 22px);
  background: var(--pink); color: #17102b;
  font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 99px;
  border: 1px solid #000;
}

/* ================================================================
   ATOM: avatar
   ================================================================ */
.av {
  display: inline-grid; place-items: center; border-radius: 50%;
  font-weight: 800; border: 2px solid #000; flex-shrink: 0;
  color: #0b0715;
}
.av-row { display: inline-flex; align-items: center; gap: 8px; }

/* ================================================================
   ATOM: buttons
   ================================================================ */
.btn {
  background: var(--lime); color: #0b0715; border: 2px solid #000; border-radius: 12px;
  padding: 10px 18px; font-weight: 800; cursor: pointer; font-size: 14px;
  box-shadow: var(--shadow-btn); transition: transform .1s, box-shadow .1s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 0 5px 0 #000; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 1px 0 #000; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--card-2); border-color: var(--lime); transform: none; }
.btn.danger { background: var(--pink); color: #0b0715; }
.btn.cyan { background: var(--cyan); color: #0b0715; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; box-shadow: 0 2px 0 #000; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ================================================================
   ATOM: inputs
   ================================================================ */
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.input, .field input {
  background: var(--bg-2); border: 2px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font-size: 15px; outline: none; color: var(--ink);
  transition: border-color .12s;
}
.input:focus, .field input:focus { border-color: var(--lime); }
.search-input {
  background: var(--card); border: 2px solid var(--line); border-radius: 999px;
  padding: 9px 16px; outline: none; color: var(--ink); font-size: 14px;
  transition: border-color .12s, background .12s;
  width: 100%;
}
.search-input:focus { border-color: var(--cyan); background: var(--bg-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line);
  font-size: 12px; font-weight: 800; color: var(--muted);
}
.shake { animation: shake .35s; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ================================================================
   PAGE: STASH (home)
   ================================================================ */
.hero-card {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-2) 100%);
  border: 2px solid #000; border-radius: var(--r-lg);
  padding: 24px; margin-bottom: 20px;
  box-shadow: 6px 6px 0 var(--pink);
  position: relative; overflow: hidden;
  cursor: pointer; transition: transform .15s;
}
.hero-card:hover { transform: translateY(-2px); }
.hero-card::after {
  content: ""; position: absolute; right: -30px; bottom: -30px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,255,61,.22), transparent 70%);
  pointer-events: none;
}
.hero-card .emoji { font-size: 40px; margin-bottom: 8px; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-7px) rotate(6deg); } }
.hero-card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.4px; }
.hero-card p { margin: 0; color: var(--muted); font-size: 14px; max-width: 420px; }
.hero-card .hint { margin-top: 14px; font-size: 12px; color: var(--muted-2); font-weight: 700; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 16px 0 16px; }
.chip {
  background: var(--card); border: 2px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
  font-weight: 800; font-size: 13px; cursor: pointer;
  color: var(--muted); transition: all .12s;
}
.chip:hover { color: var(--ink); border-color: var(--lime); }
.chip.on { background: var(--lime); color: #0b0715; border-color: var(--lime); }

/* upload queue */
.queue { display: grid; gap: 8px; margin: 0 0 16px; }
.q-item { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.q-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-pct { color: var(--lime); }
.bar { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--orange), var(--lime)); transition: width .15s; }
.q-item.fail { border-color: var(--pink); }
.q-item.fail .q-pct { color: var(--pink); }
.q-item.done { border-color: var(--lime); }

/* grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; } }
.tile {
  --a: var(--orange);
  background: var(--card); border: 2px solid #000; border-radius: var(--r);
  overflow: hidden; cursor: pointer; outline: none;
  box-shadow: 0 4px 0 var(--a);
  transition: transform .15s, box-shadow .15s;
  animation: rise .35s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tile:nth-child(1) { animation-delay: .02s; }
.tile:nth-child(2) { animation-delay: .04s; }
.tile:nth-child(3) { animation-delay: .06s; }
.tile:nth-child(4) { animation-delay: .08s; }
.tile:nth-child(5) { animation-delay: .10s; }
.tile:nth-child(6) { animation-delay: .12s; }
.tile:hover, .tile:focus-visible { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 7px 0 var(--a); }
.k-image { --a: var(--pink); }
.k-video { --a: var(--cyan); }
.k-audio { --a: var(--lime); }
.k-pdf, .k-text, .k-other { --a: var(--orange); }
.thumb {
  aspect-ratio: 1; background: var(--bg-2); position: relative;
  display: grid; place-items: center; overflow: hidden;
  border-bottom: 2px solid #000;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .em { font-size: 46px; }
.k-audio .thumb { background: linear-gradient(135deg, #3b1f6e, #1d3a5f); }
.k-pdf .thumb, .k-text .thumb, .k-other .thumb { background: linear-gradient(135deg, #3d2a1f, #2a1d3f); }
.badge-ext {
  position: absolute; left: 8px; bottom: 8px;
  background: #000c; color: var(--ink);
  font-size: 10px; font-weight: 900; padding: 2px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .6px;
}
.play-icon {
  position: absolute; right: 8px; top: 8px;
  background: #000b; border-radius: 99px;
  width: 30px; height: 30px; display: grid; place-items: center; font-size: 12px;
}
.tile-info { padding: 10px 12px 12px; }
.tile-info b {
  display: block; font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 3px;
}
.tile-info span { font-size: 11px; color: var(--muted); font-weight: 600; }
.empty {
  text-align: center; color: var(--muted); font-weight: 700;
  padding: 60px 10px; grid-column: 1 / -1;
}
.empty .em { font-size: 54px; display: block; margin-bottom: 8px; }

/* ================================================================
   PAGE: CHAT
   ================================================================ */
.chat-page {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
}
@media (min-width: 960px) {
  .chat-page { height: calc(100vh - var(--topbar-h)); }
}
.chat-log {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.msg {
  display: flex; gap: 8px; align-items: flex-end;
  animation: slideUp .25s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.mine { flex-direction: row-reverse; }
.msg .bubble {
  max-width: 78%; background: var(--card-2); border: 2px solid var(--line);
  padding: 8px 12px; border-radius: 16px 16px 16px 4px;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  font-size: 14px;
}
.msg.mine .bubble { background: var(--lime); color: #0b0715; border-color: #000; border-radius: 16px 16px 4px 16px; }
.msg .sticker { font-size: 56px; line-height: 1; }
.msg .meta { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.msg .reactions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.msg .reactions span {
  background: #000a; border-radius: 99px; padding: 1px 7px; font-size: 12px;
  border: 1px solid var(--line); cursor: pointer;
}
.msg .reactions span:hover { border-color: var(--lime); }
.msg .react-row {
  display: flex; gap: 2px; margin-top: 4px;
  opacity: 0; transition: opacity .15s;
}
.msg:hover .react-row { opacity: 1; }
.msg .react-row button {
  background: transparent; border: none; font-size: 14px; cursor: pointer;
  padding: 1px 3px; border-radius: 6px;
}
.msg .react-row button:hover { background: #000a; }

.typing-line {
  min-height: 18px; font-size: 12px; color: var(--muted);
  font-style: italic; padding: 0 16px 6px;
}

.chat-form {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 2px solid var(--line);
  background: var(--bg);
  position: relative;
}
@media (min-width: 960px) {
  .chat-form { padding: 12px 16px 16px; }
}
.chat-form input {
  flex: 1; background: var(--card); border: 2px solid var(--line);
  border-radius: 14px; padding: 10px 14px; outline: none; color: var(--ink);
  font-size: 15px;
}
.chat-form input:focus { border-color: var(--lime); }
.chat-form .send-btn {
  background: var(--lime); color: #0b0715; border: 2px solid #000;
  border-radius: 12px; padding: 0 18px; font-size: 18px; font-weight: 900;
  cursor: pointer; box-shadow: 0 3px 0 var(--pink);
  transition: all .1s;
}
.chat-form .send-btn:active { box-shadow: 0 0 0 var(--pink); transform: translate(2px, 2px); }
.chat-form .sticker-btn {
  background: var(--cyan); color: #0b0715; border: 2px solid #000;
  border-radius: 12px; padding: 0 14px; font-size: 18px;
  cursor: pointer; box-shadow: 0 3px 0 #000;
}
.chat-form .sticker-btn:active { box-shadow: 0 0 0 #000; transform: translate(2px, 2px); }

.sticker-picker {
  position: absolute; bottom: 100%; left: 12px; right: 12px;
  margin-bottom: 8px;
  background: var(--bg-2); border: 2px solid var(--line); border-radius: 16px;
  padding: 10px; z-index: 5;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  box-shadow: 0 6px 0 #000;
}
.sticker-picker button {
  background: var(--card); border: 2px solid var(--line); border-radius: 10px;
  font-size: 24px; padding: 6px 0; cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.sticker-picker button:hover { transform: scale(1.15); border-color: var(--lime); }

/* ================================================================
   PAGE: MEMBERS
   ================================================================ */
.member-list { display: grid; gap: 8px; }
.member {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--card); border: 2px solid var(--line);
  border-radius: var(--r);
}
.member b { display: block; font-size: 15px; }
.member small { color: var(--muted); font-size: 12px; }
.member .status {
  margin-left: auto; font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 99px;
  background: var(--bg-2); color: var(--muted);
}
.member .status.on { background: var(--lime); color: #0b0715; }

/* ================================================================
   PAGE: ADMIN
   ================================================================ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 2px solid #000; border-radius: var(--r);
  padding: 14px 16px; box-shadow: 0 4px 0 var(--a, var(--cyan));
}
.stat-card b { display: block; font-size: 26px; font-weight: 900; }
.stat-card span { color: var(--muted); font-weight: 700; font-size: 12px; }

.bulk-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
}
.bulk-bar .grow { flex: 1; }
.bulk-bar label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.bulk-bar input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--lime); cursor: pointer; }

.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: auto 52px 1fr auto; gap: 10px; align-items: center;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; transition: border-color .12s;
}
.row.sel { border-color: var(--lime); }
.row .rt {
  width: 52px; height: 52px; border-radius: 10px; overflow: hidden;
  background: var(--bg-2); display: grid; place-items: center;
  cursor: pointer; border: 2px solid #000; font-size: 22px;
}
.row .rt img { width: 100%; height: 100%; object-fit: cover; }
.row .rn { min-width: 0; cursor: pointer; }
.row .rn b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row .rn span { color: var(--muted); font-size: 12px; font-weight: 600; }
.row .ra { display: flex; gap: 6px; }
.row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--lime); cursor: pointer; }
@media (max-width: 560px) {
  .row { grid-template-columns: auto 44px 1fr; }
  .row .rt { width: 44px; height: 44px; }
  .row .ra { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ================================================================
   VIEWER (modal)
   ================================================================ */
.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 4, 14, .96);
  backdrop-filter: blur(12px);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.v-top, .v-bottom { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.v-top h3 {
  margin: 0; flex: 1; font-size: 16px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v-x {
  background: var(--pink); color: #0b0715; border: 2px solid #000;
  width: 40px; height: 40px; border-radius: 12px;
  font-weight: 900; font-size: 18px; cursor: pointer;
}
.v-stage {
  flex: 1; min-height: 0; display: grid; place-items: center;
  padding: 0 16px; position: relative;
}
.v-stage > img { max-width: 100%; max-height: 100%; border-radius: var(--r); object-fit: contain; }
.v-stage > video { width: 100%; max-height: 100%; border-radius: var(--r); background: #000; }
.v-frame { width: 100%; height: 100%; border: 0; border-radius: var(--r); background: #fff; }
.v-text {
  width: 100%; height: 100%; margin: 0; overflow: auto;
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--r); padding: 16px;
  font: 13px/1.5 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.v-none { text-align: center; color: var(--muted); font-weight: 700; }
.v-none .big { font-size: 70px; }
.v-audio { display: grid; gap: 26px; justify-items: center; width: 100%; max-width: 460px; }
.v-audio audio { width: 100%; }
.vinyl {
  width: min(62vw, 260px); aspect-ratio: 1; border-radius: 50%;
  background: repeating-radial-gradient(circle, #111 0 3px, #1b1b1b 3px 6px);
  border: 3px solid #000; box-shadow: 8px 8px 0 var(--lime);
  display: grid; place-items: center;
}
.vinyl i {
  width: 34%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #111 0 7%, var(--pink) 8% 100%);
  border: 3px solid #000;
}
.vinyl.playing { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.v-bottom { justify-content: space-between; flex-wrap: wrap; }
.v-meta { color: var(--muted); font-weight: 600; font-size: 13px; }
.v-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: #000b; border: 2px solid var(--line); color: var(--ink);
  width: 44px; height: 56px; border-radius: 12px;
  font-size: 22px; cursor: pointer; z-index: 2;
}
.v-nav.l { left: 6px; }
.v-nav.r { right: 6px; }
@media (max-width: 640px) { .v-nav { opacity: .8; width: 38px; } }

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed; left: 50%;
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); z-index: 200;
  background: var(--lime); color: #0b0715;
  border: 2px solid #000; box-shadow: 0 4px 0 var(--pink);
  padding: 10px 18px; border-radius: 999px; font-weight: 800;
  max-width: 90vw; font-size: 14px;
  animation: toastIn .2s ease-out;
}
@media (min-width: 960px) { .toast { bottom: 24px; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* utility */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.center { text-align: center; }
.gap-8 { display: grid; gap: 8px; }
.gap-12 { display: grid; gap: 12px; }
.gap-16 { display: grid; gap: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }

/* ================================================================
   PHASE 5: sticker tray, voice notes, notifications, settings
   ================================================================ */

/* sticker tray modal */
.tray-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(6,4,14,.7);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px;
  animation: fadeIn .15s;
}
.tray {
  background: var(--card); border: 2px solid #000; border-radius: var(--r-lg);
  width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 8px 8px 0 var(--pink); overflow: hidden;
}
.tray-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 2px solid var(--line);
}
.tray-head h3 { margin: 0; flex: 1; font-size: 17px; }
.tray-tabs { display: flex; gap: 4px; padding: 10px 12px; background: var(--bg-2); }
.tray-tab {
  flex: 1; background: transparent; border: none; padding: 8px; border-radius: 8px;
  font-size: 13px; font-weight: 800; color: var(--muted); cursor: pointer;
}
.tray-tab.on { background: var(--card); color: var(--ink); }
.tray-body { padding: 16px; overflow-y: auto; }
.tray-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 10px;
}
.tray-item {
  position: relative; aspect-ratio: 1; background: var(--bg-2);
  border: 2px solid var(--line); border-radius: 12px;
  display: grid; place-items: center; overflow: hidden;
  cursor: pointer; transition: transform .12s, border-color .12s;
}
.tray-item:hover { transform: scale(1.04); border-color: var(--lime); }
.tray-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tray-item .del {
  position: absolute; top: 2px; right: 2px;
  background: var(--pink); color: #0b0715; border: 1px solid #000;
  border-radius: 6px; font-size: 10px; width: 20px; height: 20px;
  font-weight: 900; cursor: pointer; display: none; align-items: center; justify-content: center;
}
.tray-item:hover .del { display: inline-flex; }
.tray-form { display: grid; gap: 10px; }
.tray-form input[type=text], .tray-form input[type=file] {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-2); border: 2px solid var(--line); color: var(--ink);
  outline: none;
}
.tray-form input[type=text]:focus { border-color: var(--lime); }
.tray-empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.tray-hint { font-size: 12px; color: var(--muted-2); margin-top: 8px; }

/* voice note message */
.voice-msg { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.voice-msg .wave {
  display: flex; align-items: center; gap: 2px; height: 24px; flex: 1;
}
.voice-msg .wave i {
  width: 3px; background: currentColor; border-radius: 2px; opacity: .7;
}
.voice-msg.playable .wave i { animation: wave 1.2s ease-in-out infinite alternate; }
.voice-msg.playable .wave i:nth-child(2n) { animation-delay: .15s; }
.voice-msg.playable .wave i:nth-child(3n) { animation-delay: .3s; }
@keyframes wave { from { height: 4px; } to { height: 22px; } }
.voice-msg .play-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--lime); color: #0b0715; border: 2px solid #000;
  font-size: 14px; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 2px 0 #000;
}
.msg.mine .voice-msg .play-btn { background: #0b0715; color: var(--lime); }
.voice-msg .dur { font-size: 12px; font-weight: 700; }

/* mic button in chat */
.chat-form .mic-btn {
  background: var(--pink); color: #0b0715; border: 2px solid #000;
  border-radius: 12px; padding: 0 14px; font-size: 18px;
  cursor: pointer; box-shadow: 0 3px 0 #000; transition: all .1s;
}
.chat-form .mic-btn:active, .chat-form .mic-btn.recording {
  background: #ff2d55; color: #fff;
  box-shadow: 0 0 0 #000; transform: translate(2px, 2px);
  animation: recPulse .9s ease-in-out infinite;
}
@keyframes recPulse { 50% { box-shadow: 0 0 0 6px rgba(255,45,85,.35); } }
.rec-status {
  position: absolute; bottom: 100%; left: 12px;
  background: #000d; color: var(--pink);
  padding: 6px 12px; border-radius: 10px; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.rec-status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--pink);
  animation: pulse 1s ease-in-out infinite;
}

/* chat search */
.chat-search {
  padding: 8px 12px; background: var(--bg-2); border-bottom: 2px solid var(--line);
  display: flex; gap: 8px;
}
.chat-search input {
  flex: 1; background: var(--card); border: 2px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; outline: none;
}
.chat-search input:focus { border-color: var(--cyan); }
.chat-search button {
  background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 16px;
}

/* airdrop row actions */
.row .ra button.airdrop { background: var(--purple); color: #0b0715; }

/* settings page */
.settings-section {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 18px; margin-bottom: 14px;
}
.settings-section h3 {
  margin: 0 0 14px; font-size: 15px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted);
}
.storage-warning {
  margin: 12px 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--orange) 55%, var(--line));
  border-radius: 10px; background: color-mix(in srgb, var(--orange) 9%, var(--card));
  color: var(--ink); overflow-wrap: anywhere;
}
.storage-warning p { margin: 4px 0; }
.avatar-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-swatch {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid #000;
  cursor: pointer; transition: transform .12s;
  display: grid; place-items: center; color: #0b0715; font-weight: 900;
}
.avatar-swatch:hover { transform: scale(1.1); }
.avatar-swatch.on { outline: 3px solid var(--lime); outline-offset: 2px; }

/* ================================================================
   PHASE 5.1: avatar images, paste-to-import hint
   ================================================================ */
.av.has-img {
  overflow: hidden; padding: 0;
  background-size: cover; background-position: center;
  color: transparent;
}
.av.has-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.paste-zone {
  border: 2px dashed var(--line); border-radius: 12px;
  padding: 24px; text-align: center; color: var(--muted);
  font-size: 13px; font-weight: 700;
  transition: border-color .12s, background .12s;
  cursor: text;
}
.paste-zone:focus, .paste-zone.focused {
  border-color: var(--lime); background: rgba(200,255,61,.06); outline: none;
}
.paste-zone kbd {
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 6px; font-family: var(--mono); font-size: 12px;
}
.avatar-upload-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%;
  border: 3px solid #000; overflow: hidden;
  display: grid; place-items: center;
  font-weight: 900; font-size: 26px; color: #0b0715;
  flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }


/* ================================================================
   PWA: install + update banners
   ================================================================ */
.install-banner,
.update-banner {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 2px solid #000;
  box-shadow: 0 4px 0 var(--lime);
  border-radius: 16px;
  padding: 10px 12px;
  max-width: calc(100vw - 32px);
  width: 420px;
  animation: toastIn .25s ease-out;
}
.update-banner { box-shadow: 0 4px 0 var(--cyan); }
.install-banner .install-emoji,
.update-banner .install-emoji { font-size: 24px; }
.install-banner .install-text,
.update-banner .install-text { flex: 1; min-width: 0; }
.install-banner .install-text b,
.update-banner .install-text b { display: block; font-size: 14px; }
.install-banner .install-text small,
.update-banner .install-text small { color: var(--muted); font-size: 12px; font-weight: 600; }
.install-banner .btn,
.update-banner .btn { box-shadow: 0 2px 0 #000; }
.install-banner .icon-btn,
.update-banner .icon-btn { width: 30px; height: 30px; font-size: 14px; border-width: 2px; }
@media (min-width: 960px) {
  .install-banner, .update-banner { bottom: 20px; }
}

/* ================================================================
   Avatar crop modal — WhatsApp-style
   ================================================================ */
.crop-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(6,4,14,.94); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn .15s;
}
.crop-card {
  background: var(--card); border: 2px solid #000; border-radius: 22px;
  padding: 18px; width: min(420px, 100%);
  box-shadow: 8px 8px 0 var(--cyan);
  display: flex; flex-direction: column; gap: 14px;
}
.crop-card h3 { margin: 0; font-size: 16px; text-align: center; }
.crop-stage {
  position: relative; width: 100%; aspect-ratio: 1;
  background: #000; border-radius: 50%; overflow: hidden;
  touch-action: none; cursor: grab;
  border: 3px solid var(--line);
  user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.crop-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px dashed rgba(200,255,61,.35);
  pointer-events: none;
  box-shadow: inset 0 0 0 9999px rgba(0,0,0,.28);
}
.crop-help {
  font-size: 11px; color: var(--muted-2); text-align: center;
  font-weight: 700; letter-spacing: .3px;
}
.crop-actions { display: flex; gap: 8px; justify-content: center; }
.crop-actions .btn { flex: 1; justify-content: center; }
  /* ================================================================
   Phase 2: reply threading + swipe-to-reply
   ================================================================ */
.msg { position: relative; }
.msg .quote {
  display: block;
  border-left: 3px solid var(--cyan);
  background: rgba(77, 227, 255, .07);
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.mine .quote { border-left-color: #0b0715; background: rgba(0,0,0,.12); color: #17102b; }
.msg .quote b { color: var(--ink); font-weight: 800; }
.msg.mine .quote b { color: #17102b; }
.msg .quote:hover { filter: brightness(1.15); }
.msg.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0%, 40% { background: rgba(200,255,61,.22); box-shadow: inset 0 0 0 2px var(--lime); }
  100%    { background: transparent; box-shadow: none; }
}

.msg .reply-btn {
  position: absolute;
  top: 4px;
  right: -32px;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--card);
  border: 2px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .15s, border-color .15s, color .15s;
}
.msg:hover .reply-btn { opacity: 1; }
.msg.mine .reply-btn { left: -32px; right: auto; }
.msg .reply-btn:hover { border-color: var(--lime); color: var(--ink); }
@media (hover: none) { .msg .reply-btn { display: none; } }

/* swipe indicator */
.msg.swiping { background: rgba(200,255,61,.08); border-radius: 12px; }
.msg .swipe-hint {
  position: absolute;
  top: 50%; right: -44px; transform: translateY(-50%);
  font-size: 20px;
  color: var(--lime);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.msg.swiping .swipe-hint { opacity: 1; }

/* reply composer banner */
.reply-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: rgba(77, 227, 255, .09);
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  font-size: 13px;
}
.reply-banner .r-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.reply-banner .r-text b { color: var(--ink); font-weight: 800; }
.reply-banner .r-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 0 4px;
}
.reply-banner .r-close:hover { color: var(--pink); }


/* ================================================================
   Phase 3: delete + moderator toggles
   ================================================================ */
.msg-menu {
  position: fixed; z-index: 150;
  background: var(--card); border: 2px solid #000;
  border-radius: 12px; box-shadow: 0 4px 0 var(--pink);
  min-width: 140px; padding: 4px;
  display: flex; flex-direction: column;
  animation: fadeIn .1s ease-out;
}
.msg-menu button {
  background: transparent; border: none;
  padding: 8px 12px; text-align: left;
  color: var(--ink); font-weight: 700; font-size: 13px;
  border-radius: 8px; cursor: pointer;
}
.msg-menu button:hover { background: var(--card-2); }
.msg-menu button.danger { color: var(--pink); }

.mod-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 2px solid var(--line); border-radius: 10px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  cursor: pointer; user-select: none;
}
.mod-toggle input[type=checkbox] {
  width: 16px; height: 16px; accent-color: var(--lime); cursor: pointer;
}
.mod-toggle:hover { border-color: var(--lime); color: var(--ink); }

/* ================================================================
   Phase 4 — new chat UI + link previews
   ================================================================ */
.chat-log {
  gap: 4px;
  padding: 16px 12px 12px;
}

/* day divider */
.day-divider {
  display: flex; align-items: center; justify-content: center;
  margin: 16px 0 10px;
  position: relative;
}
.day-divider::before, .day-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line); opacity: .6;
}
.day-divider span {
  padding: 3px 12px; margin: 0 12px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-weight: 800;
  border-radius: 99px; text-transform: lowercase;
}

/* message rows */
.msg {
  display: flex; gap: 8px; align-items: flex-end;
  position: relative; padding: 2px 0;
  animation: msgIn .22s ease-out both;
}
.msg.mine { flex-direction: row-reverse; }
.msg-avatar { width: 34px; flex-shrink: 0; }
.msg.mine .msg-avatar:empty { display: none; }
.msg-body {
  max-width: min(72%, 560px);
  display: flex; flex-direction: column;
  position: relative;
}
.msg.mine .msg-body { align-items: flex-end; }
.msg-name {
  font-size: 12px; font-weight: 800; color: var(--muted);
  margin: 0 6px 3px;
}

/* bubbles */
.bubble {
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  position: relative;
}
.msg.mine .bubble {
  background: var(--lime); color: #0b0715;
  border-color: #000;
}

/* tails */
.msg.tail-l .bubble { border-bottom-left-radius: 6px; }
.msg.tail-r .bubble { border-bottom-right-radius: 6px; }
.msg.tail-l .bubble::before {
  content: ""; position: absolute;
  left: -8px; bottom: 0;
  width: 14px; height: 14px;
  background: var(--card-2); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  border-bottom-left-radius: 20px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.msg.mine.tail-r .bubble::before {
  content: ""; position: absolute;
  right: -8px; bottom: 0;
  width: 14px; height: 14px;
  background: var(--lime); border-right: 1px solid #000; border-bottom: 1px solid #000;
  border-bottom-right-radius: 20px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

/* quote (reply context) */
.quote {
  display: flex; flex-direction: column;
  background: rgba(77,227,255,.08);
  border-left: 3px solid var(--cyan);
  padding: 6px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.3;
}
.msg.mine .quote {
  background: rgba(0,0,0,.14);
  border-left-color: #0b0715;
}
.quote b {
  color: var(--cyan);
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px;
}
.msg.mine .quote b { color: #17102b; }
.quote span {
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg.mine .quote span { color: #17102b; opacity: .8; }

/* stickers */
.sticker {
  font-size: 64px;
  line-height: 1;
  padding: 4px;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
.bubble-sticker { background: transparent !important; border: none !important; padding: 0 !important; }
.bubble-sticker img {
  max-width: 180px; max-height: 180px;
  border-radius: 14px; display: block;
}

/* voice */
.bubble-voice {
  display: flex; align-items: center; gap: 10px;
  min-width: 200px;
  padding: 10px 14px;
}
.bubble-voice .play-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--lime); color: #0b0715; border: 2px solid #000;
  font-size: 13px; cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 0 #000;
}
.msg.mine .bubble-voice .play-btn { background: #0b0715; color: var(--lime); }
.bubble-voice .wave {
  display: flex; align-items: center; gap: 2px;
  height: 26px; flex: 1;
}
.bubble-voice .wave i {
  width: 3px; background: currentColor; border-radius: 2px; opacity: .6;
}
.bubble-voice .dur { font-size: 12px; font-weight: 800; }

/* under-bubble row (time + reactions) */
.msg-under {
  display: flex; align-items: center; gap: 8px;
  margin-top: 3px;
  font-size: 11px; color: var(--muted);
  padding: 0 4px;
}
.msg.mine .msg-under { flex-direction: row-reverse; }
.msg-time { opacity: 0; transition: opacity .15s; font-weight: 700; }
.msg:hover .msg-time { opacity: 1; }
.reactions { display: flex; gap: 3px; flex-wrap: wrap; }
.reactions:empty { display: none; }
.reactions span {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 99px; padding: 1px 7px;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
}
.reactions span:hover { border-color: var(--lime); }

/* hover react row */
.react-row {
  display: flex; gap: 2px;
  opacity: 0; margin-top: 3px;
  transition: opacity .15s;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 4px;
  width: max-content;
}
.msg:hover .react-row { opacity: 1; }
.react-row button {
  background: transparent; border: none;
  font-size: 14px; cursor: pointer; padding: 1px 3px;
  border-radius: 6px;
}
.react-row button:hover { background: var(--card-2); }

/* reply button (desktop) */
.reply-btn {
  position: absolute; top: 6px;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
  cursor: pointer; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s;
  z-index: 2;
}
.msg:not(.mine) .reply-btn { right: -32px; }
.msg.mine .reply-btn { left: -32px; }
.msg:hover .reply-btn { opacity: 1; }
.reply-btn:hover { border-color: var(--lime); color: var(--ink); }
@media (hover: none) { .reply-btn { display: none; } }

/* flash on jump */
.msg.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0%, 40% { background: rgba(200,255,61,.18); }
  100%    { background: transparent; }
}

/* typing */
.typing-line {
  padding: 0 20px 6px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  min-height: 20px;
}

/* jump to latest pill */
.jump-latest {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: 88px;
  background: var(--pink); color: #17102b;
  border: 2px solid #000; border-radius: 999px;
  padding: 6px 14px; font-size: 12px; font-weight: 800;
  cursor: pointer; z-index: 5;
  box-shadow: 0 3px 0 #000;
  animation: jumpPulse 1.6s ease-in-out infinite;
}
@keyframes jumpPulse { 50% { transform: translate(-50%, -2px); } }

/* link preview card */
.link-card {
  display: block;
  margin-top: 6px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  max-width: 320px;
  transition: border-color .12s;
}
.link-card:hover { border-color: var(--lime); }
.msg.mine .link-card { background: rgba(0,0,0,.14); border-color: rgba(0,0,0,.3); color: #17102b; }
.lc-img { background: var(--bg-2); overflow: hidden; }
.lc-img img { width: 100%; height: 160px; object-fit: cover; display: block; }
.lc-body { padding: 9px 12px 11px; }
.lc-site { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 3px; }
.lc-title { font-size: 13px; font-weight: 800; line-height: 1.3; margin-bottom: 3px; }
.lc-desc { font-size: 12px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg.mine .lc-site { color: #17102b; opacity: .7; }
.msg.mine .lc-desc { color: #17102b; opacity: .8; }
.link-image { background: transparent; border: none; max-width: 240px; margin-top: 6px; }
.link-image img { border-radius: 12px; max-width: 240px; max-height: 240px; object-fit: cover; display: block; border: 1px solid var(--line); }

/* msg menu */
.msg-menu {
  position: fixed; z-index: 150;
  background: var(--card); border: 2px solid #000;
  border-radius: 12px; box-shadow: 0 4px 0 var(--pink);
  min-width: 150px; padding: 4px;
  display: flex; flex-direction: column;
  animation: fadeIn .1s ease-out;
}
.msg-menu button {
  background: transparent; border: none;
  padding: 8px 12px; text-align: left;
  color: var(--ink); font-weight: 700; font-size: 13px;
  border-radius: 8px; cursor: pointer;
}
.msg-menu button:hover { background: var(--card-2); }
.msg-menu button.danger { color: var(--pink); }

/* ================================================================
   Phase 5 — swipe-to-reply + search results
   ================================================================ */
.chat-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
}
.chat-search input {
  flex: 1;
  background: var(--card); border: 2px solid var(--line);
  border-radius: 999px; padding: 8px 14px;
  font-size: 13px; outline: none;
}
.chat-search input:focus { border-color: var(--cyan); }
.search-count {
  font-size: 11px; color: var(--muted); font-weight: 800;
  white-space: nowrap;
}
.chat-search button {
  background: transparent; border: none;
  color: var(--muted); font-size: 16px; cursor: pointer;
  padding: 0 4px;
}

/* swipe */
.msg {
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.2);
  will-change: transform;
}
.msg.swiping-now { transition: none; }
.msg.swipe-armed { transition: transform .12s ease-out; }
.msg.swiping-now::after {
  content: "↩";
  position: absolute;
  left: -34px; top: 50%; transform: translateY(-50%);
  font-size: 22px;
  color: var(--lime);
  opacity: 0;
  transition: opacity .1s;
}
.msg.mine.swiping-now::after { left: auto; right: -34px; }
.msg.swiping-now { transition: none; }
.msg.swipe-armed::after { opacity: 1 !important; }

/* prevent text selection while dragging */
.msg.swiping-now * { user-select: none; }

/* ================================================================
   Block 1 — emoji picker
   ================================================================ */
.emoji-btn {
  background: var(--card); color: var(--ink); border: 2px solid var(--line);
  border-radius: 12px; padding: 0 12px; font-size: 18px;
  cursor: pointer; box-shadow: 0 3px 0 #000;
  transition: border-color .12s;
}
.emoji-btn:hover { border-color: var(--lime); }

.emoji-picker {
  position: absolute;
  bottom: 100%; left: 8px; right: 8px;
  margin-bottom: 8px;
  max-height: 280px;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 0 #000;
  overflow-y: auto;
  padding: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px;
}
.emoji-picker button {
  background: transparent; border: none;
  font-size: 22px; line-height: 1;
  padding: 4px; border-radius: 8px;
  cursor: pointer;
  transition: transform .1s, background .1s;
}
.emoji-picker button:hover {
  background: var(--card); transform: scale(1.2);
}

/* ================================================================
   Block 2 — sticker pack chips
   ================================================================ */
.tray-packs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  background: var(--bg);
}
.tray-pack {
  background: var(--card); border: 2px solid var(--line);
  border-radius: 999px; padding: 4px 12px;
  font-size: 12px; font-weight: 800;
  color: var(--muted); cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.tray-pack:hover { border-color: var(--lime); color: var(--ink); }
.tray-pack.on { background: var(--lime); color: #0b0715; border-color: var(--lime); }
.tray-pack .cnt {
  background: rgba(0,0,0,.2); border-radius: 99px;
  padding: 1px 6px; margin-left: 4px;
  font-size: 10px;
}
.tray-pack.on .cnt { background: rgba(0,0,0,.25); }

.pack-input {
  width: 100%;
  background: var(--bg-2); border: 2px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 13px;
  outline: none; color: var(--ink);
}
.pack-input:focus { border-color: var(--lime); }

/* ================================================================
   Block 3 — waveform seek
   ================================================================ */
.bubble-voice .wave {
  cursor: pointer;
  position: relative;
  padding: 4px 0;
  border-radius: 4px;
  transition: background .1s;
}
.bubble-voice .wave:hover { background: rgba(255,255,255,.04); }
.bubble-voice .wave i {
  width: 3px; background: currentColor;
  border-radius: 2px; opacity: .35;
  transition: opacity .15s, background .15s;
  pointer-events: none;
}
.bubble-voice .wave i.played { opacity: 1; }
.msg.mine .bubble-voice .wave i.played { background: #0b0715; }
.bubble-voice .wave i.playing-now {
  opacity: 1;
  box-shadow: 0 0 6px currentColor;
}

/* ================================================================
   Block 4 — thread view
   ================================================================ */
.thread-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--line);
  background: var(--bg-2);
}
.thread-header .chip { margin: 0; }
.thread-label { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ================================================================
   Block 1 — file folders
   ================================================================ */
.folders {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.folder-tile {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 2px solid #000;
  border-radius: 14px; padding: 10px 14px;
  cursor: pointer; font-weight: 800; font-size: 14px;
  box-shadow: 0 3px 0 var(--orange);
  transition: transform .12s;
}
.folder-tile:hover { transform: translateY(-2px); }
.folder-tile .fc { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 2px; }
.folder-tile .ficon { font-size: 20px; }
.folder-tile.active {
  background: var(--lime); color: #0b0715; border-color: var(--lime);
}
.folder-tile.active .fc { color: #17102b; opacity: .7; }
.folder-back {
  background: transparent; border: 2px dashed var(--line);
  color: var(--muted); border-radius: 14px;
  padding: 8px 14px; font-size: 13px; font-weight: 800;
  cursor: pointer;
}
.folder-back:hover { border-color: var(--lime); color: var(--ink); }

/* ================================================================
   Block 2 — custom emoji
   ================================================================ */
.emoji-picker .ce-section {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
}
.emoji-picker .ce-section::before,
.emoji-picker .ce-section::after {
  content: ""; flex: 1; height: 1px; background: var(--line); opacity: .5;
}
.emoji-picker button.ce {
  padding: 2px;
}
.emoji-picker button.ce img {
  width: 24px; height: 24px; object-fit: contain; display: block;
}
.inline-emoji {
  display: inline-block;
  width: 1.1em; height: 1.1em;
  vertical-align: -0.15em;
  object-fit: contain;
  margin: 0 1px;
}
.reactions span img {
  width: 14px; height: 14px;
  vertical-align: -2px;
  object-fit: contain;
  margin-right: 2px;
}
.react-row button img {
  width: 16px; height: 16px;
  vertical-align: -3px;
  object-fit: contain;
}
/* Community polls */
.poll-create,.poll-card{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:18px;margin-bottom:16px}
.poll-create h2{font-size:16px;margin:0 0 14px}.poll-option-inputs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:12px}
.poll-create-actions{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:14px}.poll-note{font-size:11px;color:var(--muted);margin:10px 0 0}.poll-card-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.poll-card-head small{color:var(--muted);font-size:11px}.poll-card-head h3{font-size:16px;margin:6px 0 14px;overflow-wrap:anywhere}.poll-state{font-size:10px;color:var(--muted);white-space:nowrap;background:var(--card-2);padding:5px 8px;border-radius:20px}.poll-state.closed{color:var(--pink)}
.poll-options{display:grid;gap:8px}.poll-choice{width:100%;text-align:left;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--card-2);color:var(--ink);font:inherit;cursor:pointer}.poll-choice:hover{border-color:var(--lime);background:var(--card)}.poll-choice:disabled{opacity:.5}.poll-result-label{display:flex;justify-content:space-between;gap:10px;font-size:13px;margin-bottom:5px}.poll-result-label b{font-size:12px;color:var(--muted);white-space:nowrap}.poll-track{height:8px;background:var(--card-2);border-radius:99px;overflow:hidden}.poll-track i{display:block;height:100%;background:var(--cyan);border-radius:99px}.poll-result.mine .poll-track i{background:var(--lime)}.poll-card-foot{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:14px;color:var(--muted);font-size:11px}
@media(max-width:600px){.poll-option-inputs{grid-template-columns:1fr}.poll-create,.poll-card{padding:14px}.poll-card-head{display:block}.poll-state{display:inline-block;margin-bottom:8px}}

/* Ephemeral stories */
.story-compose,.story-card{background:var(--card);border:1px solid var(--line);border-radius:18px;padding:18px;margin-bottom:16px}
.story-compose-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.story-compose h2{font-size:16px;margin:0 0 5px}.story-compose-head p{font-size:12px;color:var(--muted);margin:0 0 14px}.story-expiry{font-size:11px;font-weight:700;color:var(--lime);background:var(--card-2);border-radius:99px;padding:6px 10px}.story-compose textarea{width:100%;resize:vertical;min-height:90px;border:1px solid var(--line);border-radius:12px;padding:12px;background:var(--card-2);color:var(--ink);font:inherit;outline:none}.story-compose textarea:focus{border-color:var(--lime)}.story-compose-foot{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:12px}.story-compose-foot small,.story-card header small{font-size:11px;color:var(--muted)}.story-card header{display:flex;align-items:center;gap:10px}.story-card header b{display:block;font-size:13px}.story-card p{white-space:normal;overflow-wrap:anywhere;line-height:1.6;margin:16px 0 2px;font-size:14px}.story-card .icon-btn{font-size:20px}.story-compose .err{margin:8px 0 0}
@media(max-width:600px){.story-compose,.story-card{padding:14px}}

.story-reactions{display:flex;flex-wrap:wrap;gap:7px;margin-top:14px}.story-reaction{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--card-2);color:var(--ink);border-radius:99px;padding:6px 10px;cursor:pointer;font:inherit;font-size:13px}.story-reaction span{font-size:11px;color:var(--muted)}.story-reaction.selected{border-color:var(--lime);background:color-mix(in srgb,var(--lime) 12%,var(--card-2))}.story-reaction:disabled{opacity:.55;cursor:wait}

.story-audience{display:grid;gap:8px;margin-top:12px}.story-audience>label{font-size:12px;color:var(--muted)}.story-audience select{max-width:260px;border:1px solid var(--line);border-radius:10px;padding:9px;background:var(--card-2);color:var(--ink);font:inherit}.story-audience-people{display:flex;flex-wrap:wrap;gap:8px;max-height:150px;overflow:auto;padding:8px;border:1px solid var(--line);border-radius:12px}.story-person{display:inline-flex;align-items:center;gap:6px;padding:6px 9px;border-radius:99px;background:var(--card-2);font-size:12px}

.story-viewers{margin-top:12px;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--card-2)}.story-viewers>b{display:block;font-size:12px;margin-bottom:8px}.story-viewer{display:flex;justify-content:space-between;gap:10px;padding:6px 0;font-size:12px;border-top:1px solid var(--line)}.story-viewer small{color:var(--muted);font-size:10px}

.story-media-pick{display:flex;align-items:center;gap:10px;margin-top:12px;font-size:12px;color:var(--muted);cursor:pointer}.story-media-pick input{max-width:100%;font:inherit}.story-media-help{display:block;margin-top:5px;color:var(--muted);font-size:10px}.story-media{display:block;width:100%;max-height:520px;object-fit:contain;background:#08090b;border-radius:12px;margin-top:14px}
.crop-controls { display: flex; align-items: center; gap: 8px; }
.crop-controls input[type="range"] { flex: 1; min-width: 0; accent-color: var(--lime); }
.crop-controls .btn { min-width: 34px; padding-inline: 8px; }
.crop-actions { flex-wrap: wrap; }
.crop-actions .btn { min-width: 0; }
@media (max-width: 420px) {
  .crop-card { padding: 14px; gap: 11px; }
  .crop-actions .btn { flex: 1 1 38%; }
}

/* ================================================================
   COMFORT PASS — calmer contrast, softer surfaces, quieter motion
   ================================================================ */
:root {
  --bg: #11131b;
  --bg-2: #171a24;
  --card: #1c202c;
  --card-2: #252b38;
  --ink: #edf1f5;
  --muted: #a0aaba;
  --muted-2: #778394;
  --line: #343d4b;
  --lime: #a9dfc2;
  --pink: #e8a9c2;
  --cyan: #a8d5e3;
  --orange: #e8c38e;
  --purple: #b9b2e8;
  --shadow-btn: 0 2px 8px rgba(0, 0, 0, .18);
  --shadow-card: 0 8px 28px rgba(0, 0, 0, .16);
}
.blobs {
  background:
    radial-gradient(620px 520px at 0% 0%, rgba(232,169,194,.075), transparent 68%),
    radial-gradient(700px 600px at 100% 10%, rgba(168,213,227,.065), transparent 68%),
    radial-gradient(700px 700px at 50% 110%, rgba(169,223,194,.055), transparent 68%);
  animation-duration: 48s;
}
.brand { transform: none; }
.brand .box, .topbar .brand-mobile .box {
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: none;
}
.btn {
  color: #14221c;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  box-shadow: var(--shadow-btn);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-btn); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { border-color: var(--lime); }
.btn.danger, .btn.cyan { color: #20202a; }
.btn.small { box-shadow: none; }
.icon-btn {
  border-width: 1px;
  border-color: var(--line);
  box-shadow: none;
}
.icon-btn:hover { border-color: var(--lime); transform: none; background: var(--card-2); }
.nav-btn { border-width: 1px; }
.nav-btn.on { border-color: var(--line); background: rgba(255,255,255,.055); }
.me-card, .rail-card, .tile, .sticker-picker {
  border-width: 1px;
  box-shadow: var(--shadow-card);
}
.input, .field input, .search-input, .chat-form input {
  border-width: 1px;
  border-color: var(--line);
}
.input:focus, .field input:focus, .search-input:focus,
.chat-form input:focus, .chat-search input:focus,
.story-compose textarea:focus, .pack-input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(169,223,194,.13);
}
.chat-log { gap: 13px; padding: 18px; }
.msg { animation-duration: .18s; }
.msg .bubble {
  border: 1px solid var(--line);
  border-radius: 17px 17px 17px 6px;
  padding: 10px 14px;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.msg.mine .bubble {
  background: #355747;
  color: #f0f7f2;
  border-color: #527461;
  border-radius: 17px 17px 6px 17px;
}
.msg .meta { color: #aeb9c6; }
.msg .reactions span { background: var(--card); border-color: var(--line); }
.chat-form {
  border-top: 1px solid var(--line);
  background: rgba(17,19,27,.94);
  padding: 13px 16px max(13px, env(safe-area-inset-bottom, 0px));
}
.chat-form input { border-radius: 16px; padding: 12px 15px; }
.chat-form .send-btn, .chat-form .sticker-btn {
  color: #17221d;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  box-shadow: none;
}
.chat-form .send-btn:active, .chat-form .sticker-btn:active {
  box-shadow: none;
  transform: scale(.97);
}
.tabbar { border-top-width: 1px; }
@media (hover: hover) {
  .msg .react-row { opacity: .72; }
}
:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* ================================================================
   Step 1Q — calmer, more welcoming conversation experience
   ================================================================ */
.chat-page { min-height: 0; min-width: 0; }
.chat-log {
  min-height: 180px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.chat-empty {
  width: min(100%, 440px);
  margin: auto;
  padding: 34px 24px 42px;
  text-align: center;
  color: var(--muted);
}
.chat-empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 17px;
  border: 1px solid rgba(169,223,194,.24);
  border-radius: 20px;
  background: rgba(169,223,194,.08);
  color: var(--lime);
  font-size: 27px;
}
.chat-empty h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 700;
  letter-spacing: -.35px;
}
.chat-empty p {
  max-width: 340px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.7;
}
.chat-empty-hint {
  display: inline-block;
  margin-top: 16px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
}
.chat-empty-search { padding-top: 54px; }
.chat-empty-search .chat-empty-icon { font-size: 32px; }
.chat-form {
  align-items: center;
  gap: 9px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.chat-form input {
  min-width: 0;
  min-height: 46px;
  background: var(--card);
}
.chat-form .send-btn,
.chat-form .sticker-btn,
.chat-form .emoji-btn,
.chat-form .mic-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 18px;
  border-radius: 14px;
}
.chat-form .send-btn {
  background: var(--lime);
  color: #17221d;
  font-size: 23px;
  font-weight: 700;
}
.chat-form .send-btn:hover { filter: brightness(1.05); }
.chat-channels { scrollbar-width: thin; }
.chat-channels .channel-chip { min-height: 38px; }
.jump-latest {
  border: 1px solid rgba(255,255,255,.16);
  background: var(--card-2);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  animation: none;
}
@media (max-width: 600px) {
  .chat-page { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px)); }
  .chat-log { padding: 14px 12px 18px; gap: 11px; }
  .msg-body { max-width: 84%; }
  .chat-form { gap: 6px; padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
  .chat-form .send-btn,
  .chat-form .sticker-btn,
  .chat-form .emoji-btn,
  .chat-form .mic-btn { flex-basis: 40px; width: 40px; min-width: 40px; height: 42px; border-radius: 13px; }
  .chat-form input { min-height: 44px; padding: 10px 12px; font-size: 16px; }
  .chat-empty { padding: 28px 18px 34px; }
}
@media (max-width: 360px) {
  .chat-form { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .chat-form .sticker-btn { display: none; }
}

/* ================================================================
   Step 1R — consistent navigation and calmer page hierarchy
   ================================================================ */
.nav { gap: 6px; }
.nav-btn {
  min-height: 46px;
  padding: 10px 13px;
  border-radius: 13px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.nav-btn .ic { width: 24px; font-size: 19px; }
.nav-btn.on {
  position: relative;
  background: rgba(169,223,194,.09);
  border-color: rgba(169,223,194,.18);
}
.nav-btn.on::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--lime);
}
.tabbar {
  background: rgba(23,26,36,.94);
  border-top: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 -10px 32px rgba(0,0,0,.12);
}
.tab {
  min-width: 0;
  min-height: 56px;
  gap: 4px;
  padding: 7px 2px 5px;
  font-size: 10px;
  letter-spacing: .1px;
}
.tab .ic { font-size: 19px; transition: transform .16s ease; }
.tab.on .ic { transform: translateY(-1px); }
.tab.on::before {
  content: "";
  position: absolute;
  top: 0;
  width: 22px;
  height: 2px;
  border-radius: 0 0 4px 4px;
  background: var(--lime);
}
.content { min-width: 0; animation: page-arrive .18s ease-out both; }
@keyframes page-arrive {
  from { opacity: .72; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.topbar { border-bottom-color: rgba(255,255,255,.07); }
.me-card {
  background: rgba(255,255,255,.025);
  border-color: rgba(255,255,255,.08);
  box-shadow: none;
}
.nav-btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: -3px;
}
@media (max-width: 420px) {
  .tab { font-size: 9px; }
  .tab .ic { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .content { animation: none; }
  .tab .ic { transition: none; }
}


/* ================================================================
   Step 1S — responsive page context and consistent application shell
   ================================================================ */
.topbar {
  gap: 12px;
  padding-inline: clamp(12px, 2.2vw, 24px);
}
.topbar .brand-mobile {
  flex: 0 0 auto;
  width: 30px;
  justify-content: center;
}
.topbar h1.desktop-title {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(14px, 1.5vw, 17px);
  font-weight: 700;
  letter-spacing: -.25px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-spacer { flex: 0 0 clamp(0px, 1vw, 12px); }
.main { min-width: 0; }
.main > .topbar { isolation: isolate; }
.main[data-page] .content { min-height: calc(100vh - var(--topbar-h)); }
.icon-btn { flex: 0 0 40px; width: 40px; height: 40px; }
.icon-btn:focus-visible { outline-offset: 2px; }
@media (max-width: 420px) {
  .topbar { gap: 8px; padding-inline: 10px; }
  .topbar .brand-mobile { width: 27px; }
  .topbar .brand-mobile .box { width: 27px; height: 27px; }
  .topbar h1.desktop-title { font-size: 14px; }
  .icon-btn { flex-basis: 38px; width: 38px; height: 38px; }
}
@media (min-width: 960px) {
  .topbar .brand-mobile { display: none; }
  .topbar h1.desktop-title { font-size: 17px; }
}


/* ================================================================
   Step 1T — keyboard navigation and focus visibility
   ================================================================ */
.skip-link {
  position: fixed;
  z-index: 10000;
  top: 10px;
  left: 10px;
  padding: 11px 15px;
  border: 1px solid rgba(169,223,194,.5);
  border-radius: 12px;
  background: #202b28;
  color: #f0f7f2;
  box-shadow: 0 5px 22px rgba(0,0,0,.28);
  transform: translateY(-160%);
  transition: transform .14s ease;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
.main:focus { outline: none; }
.main:focus-visible { outline: 2px solid rgba(169,223,194,.55); outline-offset: -3px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  scroll-margin-block: 16px;
}
@media (prefers-reduced-motion: reduce) { .skip-link { transition: none; } }

/* ================================================================
   Step 1U — calm visual system across every application screen
   ================================================================ */
:root {
  --bg: #11151b;
  --bg-2: #171d25;
  --card: #1b232d;
  --card-2: #232e39;
  --ink: #edf2f4;
  --muted: #a2afb9;
  --muted-2: #7f8c97;
  --line: rgba(210,226,235,.13);
  --lime: #a9dfc2;
  --pink: #e7a9ba;
  --cyan: #9ccbd9;
  --orange: #e5c08e;
  --purple: #b9b3e8;
  --shadow-btn: 0 2px 8px rgba(0,0,0,.16);
  --shadow-card: 0 8px 28px rgba(0,0,0,.14);
}
body {
  background-color: var(--bg);
  line-height: 1.55;
}
.blobs {
  opacity: .34;
  background:
    radial-gradient(620px 520px at 0% 0%, rgba(169,223,194,.10), transparent 68%),
    radial-gradient(680px 560px at 100% 8%, rgba(156,203,217,.09), transparent 68%),
    radial-gradient(720px 680px at 50% 110%, rgba(185,179,232,.07), transparent 70%);
  animation-duration: 48s;
}
.topbar, .tabbar {
  background: rgba(17,21,27,.92);
  border-color: var(--line);
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}
.sidebar, .rightbar { border-color: var(--line); }
.sidebar { background: rgba(23,29,37,.94); }
.content { padding: clamp(14px, 2.4vw, 26px); }
.rail-card, .panel, .poll-card, .story-card, .me-card {
  border-color: var(--line);
  box-shadow: var(--shadow-card);
}
.rail-card, .panel, .poll-card, .story-card {
  border-radius: 18px;
}
.btn {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  box-shadow: var(--shadow-btn);
  font-weight: 700;
  min-height: 42px;
}
.btn:hover { box-shadow: 0 5px 14px rgba(0,0,0,.18); }
.btn.ghost { border-color: var(--line); }
.btn.danger, .btn.cyan { color: #172027; }
.icon-btn {
  border-width: 1px;
  border-color: var(--line);
  background: rgba(255,255,255,.035);
  transition: background .16s ease, border-color .16s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.075); border-color: rgba(169,223,194,.48); transform: none; }
.input, .field input, .field textarea, .field select, textarea, select {
  border-width: 1px;
  border-color: var(--line);
  background: rgba(10,14,19,.38);
  border-radius: 12px;
  min-height: 44px;
}
.input:focus, .field input:focus, .field textarea:focus, .field select:focus,
textarea:focus, select:focus, .search-input:focus {
  border-color: rgba(169,223,194,.78);
  box-shadow: 0 0 0 3px rgba(169,223,194,.10);
}
.field label, .field > span {
  color: var(--muted);
  letter-spacing: .35px;
}
.content h2 { line-height: 1.3; letter-spacing: -.25px; }
.content h3 { line-height: 1.35; }
.content p { line-height: 1.6; }
@media (max-width: 600px) {
  .content { padding: 13px 12px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .panel, .poll-card, .story-card { border-radius: 15px; }
  .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .blobs { animation: none; }
  .icon-btn, .btn { transition: none; }
}

/* ================================================================
   Step 1V — calmer page-level layouts and settings hierarchy
   ================================================================ */
.settings-section {
  background: linear-gradient(145deg, rgba(35,46,57,.72), rgba(27,35,45,.72));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(16px, 2.5vw, 22px);
  margin: 0 0 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
.settings-section h3 {
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.15px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.settings-section h3[style*="margin-top"] { margin-top: 18px !important; }
.settings-section .field { max-width: 100%; }
.settings-section form { width: 100%; }
.settings-section .avatar-upload-row { align-items: center; gap: 16px; }
.settings-section .avatar-preview {
  border: 2px solid rgba(237,242,244,.18);
  box-shadow: 0 5px 16px rgba(0,0,0,.18);
}
.settings-section .avatar-grid { gap: 10px; }
.settings-section .avatar-swatch {
  border: 2px solid rgba(237,242,244,.16);
  box-shadow: none;
  transition: border-color .15s ease, transform .15s ease;
}
.settings-section .avatar-swatch:hover { transform: translateY(-2px); }
.settings-section .avatar-swatch.on { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(169,223,194,.12); }
.settings-section [data-ce] {
  border: 1px solid var(--line) !important;
  background: rgba(255,255,255,.025) !important;
  border-radius: 12px !important;
}
.settings-section .btn { min-width: 112px; }
.settings-section .btn.danger { background: rgba(231,169,186,.12); border-color: rgba(231,169,186,.32); color: #f0c2ce; }
.settings-section .err { min-height: 1em; }
.poll-create, .poll-card, .story-card, .panel, .rail-card {
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
.poll-create { border-radius: 18px; }
.poll-create h2 { margin-top: 0; }
.poll-list { display: grid; gap: 14px; margin-top: 18px; }
.poll-card { margin: 0; }
.poll-card-head { gap: 12px; }
.poll-card-head h3 { overflow-wrap: anywhere; }
@media (min-width: 760px) {
  .settings-section { padding: 22px 24px; margin-bottom: 18px; }
  .settings-section form { max-width: 460px !important; }
}
@media (max-width: 420px) {
  .settings-section { padding: 14px; border-radius: 15px; }
  .settings-section .avatar-upload-row { align-items: flex-start; }
  .settings-section .btn { min-width: 0; }
  .poll-create { padding: 15px; }
  .poll-card-head { display: grid; grid-template-columns: minmax(0,1fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  .settings-section .avatar-swatch { transition: none; }
  .settings-section .avatar-swatch:hover { transform: none; }
}

/* Step 1W — calmer message grouping and always-readable timestamps */
.chat-log { row-gap: 7px; }
.msg { column-gap: 9px; }
.msg.is-grouped { padding-top: 0; margin-top: -3px; }
.msg.is-grouped .msg-name { display: none; }
.msg.is-grouped .msg-avatar { visibility: hidden; }
.msg.is-grouped .bubble { border-radius: 13px 17px 17px 13px; }
.msg.mine.is-grouped .bubble { border-radius: 17px 13px 13px 17px; }
.msg .msg-time { opacity: .78; font-size: 10.5px; font-weight: 600; }
.msg:hover .msg-time, .msg:focus-within .msg-time { opacity: 1; }
.msg .msg-under { min-height: 16px; gap: 7px; }
.msg .msg-name { letter-spacing: .01em; font-weight: 700; }
.msg .bubble { max-width: 100%; }
@media (max-width: 600px) {
  .msg-body { max-width: 86%; }
  .msg .msg-time { opacity: .82; }
  .msg .react-row { opacity: .86; }
  .msg.is-grouped { margin-top: -5px; }
}
@media (prefers-reduced-motion: reduce) {
  .msg, .msg .msg-time, .msg .react-row { animation: none !important; transition: none !important; }
}

/* Step 1X — comfortable composer and clear reply context */
.chat-form {
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(17,21,27,.96);
  backdrop-filter: blur(14px);
}
.chat-form:focus-within {
  border-top-color: rgba(169,223,194,.28);
}
.chat-form input {
  min-width: 0;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid rgba(210,226,235,.14);
  border-radius: 17px;
  background: #202a34;
  color: var(--ink);
  line-height: 1.45;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}
.chat-form input::placeholder { color: #91a0ac; opacity: 1; }
.chat-form input:focus {
  border-color: rgba(169,223,194,.72);
  box-shadow: 0 0 0 3px rgba(169,223,194,.10);
}
.chat-form .sticker-btn,
.chat-form .emoji-btn,
.chat-form .mic-btn,
.chat-form .send-btn {
  flex-shrink: 0;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.chat-form .sticker-btn,
.chat-form .emoji-btn,
.chat-form .mic-btn {
  background: rgba(255,255,255,.045);
  color: var(--ink);
  border: 1px solid var(--line);
}
.chat-form .sticker-btn:hover,
.chat-form .emoji-btn:hover,
.chat-form .mic-btn:hover {
  background: rgba(169,223,194,.10);
  border-color: rgba(169,223,194,.36);
}
.chat-form .send-btn { box-shadow: 0 3px 10px rgba(169,223,194,.12); }
.reply-banner {
  gap: 12px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  background: rgba(169,223,194,.065);
  font-size: 12px;
}
.reply-banner .r-text { line-height: 1.5; }
.reply-context-label { color: var(--muted-2); }
.reply-banner .r-text b { color: var(--lime); font-weight: 700; }
.reply-context-preview { color: var(--muted); }
.reply-banner .r-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid transparent;
  border-radius: 10px;
}
.reply-banner .r-close:hover,
.reply-banner .r-close:focus-visible {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255,255,255,.06);
}
@media (max-width: 600px) {
  .chat-form { gap: 6px; padding-top: 10px; }
  .chat-form input { min-height: 46px; padding-inline: 12px; }
  .reply-banner { padding: 8px 10px; }
}
@media (max-width: 360px) {
  .chat-form .emoji-btn, .chat-form .mic-btn,
  .chat-form .send-btn { flex-basis: 38px; width: 38px; min-width: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-form .sticker-btn, .chat-form .emoji-btn,
  .chat-form .mic-btn, .chat-form .send-btn { transition: none; }
}

/* Step 1Y — calm, useful connection feedback */
.connection-banner {
  margin: 0 0 10px;
  padding: 10px 13px;
  border: 1px solid rgba(229, 192, 142, .34);
  border-radius: 12px;
  background: rgba(229, 192, 142, .09);
  color: #e8d5b8;
  font-size: 13px;
  line-height: 1.45;
}
.connection-banner[data-state="offline"],
.connection-banner[data-state="disconnected"] {
  border-color: rgba(231, 169, 186, .38);
  background: rgba(231, 169, 186, .09);
  color: #f0c8d2;
}
.connection-banner[hidden] { display: none; }
@media (max-width: 600px) {
  .connection-banner { margin-bottom: 8px; padding: 9px 11px; font-size: 12px; }
}


/* Step 1Z — understated message delivery feedback */
.chat-send-status {
  min-height: 0;
  margin: 0 4px 6px;
  padding: 0 9px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}
.chat-send-status[hidden] { display: none; }
.chat-send-status[data-state="pending"] { color: var(--muted); }
.chat-send-status[data-state="success"] { color: var(--lime); }
.chat-send-status[data-state="error"] { color: #e7b2bf; }

/* Step 2A — consistent media-message delivery feedback */
.media-send-retry {
  margin-left: 8px;
  padding: 3px 9px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-2);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.media-send-retry:hover { border-color: var(--lime); }
.media-send-retry:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* Step 2L — expressive colour themes, framed chat and tasteful depth */
:root {
  --bg: #0b0715;
  --bg-2: #120d22;
  --card: #17122c;
  --card-2: #221a3f;
  --ink: #f4eeff;
  --muted: #b0a4d1;
  --muted-2: #8275a8;
  --line: #392b61;
  --lime: #c8ff3d;
  --pink: #ff5fa8;
  --cyan: #4de3ff;
  --orange: #ffa63d;
  --purple: #8a7dff;
  --shadow-btn: 0 4px 14px rgba(0,0,0,.22);
  --shadow-card: 0 14px 36px rgba(0,0,0,.24);
}
body { background-color: var(--bg); }
.blobs {
  opacity: .72;
  background:
    radial-gradient(650px 520px at 0% 0%, rgba(255,95,168,.18), transparent 68%),
    radial-gradient(700px 600px at 100% 8%, rgba(77,227,255,.14), transparent 68%),
    radial-gradient(720px 680px at 50% 110%, rgba(138,125,255,.14), transparent 70%);
  animation-duration: 34s;
}
.topbar, .tabbar { background: color-mix(in srgb, var(--bg) 90%, transparent); }
.sidebar { background: color-mix(in srgb, var(--card) 88%, transparent); }
.chat-page {
  position: relative;
  width: 100%;
  height: calc(100dvh - var(--topbar-h) - 44px);
  min-height: 360px;
  border: 1px solid color-mix(in srgb, var(--purple) 34%, var(--line));
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(155deg, color-mix(in srgb, var(--card) 94%, transparent), color-mix(in srgb, var(--bg-2) 94%, transparent));
  box-shadow: 0 22px 70px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.045);
  isolation: isolate;
}
.chat-page::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--pink), var(--cyan), transparent); opacity: .55;
}
.chat-page .chat-log { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--purple) 8%, transparent), transparent 60%); }
.chat-page .chat-form { background: color-mix(in srgb, var(--card) 94%, transparent); border-top: 1px solid var(--line); }
.chat-page .msg.mine .bubble { background: linear-gradient(135deg, color-mix(in srgb, var(--purple) 80%, #251b46), color-mix(in srgb, var(--pink) 28%, #251b46)); color: var(--ink); border-color: color-mix(in srgb, var(--purple) 48%, var(--line)); }
.chat-page .msg:not(.mine) .bubble { background: color-mix(in srgb, var(--card-2) 88%, var(--bg)); }
main[data-page="chat"] .content { max-width: none; padding: 18px clamp(14px, 2.4vw, 30px) 28px; }
@media (min-width: 960px) {
  .chat-page { height: calc(100dvh - var(--topbar-h) - 48px); }
  main[data-page="chat"] .content { padding-top: 16px; }
}
@media (max-width: 600px) {
  .chat-page { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px) - 18px); min-height: 300px; border-radius: 19px; }
  main[data-page="chat"] .content { padding: 10px 9px 18px; }
}
/* Theme presets: all share the same contrast and component rules. */
body[data-theme="ocean"] {
  --bg:#071521; --bg-2:#0b2031; --card:#10283b; --card-2:#17364d; --ink:#eafaff; --muted:#9cbacb; --muted-2:#6e91a7; --line:#24465d;
  --lime:#75e7d0; --pink:#55c9ed; --cyan:#78aaff; --orange:#ffd17c; --purple:#52bfd0;
}
body[data-theme="sunset"] {
  --bg:#1b1020; --bg-2:#28172c; --card:#302039; --card-2:#432846; --ink:#fff2eb; --muted:#d0aeb5; --muted-2:#a17e91; --line:#59364e;
  --lime:#ffca78; --pink:#ff806e; --cyan:#e7a3bd; --orange:#ffc16b; --purple:#c39bff;
}
body[data-theme="mint"] {
  --bg:#101b1a; --bg-2:#172824; --card:#1c302a; --card-2:#28443a; --ink:#edfff6; --muted:#a8cbbb; --muted-2:#789c8c; --line:#355648;
  --lime:#76d6b0; --pink:#d99acb; --cyan:#9bd9e5; --orange:#f0d9a8; --purple:#b8a6ff;
}
body[data-theme="ocean"] .blobs { background: radial-gradient(650px 520px at 0% 0%,rgba(40,199,217,.18),transparent 68%),radial-gradient(700px 600px at 100% 8%,rgba(104,168,255,.15),transparent 68%),radial-gradient(720px 680px at 50% 110%,rgba(179,244,236,.10),transparent 70%); }
body[data-theme="sunset"] .blobs { background: radial-gradient(650px 520px at 0% 0%,rgba(255,128,110,.19),transparent 68%),radial-gradient(700px 600px at 100% 8%,rgba(195,155,255,.15),transparent 68%),radial-gradient(720px 680px at 50% 110%,rgba(255,202,120,.11),transparent 70%); }
body[data-theme="mint"] .blobs { background: radial-gradient(650px 520px at 0% 0%,rgba(118,214,176,.17),transparent 68%),radial-gradient(700px 600px at 100% 8%,rgba(184,166,255,.14),transparent 68%),radial-gradient(720px 680px at 50% 110%,rgba(240,217,168,.09),transparent 70%); }
/* Real depth, restrained enough not to make reading tiring. */
.tile, .poll-card, .story-card, .rail-card, .settings-section { transform-style: preserve-3d; transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  .tile:hover, .poll-card:hover, .story-card:hover { transform: perspective(900px) rotateX(1.2deg) rotateY(-1deg) translateY(-4px); box-shadow: 0 20px 38px rgba(0,0,0,.28); }
  .settings-section:hover { border-color: color-mix(in srgb, var(--purple) 35%, var(--line)); }
  .nav-btn, .tab, .icon-btn, .btn { transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
  .nav-btn:hover { transform: translateX(3px); }
  .icon-btn:hover { transform: translateY(-2px) rotate(-3deg); }
}
.appearance-section { overflow: hidden; position: relative; background: linear-gradient(145deg, color-mix(in srgb, var(--card-2) 82%, transparent), color-mix(in srgb, var(--card) 90%, transparent)); }
.settings-heading-row { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.settings-heading-row h3 { margin-bottom:12px; }
.appearance-sparkle { color:var(--lime); font-size:28px; filter:drop-shadow(0 0 12px color-mix(in srgb,var(--lime) 65%,transparent)); }
.theme-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.theme-choice { min-width:0; display:grid; gap:7px; text-align:left; padding:12px; border:1px solid var(--line); border-radius:15px; background:color-mix(in srgb,var(--bg) 54%,transparent); color:var(--ink); cursor:pointer; transition:transform .18s ease,border-color .18s ease,background .18s ease; }
.theme-choice:hover { transform:translateY(-2px); border-color:var(--purple); }
.theme-choice.on { border-color:var(--lime); background:color-mix(in srgb,var(--lime) 8%,var(--card)); box-shadow:0 0 0 2px color-mix(in srgb,var(--lime) 15%,transparent); }
.theme-swatches { display:flex; gap:5px; }
.theme-swatches i { width:23px; height:23px; border-radius:8px; border:1px solid rgba(255,255,255,.16); box-shadow:inset 0 1px rgba(255,255,255,.15); }
.theme-choice b { font-size:13px; }
.theme-choice small { color:var(--muted); font-size:11px; }
.appearance-controls { display:flex; align-items:center; justify-content:space-between; gap:12px; padding-top:14px; margin-top:14px; border-top:1px solid var(--line); }
.appearance-controls div { display:grid; gap:3px; }
.appearance-controls b { font-size:13px; }
.appearance-controls small { color:var(--muted); font-size:11px; }
@media (max-width:420px) { .theme-grid { gap:8px; } .theme-choice { padding:10px; } .theme-swatches i { width:19px; height:19px; } }
body[data-motion="off"] *, body[data-motion="off"] *::before, body[data-motion="off"] *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; }
@media (prefers-reduced-motion:reduce) { .chat-page, .tile, .poll-card, .story-card, .settings-section, .theme-choice { transition:none !important; transform:none !important; } }

/* Step 2Q — immediate, removable story-media preview */
.story-upload-preview{display:flex;align-items:center;gap:12px;margin-top:12px;padding:10px;border:1px solid color-mix(in srgb,var(--lime) 34%,var(--line));border-radius:14px;background:linear-gradient(115deg,color-mix(in srgb,var(--pink) 10%,var(--card-2)),var(--card-2))}
.story-upload-preview[hidden]{display:none}
.story-upload-preview img,.story-upload-preview video{width:112px;height:84px;object-fit:cover;border-radius:10px;background:#08090b;flex:0 0 auto}
.story-upload-preview>div{display:grid;gap:5px;min-width:0}
.story-upload-preview b{font-size:12px;overflow-wrap:anywhere}
.story-upload-preview small{font-size:11px;color:var(--muted)}
.story-upload-preview .btn{justify-self:start;min-height:34px}
@media(max-width:420px){.story-upload-preview img,.story-upload-preview video{width:88px;height:72px}.story-upload-preview{align-items:flex-start}}
@media(prefers-reduced-motion:no-preference){.story-upload-preview{animation:story-preview-in .22s ease-out both}@keyframes story-preview-in{from{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:none}}}

/* Step 2Q — immediate, removable story-media preview */
.story-upload-preview{display:flex;align-items:center;gap:12px;margin-top:12px;padding:10px;border:1px solid color-mix(in srgb,var(--lime) 34%,var(--line));border-radius:14px;background:linear-gradient(115deg,color-mix(in srgb,var(--pink) 10%,var(--card-2)),var(--card-2))}
.story-upload-preview[hidden]{display:none}
.story-upload-preview img,.story-upload-preview video{width:112px;height:84px;object-fit:cover;border-radius:10px;background:#08090b;flex:0 0 auto}
.story-upload-preview>div{display:grid;gap:5px;min-width:0}
.story-upload-preview b{font-size:12px;overflow-wrap:anywhere}
.story-upload-preview small{font-size:11px;color:var(--muted)}
.story-upload-preview .btn{justify-self:start;min-height:34px}
@media(max-width:420px){.story-upload-preview img,.story-upload-preview video{width:88px;height:72px}.story-upload-preview{align-items:flex-start}}
@media(prefers-reduced-motion:no-preference){.story-upload-preview{animation:story-preview-in .22s ease-out both}@keyframes story-preview-in{from{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:none}}}

/* Step 2R — member discovery and compact profile cards */
.member-discovery-head { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin:4px 0 20px; }
.member-discovery-head h2 { margin:5px 0 6px; font-size:clamp(24px,4vw,34px); letter-spacing:-.04em; }
.member-discovery-head p { margin:0; max-width:540px; color:var(--muted); line-height:1.55; }
.member-discovery-head .eyebrow { color:var(--a,var(--violet)); font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.14em; }
.member-count { flex:none; padding:9px 12px; border:1px solid var(--line); border-radius:999px; color:var(--muted); background:var(--card); font-size:12px; font-weight:800; }
.member-discovery-tools { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
.member-search { display:flex; align-items:center; gap:9px; flex:1; min-width:0; padding:0 13px; min-height:46px; border:1px solid var(--line); border-radius:14px; background:var(--card); color:var(--muted); }
.member-search span { font-size:24px; line-height:1; }
.member-search input { width:100%; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font:inherit; }
.member-online-filter { display:flex; align-items:center; gap:7px; white-space:nowrap; color:var(--muted); font-size:13px; font-weight:750; }
.member-profile-card { min-height:82px; padding:13px 15px; border-radius:16px; transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease; }
.member-profile-card:hover { transform:translateY(-2px); border-color:var(--a,var(--violet)); box-shadow:0 9px 24px #0002; }
.member-avatar-wrap { position:relative; flex:none; }
.member-presence { position:absolute; right:-1px; bottom:1px; width:12px; height:12px; border:2px solid var(--card); border-radius:50%; background:#687080; }
.member-presence.is-online { background:var(--lime); box-shadow:0 0 0 3px color-mix(in srgb,var(--lime) 17%,transparent),0 0 12px color-mix(in srgb,var(--lime) 55%,transparent); }
.member-profile-copy { min-width:0; }
.member-profile-copy b { display:flex; align-items:center; flex-wrap:wrap; gap:7px; }
.member-profile-copy small { display:block; margin-top:5px; }
.member-role { padding:2px 7px; border-radius:99px; background:color-mix(in srgb,var(--a,var(--violet)) 18%,transparent); color:var(--a,var(--violet)); font-size:9px; letter-spacing:.07em; text-transform:uppercase; }
.member-role.moderator { color:var(--lime); background:color-mix(in srgb,var(--lime) 13%,transparent); }
.member-you { margin-left:auto; padding:5px 9px; border-radius:99px; background:var(--bg-2); color:var(--muted); font-size:11px; font-weight:850; }
.member-dm { margin-left:auto; flex:none; }
@media (max-width:560px) {
  .member-discovery-head { align-items:flex-start; flex-direction:column; gap:10px; }
  .member-discovery-tools { align-items:flex-start; flex-direction:column; }
  .member-search { width:100%; box-sizing:border-box; }
  .member-profile-card { gap:10px; padding:11px; }
  .member-profile-copy small { line-height:1.4; }
  .member-dm { padding:7px 9px; }
}
@media (prefers-reduced-motion:reduce) { .member-profile-card { transition:none; } .member-profile-card:hover { transform:none; } }

/* Step 2S — member-owned profile details */
.member-bio { margin:7px 0 0; color:var(--text); opacity:.78; font-size:12px; line-height:1.45; overflow-wrap:anywhere; }
.profile-save-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.profile-save-row .err { margin:0; }
.profile-edit-section textarea { resize:vertical; min-height:76px; }

/* Step 2T — richer member profile preview and conversation handoff */
.member-card-actions { display:flex; align-items:center; justify-content:flex-end; gap:7px; margin-left:auto; flex:none; }
.member-card-actions .member-dm { margin-left:0; }
.member-profile-backdrop { position:fixed; inset:0; z-index:1200; display:grid; place-items:center; padding:20px; background:rgba(5,7,16,.76); backdrop-filter:blur(12px); animation:member-profile-fade .16s ease-out both; }
.member-profile-dialog { position:relative; width:min(100%,390px); box-sizing:border-box; padding:30px 26px 25px; border:1px solid color-mix(in srgb,var(--a,var(--violet)) 42%,var(--line)); border-radius:25px; background:linear-gradient(155deg,color-mix(in srgb,var(--card) 93%,var(--a,var(--violet)) 7%),var(--card)); box-shadow:0 28px 90px #0009,0 0 42px color-mix(in srgb,var(--a,var(--violet)) 15%,transparent); text-align:center; outline:none; }
.member-profile-close { position:absolute; top:12px; right:13px; width:38px; height:38px; border:1px solid var(--line); border-radius:50%; background:var(--bg-2); color:var(--text); font-size:23px; cursor:pointer; }
.member-profile-hero { position:relative; width:76px; margin:0 auto 15px; }
.member-profile-hero .member-presence { right:0; bottom:3px; width:15px; height:15px; }
.member-profile-dialog .eyebrow { color:var(--a,var(--violet)); font-size:10px; font-weight:900; letter-spacing:.15em; text-transform:uppercase; }
.member-profile-dialog h2 { margin:7px 0 8px; font-size:27px; letter-spacing:-.04em; overflow-wrap:anywhere; }
.member-profile-badges { display:flex; justify-content:center; gap:6px; min-height:20px; }
.member-profile-status { margin:17px 0 7px; color:var(--a,var(--violet)); font-weight:800; }
.member-profile-bio { margin:12px auto 17px; max-width:300px; color:var(--text); line-height:1.6; overflow-wrap:anywhere; }
.member-profile-joined { display:block; margin-bottom:19px; color:var(--muted); }
.member-profile-message { width:100%; min-height:46px; }
@keyframes member-profile-fade { from { opacity:0; } to { opacity:1; } }
@media (max-width:560px) { .member-card-actions { gap:5px; } .member-card-actions .btn { padding:7px 9px; } .member-profile-dialog { padding:27px 20px 21px; } }
@media (prefers-reduced-motion:reduce) { .member-profile-backdrop { animation:none; } }

/* Step 2AF — make the purpose of private Vault storage obvious */
.vault-intro{display:flex;align-items:flex-start;gap:16px;margin-bottom:18px;padding:18px;border:1px solid var(--line);border-radius:18px;background:linear-gradient(135deg,rgba(139,92,246,.15),rgba(34,211,238,.06))}
.vault-intro-icon{display:grid;place-items:center;flex:0 0 52px;height:52px;border-radius:16px;background:rgba(139,92,246,.18);font-size:25px}
.vault-intro h2{margin:2px 0 6px}.vault-intro p:last-child{margin:0;color:var(--muted);line-height:1.55}.vault-intro .eyebrow{margin:0;color:var(--accent,var(--lime));font-size:10px;font-weight:800;letter-spacing:.14em}
.vault-guide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:14px 0}
.vault-guide article{display:flex;flex-direction:column;gap:7px;min-width:0;padding:14px;border:1px solid var(--line);border-radius:14px;background:var(--panel-2,rgba(127,127,127,.06))}
.vault-guide article>span{font-size:21px}.vault-guide b{font-size:13px}.vault-guide small{color:var(--muted);font-size:11px;line-height:1.45}
.vault-note{padding:12px 14px;border-left:3px solid var(--accent,var(--lime));border-radius:0 10px 10px 0;background:var(--panel-2,rgba(127,127,127,.06));font-size:13px;line-height:1.55}
.vault-empty{display:grid;justify-items:center;gap:7px;padding:26px 16px;text-align:center;border:1px dashed var(--line);border-radius:14px;color:var(--muted)}.vault-empty>span{font-size:27px}.vault-empty b{color:var(--text)}.vault-empty p{max-width:390px;margin:0;font-size:12px;line-height:1.5}
@media(max-width:560px){.vault-guide{grid-template-columns:1fr}.vault-guide article{display:grid;grid-template-columns:28px 1fr;align-items:center;column-gap:10px}.vault-guide article>span{grid-row:span 2}.vault-intro{padding:14px;gap:12px}.vault-intro-icon{flex-basis:42px;height:42px}}

/* Step 2AG — social-inspired conversation identity and quick discovery */
.chat-identity {
  display:flex; align-items:center; gap:12px; min-height:76px;
  padding:13px clamp(14px,2vw,22px);
  border-bottom:1px solid color-mix(in srgb,var(--purple) 22%,var(--line));
  background:linear-gradient(110deg,color-mix(in srgb,var(--purple) 10%,var(--card)),color-mix(in srgb,var(--card) 94%,transparent));
}
.chat-identity-avatar { width:44px; height:44px; flex:0 0 44px; display:grid; place-items:center; }
.chat-identity-avatar img,.chat-identity-avatar .avatar { width:42px!important; height:42px!important; }
.chat-identity-mark { display:grid;place-items:center;width:42px;height:42px;border-radius:15px;
  color:#fff;font-size:23px;background:linear-gradient(145deg,#8c5cff,#d35dcb 62%,#ff8dba);
  box-shadow:0 7px 22px rgba(151,91,255,.28),inset 0 1px rgba(255,255,255,.3); }
.chat-identity-copy { display:grid;gap:4px;min-width:0;flex:1; }
.chat-identity-copy strong { color:var(--ink);font-size:15px;font-weight:800;letter-spacing:-.2px; }
.chat-identity-copy span { color:var(--muted);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.chat-identity-actions { display:flex;align-items:center;gap:10px; }
.chat-secure-hint { color:#70d8ae;font-size:10px;font-weight:800;white-space:nowrap;letter-spacing:.2px; }
.chat-secure-hint span { color:var(--muted);font-weight:600; }
.chat-stories-shortcut { display:inline-flex;align-items:center;gap:7px;min-height:38px;padding:0 13px;
  border:1px solid color-mix(in srgb,var(--pink) 38%,var(--line));border-radius:13px;
  background:linear-gradient(120deg,color-mix(in srgb,var(--purple) 17%,var(--card)),color-mix(in srgb,var(--pink) 12%,var(--card)));
  color:var(--ink);font-family:inherit;font-size:12px;font-weight:700;cursor:pointer;transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease; }
.chat-stories-shortcut:hover { transform:translateY(-2px);border-color:var(--pink);box-shadow:0 8px 22px rgba(190,100,255,.15); }
.chat-stories-shortcut:active { transform:scale(.97); }
.chat-channels { padding:10px 14px!important;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--bg-2) 76%,transparent); }
.chat-channels .channel-chip { border-radius:999px!important; }
@media(max-width:520px) {
  .chat-identity { min-height:66px;padding:10px 12px;gap:9px; }
  .chat-identity-actions { gap:6px; }
  .chat-secure-hint span { display:none; }
  .chat-stories-shortcut { min-height:36px;padding:0 10px; }
}
@media(prefers-reduced-motion:reduce) { .chat-stories-shortcut { transition:none; } .chat-stories-shortcut:hover { transform:none; } }

/* Step 2AH — immersive, accessible Stories media viewer */
.story-card .story-media { cursor: zoom-in; transition: transform .2s ease, filter .2s ease; }
.story-card .story-media:hover { filter: brightness(1.06); }
.story-card .story-media:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
.story-viewer-top,.story-viewer-foot { display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px clamp(14px,3vw,28px);color:#fff; }
.story-viewer-person { display:flex;align-items:center;gap:10px;min-width:0; }
.story-viewer-person>div { display:grid;gap:3px; }
.story-viewer-person b { font-size:14px; }
.story-viewer-person small,.story-viewer-foot small { color:rgba(255,255,255,.62);font-size:11px; }
.story-viewer-stage { flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:8px 18px;overflow:auto; }
.story-viewer-media { display:block;max-width:min(100%,620px);max-height:calc(100dvh - 170px);width:auto;height:auto;object-fit:contain;border-radius:18px;box-shadow:0 24px 90px rgba(0,0,0,.48); }
.story-viewer-stage video.story-viewer-media { width:min(100%,620px);max-height:calc(100dvh - 170px);background:#000; }
.story-viewer-stage p { max-width:620px;width:100%;margin:0;color:#fff;font-size:14px;line-height:1.65;text-align:center;overflow-wrap:anywhere; }
.story-viewer-foot { justify-content:center;flex-wrap:wrap;font-size:10px;font-weight:800;letter-spacing:1.2px;color:#d6c4ff; }
@media(max-width:600px) { .story-viewer-media { max-width:100%;max-height:calc(100dvh - 150px);border-radius:12px; } .story-viewer-top { padding:10px 12px; } }
@media(prefers-reduced-motion:reduce) { .story-card .story-media { transition:none; } }
.story-open-media { display:inline-flex;align-items:center;gap:6px;margin-top:8px;padding:8px 11px;border:1px solid color-mix(in srgb,var(--purple) 45%,var(--line));border-radius:10px;background:color-mix(in srgb,var(--purple) 12%,var(--card-2));color:var(--ink);font-family:inherit;font-size:11px;font-weight:700;cursor:pointer; }
.story-open-media:hover { border-color:var(--pink);transform:translateY(-1px); }

/* Step 2AI — desktop three-panel messaging workspace */
.chat-workspace{display:grid;grid-template-columns:minmax(190px,238px) minmax(0,1fr) minmax(190px,238px);min-height:0;flex:1;overflow:hidden}
.chat-conversation-rail,.chat-details-rail{min-width:0;min-height:0;padding:18px 14px;background:color-mix(in srgb,var(--card) 84%,transparent);display:flex;flex-direction:column;gap:12px}
.chat-conversation-rail{border-right:1px solid var(--line)}.chat-details-rail{border-left:1px solid var(--line);align-items:stretch}
.chat-rail-heading{display:flex;align-items:center;justify-content:space-between;padding:2px 5px 8px}.chat-rail-heading div{display:grid;gap:4px}.chat-rail-heading span:first-child,.chat-details-eyebrow{font-size:9px;letter-spacing:1.6px;font-weight:900;color:var(--muted)}.chat-rail-heading strong{font-size:20px;letter-spacing:-.6px}.chat-rail-spark{display:grid;place-items:center;width:34px;height:34px;border-radius:12px;color:white;background:linear-gradient(145deg,#8c5cff,#df68c7);box-shadow:0 7px 20px rgba(151,91,255,.22)}
.chat-rail-caption{font-size:10px;color:var(--muted);padding:0 5px}.chat-conversation-rail .chat-channels{display:flex;flex-direction:column;gap:7px;padding:0!important;border:0;background:transparent;overflow:auto}.chat-conversation-rail .channel-chip{width:100%;min-height:46px;justify-content:flex-start;text-align:left;padding:8px 11px;border:1px solid transparent!important;border-radius:13px!important;background:transparent!important}.chat-conversation-rail .channel-chip:hover{background:color-mix(in srgb,var(--purple) 9%,var(--card-2))!important}.chat-conversation-rail .channel-chip.on{background:linear-gradient(110deg,color-mix(in srgb,var(--purple) 20%,var(--card)),color-mix(in srgb,var(--pink) 9%,var(--card)))!important;border-color:color-mix(in srgb,var(--purple) 38%,var(--line))!important;box-shadow:inset 3px 0 var(--purple)}
.chat-rail-note{margin-top:auto;display:flex;gap:9px;padding:12px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--purple) 7%,var(--card-2))}.chat-rail-note>span{color:var(--pink);font-size:18px}.chat-rail-note div{display:grid;gap:5px}.chat-rail-note b{font-size:11px}.chat-rail-note small{font-size:10px;line-height:1.5;color:var(--muted)}
.chat-main-column{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative}.chat-main-column .chat-identity{flex-shrink:0}.chat-main-column .chat-log{min-height:0}.chat-details-orb{width:52px;height:52px;display:grid;place-items:center;border-radius:18px;font-size:25px;color:white;background:linear-gradient(145deg,#8c5cff,#d35dcb 62%,#ff8dba);box-shadow:0 12px 28px rgba(151,91,255,.25)}.chat-details-rail h3{font-size:17px;margin:0;letter-spacing:-.4px}.chat-details-rail>p{font-size:11px;line-height:1.65;color:var(--muted);margin:0}.chat-detail-stat{display:flex;flex-direction:column;gap:5px;padding:11px 12px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--card-2) 65%,transparent)}.chat-detail-stat span{font-size:9px;color:var(--muted);text-transform:uppercase;letter-spacing:1px;font-weight:800}.chat-detail-stat b{font-size:12px}.chat-details-tip{display:grid;gap:6px;padding:12px;border-radius:13px;background:linear-gradient(135deg,color-mix(in srgb,var(--purple) 15%,var(--card)),color-mix(in srgb,var(--pink) 8%,var(--card)));border:1px solid color-mix(in srgb,var(--purple) 25%,var(--line))}.chat-details-tip b{font-size:11px}.chat-details-tip span{font-size:10px;line-height:1.55;color:var(--muted)}.chat-details-stories{margin-top:auto;min-height:40px;border:1px solid color-mix(in srgb,var(--pink) 35%,var(--line));border-radius:12px;background:color-mix(in srgb,var(--purple) 12%,var(--card));color:var(--ink);font-family:inherit;font-size:11px;font-weight:700;cursor:pointer}.chat-details-stories:hover{border-color:var(--pink);transform:translateY(-1px)}
@media(max-width:1120px){.chat-workspace{grid-template-columns:190px minmax(0,1fr)}.chat-details-rail{display:none}}
@media(max-width:760px){.chat-workspace{display:flex;flex-direction:column}.chat-conversation-rail{order:0;padding:9px 10px 5px;border-right:0;border-bottom:1px solid var(--line)}.chat-rail-heading,.chat-rail-caption,.chat-rail-note{display:none}.chat-conversation-rail .chat-channels{flex-direction:row;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.chat-conversation-rail .chat-channels::-webkit-scrollbar{display:none}.chat-conversation-rail .channel-chip{width:auto;min-width:max-content;min-height:40px}.chat-main-column{flex:1}.chat-main-column .chat-identity{min-height:62px}.chat-main-column .chat-log{padding:12px}}
@media(prefers-reduced-motion:reduce){.chat-details-stories:hover{transform:none}}

/* Step 2AJ — searchable conversation previews */
.chat-list-search{display:flex;align-items:center;gap:8px;min-height:39px;padding:0 11px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--bg-2) 78%,transparent);color:var(--muted)}
.chat-list-search>span{font-size:20px;line-height:1}
.chat-list-search input{width:100%;min-width:0;border:0;outline:0;background:transparent;color:var(--ink);font:inherit;font-size:11px}
.chat-list-search input::placeholder{color:var(--muted)}
.chat-conversation-rail .channel-chip.channel-row{display:flex;align-items:center;gap:10px;min-height:62px;padding:8px 9px!important;border-radius:13px!important}
.channel-row-avatar{width:40px;height:40px;flex:0 0 40px;display:grid;place-items:center;overflow:hidden;border-radius:14px;background:linear-gradient(145deg,color-mix(in srgb,var(--purple) 36%,var(--card)),color-mix(in srgb,var(--pink) 20%,var(--card-2)));color:#fff;font-size:18px}
.channel-row-avatar img{width:100%;height:100%;object-fit:cover}
.channel-row-copy{display:grid;gap:5px;min-width:0;flex:1;text-align:left}
.channel-row-top{display:flex;align-items:center;justify-content:space-between;gap:7px;min-width:0}
.channel-row-top b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--ink)}
.channel-row-top time{flex:0 0 auto;font-size:9px;color:var(--muted);font-weight:600}
.channel-row-preview{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px;line-height:1.35;color:var(--muted);font-weight:500}
.chat-list-empty{padding:14px 9px;text-align:center;color:var(--muted);font-size:10px;line-height:1.5}
.chat-list-empty[hidden]{display:none}
.chat-conversation-rail .channel-chip[hidden]{display:none!important}
@media(max-width:760px){.chat-list-search{display:none}.chat-conversation-rail .channel-chip.channel-row{width:190px;min-width:190px;min-height:54px}.channel-row-avatar{width:34px;height:34px;flex-basis:34px;border-radius:12px}.channel-row-top b{font-size:10px}.channel-row-preview{max-width:125px}}
@media(prefers-reduced-motion:reduce){.chat-conversation-rail .channel-chip.channel-row{transition:none!important}}

/* Step 2AK — precise unread-message indicators */
.channel-row-bottom{display:flex;align-items:center;justify-content:space-between;gap:7px;min-width:0}
.channel-row-bottom .channel-row-preview{min-width:0;flex:1}
.channel-unread{display:inline-flex;align-items:center;justify-content:center;min-width:19px;height:19px;padding:0 6px;border-radius:999px;background:linear-gradient(135deg,#9b6cff,#e45fb8);color:#fff;font-size:9px;line-height:1;font-weight:900;box-shadow:0 3px 12px rgba(157,93,255,.28);flex:0 0 auto}
.channel-chip.on .channel-unread{background:color-mix(in srgb,var(--purple) 65%,var(--card));box-shadow:none}
@media(prefers-reduced-motion:reduce){.channel-unread{box-shadow:none}}

/* Step 2AL — conversation-scoped shared media gallery */
.shared-media-section{display:grid;gap:10px;min-width:0;padding-top:2px}.shared-media-heading{display:flex;align-items:center;justify-content:space-between;font-size:11px}.shared-media-heading span{min-width:22px;padding:3px 7px;text-align:center;border-radius:20px;background:color-mix(in srgb,var(--purple) 18%,var(--card));color:var(--ink);font-size:10px;font-weight:800}.shared-media-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.shared-media-item{aspect-ratio:1;min-width:0;overflow:hidden;display:grid;place-items:center;border:1px solid var(--line);border-radius:10px;background:color-mix(in srgb,var(--card-2) 75%,transparent);color:var(--ink);text-decoration:none}.shared-media-image img{width:100%;height:100%;object-fit:cover;display:block;transition:transform .22s ease}.shared-media-image:hover img{transform:scale(1.07)}.shared-media-audio{align-content:center;gap:4px;background:linear-gradient(145deg,color-mix(in srgb,var(--purple) 22%,var(--card)),color-mix(in srgb,var(--pink) 12%,var(--card)))}.shared-media-audio>span{font-size:24px;color:var(--purple)}.shared-media-audio small{font-size:8px;color:var(--muted)}.shared-media-sticker{font-size:28px}.shared-media-empty{display:grid;justify-items:center;text-align:center;gap:6px;padding:14px 9px;border:1px dashed var(--line);border-radius:12px}.shared-media-empty>span{font-size:20px;color:var(--purple)}.shared-media-empty b{font-size:10px}.shared-media-empty small{font-size:9px;line-height:1.5;color:var(--muted)}
@media(max-width:1120px){.shared-media-section{display:none}}
@media(prefers-reduced-motion:reduce){.shared-media-image img{transition:none}}

/* Step 2AM — per-conversation atmosphere presets */
.chat-wallpaper-section{display:grid;gap:9px;padding-top:2px}.chat-wallpaper-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.chat-wallpaper-choice{display:grid;justify-items:start;gap:5px;min-height:59px;padding:9px;border:1px solid var(--line);border-radius:12px;background:var(--card-2);color:var(--ink);font:inherit;cursor:pointer;transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease}.chat-wallpaper-choice>span{font-size:19px}.chat-wallpaper-choice small{font-size:9px;color:var(--muted);font-weight:750}.chat-wallpaper-choice:hover{transform:translateY(-2px);border-color:var(--purple)}.chat-wallpaper-choice.on{border-color:var(--purple);box-shadow:inset 0 0 0 1px var(--purple),0 5px 16px color-mix(in srgb,var(--purple) 15%,transparent)}.chat-wallpaper-choice.wallpaper-aurora{background:radial-gradient(ellipse at 15% 0%,rgba(142,104,255,.23),transparent 72%),var(--card-2)}.chat-wallpaper-choice.wallpaper-orbit{background:radial-gradient(circle at 75% 15%,transparent 0 12px,rgba(91,195,255,.2) 13px 14px,transparent 15px),radial-gradient(circle at 75% 15%,transparent 0 22px,rgba(91,195,255,.12) 23px 24px,transparent 25px),var(--card-2)}.chat-wallpaper-choice.wallpaper-petal{background:radial-gradient(ellipse at 100% 0%,rgba(255,111,170,.2),transparent 72%),var(--card-2)}.chat-wallpaper-choice.wallpaper-plain{background:var(--card-2)}.chat-log[data-wallpaper="aurora"]{background-image:radial-gradient(ellipse at 15% 0%,color-mix(in srgb,var(--purple) 12%,transparent),transparent 58%),radial-gradient(ellipse at 95% 90%,color-mix(in srgb,var(--pink) 7%,transparent),transparent 55%)}.chat-log[data-wallpaper="orbit"]{background-image:radial-gradient(circle at 88% 12%,transparent 0 52px,color-mix(in srgb,var(--cyan) 9%,transparent) 53px 54px,transparent 55px 77px,color-mix(in srgb,var(--cyan) 7%,transparent) 78px 79px,transparent 80px),radial-gradient(circle at 8% 85%,transparent 0 38px,color-mix(in srgb,var(--purple) 8%,transparent) 39px 40px,transparent 41px)}.chat-log[data-wallpaper="petal"]{background-image:radial-gradient(ellipse at 95% 0%,color-mix(in srgb,var(--pink) 12%,transparent),transparent 60%),radial-gradient(ellipse at 0% 100%,color-mix(in srgb,var(--purple) 8%,transparent),transparent 52%)}.chat-log[data-wallpaper="plain"]{background-image:none!important}.chat-wallpaper-choice:focus-visible{outline:2px solid var(--cyan);outline-offset:2px}
@media(max-width:1120px){.chat-wallpaper-section{display:none}}
@media(prefers-reduced-motion:reduce){.chat-wallpaper-choice{transition:none}.chat-wallpaper-choice:hover{transform:none}}
.chat-mobile-wallpapers{display:none;align-items:center;gap:6px;padding:7px 12px;border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--card) 88%,transparent)}.chat-mobile-wallpaper{display:inline-flex;align-items:center;gap:5px;min-height:30px;padding:4px 9px;border:1px solid var(--line);border-radius:999px;background:var(--card-2);color:var(--muted);font:inherit;font-size:10px;font-weight:750;white-space:nowrap;cursor:pointer}.chat-mobile-wallpaper.on{border-color:var(--purple);background:color-mix(in srgb,var(--purple) 15%,var(--card));color:var(--ink)}.chat-mobile-wallpaper:focus-visible{outline:2px solid var(--cyan);outline-offset:2px}@media(max-width:1120px){.chat-mobile-wallpapers{display:flex;overflow-x:auto;scrollbar-width:none}.chat-mobile-wallpapers::-webkit-scrollbar{display:none}}@media(max-width:760px){.chat-mobile-wallpapers{padding:6px 9px}.chat-mobile-wallpaper{min-height:32px}}

/* Step 2AN — expressive reaction chips and discoverable message actions */
.msg .reactions .reaction-chip {
  appearance: none; border: 1px solid var(--line); color: var(--text);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border-radius: 999px; min-height: 27px; padding: 3px 9px;
  display: inline-flex; align-items: center; gap: 5px; font: inherit;
  font-size: 12px; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.msg .reactions .reaction-chip:hover { transform: translateY(-2px); border-color: var(--accent, #a78bfa); }
.msg .reactions .reaction-chip.mine { border-color: var(--accent, #a78bfa); background: color-mix(in srgb, var(--accent, #8b5cf6) 20%, var(--card)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #8b5cf6) 18%, transparent); }
.msg .reactions .reaction-chip:focus-visible, .message-more-btn:focus-visible, .reply-btn:focus-visible { outline: 2px solid var(--accent, #a78bfa); outline-offset: 3px; }
.msg .message-more-btn {
  position: absolute; top: 3px; right: 38px; width: 32px; height: 30px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  background: var(--card); opacity: 0; pointer-events: none; cursor: pointer;
  font-size: 19px; line-height: 1; transition: opacity .16s ease, transform .16s ease;
}
.msg:hover .message-more-btn, .msg:focus-within .message-more-btn { opacity: 1; pointer-events: auto; }
.msg .message-more-btn:hover { transform: translateY(-2px); }
.msg-menu { z-index: 1000; min-width: 176px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel, #211b31); box-shadow: 0 16px 44px #0008; }
.msg-menu button { display: block; width: 100%; min-height: 40px; text-align: left; border-radius: 9px; padding: 8px 11px; color: var(--text); background: transparent; border: 0; cursor: pointer; }
.msg-menu button:hover, .msg-menu button:focus-visible { background: color-mix(in srgb, var(--accent, #8b5cf6) 18%, transparent); outline: none; }
@media (hover: none), (max-width: 600px) {
  .msg .message-more-btn { opacity: .9; pointer-events: auto; width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .msg .reactions .reaction-chip, .msg .message-more-btn { transition: none; }
  .msg .reactions .reaction-chip:hover, .msg .message-more-btn:hover { transform: none; }
}

/* Step 2AO — calmer conversation switching and touch navigation */
.chat-main-column.chat-switch-enter { animation: chat-conversation-arrive .24s cubic-bezier(.2,.75,.25,1) both; }
@keyframes chat-conversation-arrive { from { opacity:.72; transform:translateY(7px) scale(.997); } to { opacity:1; transform:none; } }
.chat-conversation-rail .chat-channels { overscroll-behavior-x:contain; scroll-padding-inline:12px; }
.chat-conversation-rail .channel-row { scroll-margin-inline:12px; -webkit-tap-highlight-color:transparent; }
.chat-main-column .chat-form { padding-bottom:max(10px,env(safe-area-inset-bottom,0px)); }
.chat-main-column .chat-input, .chat-main-column #chat-input { min-width:0; }
@media(max-width:760px) {
  .chat-conversation-rail { padding-left:max(10px,env(safe-area-inset-left,0px)); padding-right:max(10px,env(safe-area-inset-right,0px)); }
  .chat-conversation-rail .chat-channels { scroll-snap-type:x proximity; }
  .chat-conversation-rail .channel-chip.channel-row { scroll-snap-align:start; }
  .chat-main-column .chat-log { overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .chat-main-column .chat-identity { padding-left:max(12px,env(safe-area-inset-left,0px)); padding-right:max(12px,env(safe-area-inset-right,0px)); }
  .chat-main-column .chat-form { padding-left:max(8px,env(safe-area-inset-left,0px)); padding-right:max(8px,env(safe-area-inset-right,0px)); }
}
@media(prefers-reduced-motion:reduce) {
  .chat-main-column.chat-switch-enter { animation:none; }
  .chat-conversation-rail .chat-channels { scroll-behavior:auto; }
}

/* Step 2AP — profile access from the conversation itself */
.chat-identity-avatar { border:0; padding:0; background:transparent; color:inherit; display:grid; place-items:center; border-radius:50%; }
.chat-identity-avatar.is-profile-trigger { cursor:pointer; transition:transform .18s ease,filter .18s ease; }
.chat-identity-avatar.is-profile-trigger:hover { transform:translateY(-2px) scale(1.04); filter:drop-shadow(0 5px 12px #a78bfa55); }
.chat-identity-avatar:focus-visible,.chat-profile-action:focus-visible { outline:2px solid var(--accent,#a78bfa); outline-offset:4px; }
.chat-profile-action { width:100%; display:flex; align-items:center; justify-content:space-between; gap:12px; border:1px solid var(--line,rgba(255,255,255,.1)); border-radius:12px; padding:11px 12px; margin:8px 0 14px; background:rgba(167,139,250,.08); color:var(--text,#f4f0ff); font:inherit; font-size:13px; cursor:pointer; transition:background .18s ease,border-color .18s ease,transform .18s ease; }
.chat-profile-action:hover { background:rgba(167,139,250,.15); border-color:rgba(167,139,250,.38); transform:translateY(-1px); }
.chat-member-profile-dialog { max-width:390px; }
@media(prefers-reduced-motion:reduce) { .chat-identity-avatar.is-profile-trigger,.chat-profile-action { transition:none; } .chat-identity-avatar.is-profile-trigger:hover,.chat-profile-action:hover { transform:none; } }

/* Step 2AQ — per-conversation notification controls */
.chat-notification-settings { margin:14px 0; padding:13px; border:1px solid var(--line); border-radius:16px; background:linear-gradient(145deg,rgba(139,92,246,.10),rgba(236,72,153,.045)); }
.chat-notification-settings p { margin:7px 0 10px; color:var(--muted); font-size:12px; line-height:1.5; }
.chat-notification-settings .chat-profile-action { width:100%; justify-content:space-between; }
.chat-notification-settings .chat-profile-action[aria-pressed="true"] { border-color:rgba(236,72,153,.42); color:var(--pink); }

/* Step 2AR — pinned and archived conversation collections */
.chat-collection-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;padding:4px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--bg-2) 80%,transparent)}
.chat-collection-tab{min-height:32px;border:0;border-radius:8px;background:transparent;color:var(--muted);font:inherit;font-size:10px;font-weight:800;cursor:pointer;transition:background .18s ease,color .18s ease,transform .18s ease}
.chat-collection-tab:hover{color:var(--ink);transform:translateY(-1px)}
.chat-collection-tab.on{background:linear-gradient(120deg,color-mix(in srgb,var(--purple) 24%,var(--card)),color-mix(in srgb,var(--pink) 13%,var(--card)));color:var(--ink);box-shadow:0 3px 12px color-mix(in srgb,var(--purple) 13%,transparent)}
.channel-collection-mark{display:inline-grid;place-items:center;width:15px;height:15px;margin-left:3px;border-radius:5px;background:color-mix(in srgb,var(--purple) 18%,var(--card));color:var(--pink);font-size:11px;vertical-align:middle}
.chat-collection-actions{display:grid;gap:7px}
.chat-collection-actions .shared-media-heading{margin-bottom:0}
.chat-collection-actions .chat-profile-action{width:100%;justify-content:space-between}
@media(max-width:760px){.chat-collection-tabs{min-width:205px;max-width:280px;flex-shrink:0}.chat-conversation-rail .chat-collection-tabs{align-self:flex-start}.chat-conversation-rail .chat-channels{min-height:42px}}
@media(prefers-reduced-motion:reduce){.chat-collection-tab{transition:none}.chat-collection-tab:hover{transform:none}}

/* Step 2AS — saved-message collection */
.saved-messages-backdrop{position:fixed;inset:0;z-index:1200;display:grid;place-items:center;padding:18px;background:rgba(7,5,15,.76);backdrop-filter:blur(16px)}
.saved-messages-dialog{width:min(620px,100%);max-height:min(82dvh,760px);display:flex;flex-direction:column;overflow:hidden;border:1px solid rgba(178,153,255,.24);border-radius:24px;background:linear-gradient(145deg,rgba(31,23,54,.98),rgba(14,12,27,.99));box-shadow:0 28px 100px rgba(0,0,0,.55),0 0 48px rgba(139,92,246,.12);color:var(--text,#f6f1ff)}
.saved-messages-dialog>header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:24px 24px 18px;border-bottom:1px solid rgba(190,170,255,.12)}
.saved-messages-dialog h2{margin:5px 0 4px;font-size:1.45rem;letter-spacing:-.035em}.saved-messages-dialog header p{margin:0;color:var(--muted,#aaa1bd);font-size:.88rem}
.saved-messages-close{width:38px;height:38px;flex:0 0 38px;border:1px solid rgba(190,170,255,.2);border-radius:13px;background:rgba(255,255,255,.05);color:inherit;font-size:1.4rem;cursor:pointer}
.saved-messages-list{overflow:auto;display:grid;gap:10px;padding:16px 20px;overscroll-behavior:contain}
.saved-message-card{padding:14px 15px;border:1px solid rgba(190,170,255,.14);border-radius:17px;background:rgba(255,255,255,.045)}
.saved-message-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--muted,#aaa1bd);font-size:.76rem}.saved-message-meta b{color:#d9ccff;font-weight:700}.saved-message-card p{margin:10px 0 13px;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;color:var(--text,#f6f1ff)}
.saved-message-actions{display:flex;justify-content:flex-end;gap:8px}.saved-message-actions button{min-height:34px;padding:6px 12px;border:1px solid rgba(190,170,255,.2);border-radius:10px;background:rgba(255,255,255,.055);color:#e9e1ff;font-size:.78rem;cursor:pointer}.saved-message-actions button:first-child{border-color:rgba(167,139,250,.42);background:rgba(139,92,246,.16)}
.saved-messages-empty{display:grid;justify-items:center;gap:8px;padding:46px 20px;text-align:center;color:var(--muted,#aaa1bd)}.saved-messages-empty>span{display:grid;place-items:center;width:52px;height:52px;border-radius:18px;background:rgba(167,139,250,.13);color:#c4b5fd;font-size:1.6rem}.saved-messages-empty b{color:var(--text,#f6f1ff)}.saved-messages-empty small{max-width:260px;line-height:1.5}
.saved-messages-dialog>footer{padding:12px 22px;border-top:1px solid rgba(190,170,255,.12);color:var(--muted,#aaa1bd);font-size:.72rem;text-align:center}
.saved-message-highlight{animation:saved-message-pulse 1.5s ease-out;border-radius:18px;outline:2px solid rgba(167,139,250,.8);outline-offset:5px}
@keyframes saved-message-pulse{0%{box-shadow:0 0 0 0 rgba(167,139,250,.55)}100%{box-shadow:0 0 0 18px rgba(167,139,250,0)}}
.saved-messages-launch{margin:12px 0;border-color:rgba(167,139,250,.3)!important;background:linear-gradient(110deg,rgba(139,92,246,.14),rgba(255,255,255,.035))!important}
.saved-messages-dialog button:focus-visible,.saved-messages-launch:focus-visible{outline:2px solid #c4b5fd;outline-offset:3px}
@media(max-width:600px){.saved-messages-backdrop{padding:10px;align-items:end}.saved-messages-dialog{max-height:88dvh;border-radius:23px 23px 16px 16px}.saved-messages-dialog>header{padding:20px 18px 15px}.saved-messages-list{padding:13px}.saved-message-meta{align-items:flex-start;flex-direction:column;gap:3px}}
@media(prefers-reduced-motion:reduce){.saved-message-highlight{animation:none}.saved-messages-dialog *{scroll-behavior:auto!important}}


/* Step 2AU — expressive, accessible chat attachments */
.chat-form .attach-btn {
  flex: 0 0 42px; width: 42px; height: 44px; border-radius: 14px;
  border: 1px solid rgba(180,150,255,.28); color: #d8c7ff;
  background: linear-gradient(145deg, rgba(139,92,246,.22), rgba(91,54,155,.12));
  font-size: 25px; line-height: 1; cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.chat-form .attach-btn:hover { transform: translateY(-2px); border-color: rgba(190,160,255,.65); box-shadow: 0 7px 18px rgba(100,65,190,.2); }
.chat-form.is-drop-target { outline: 2px dashed rgba(180,150,255,.8); outline-offset: -5px; background: rgba(115,76,190,.12); }
.chat-attachment-card { display:flex; align-items:center; gap:12px; min-width:210px; max-width:min(340px, 78vw); padding:12px 14px; border:1px solid rgba(180,150,255,.24); border-radius:16px; color:var(--ink); text-decoration:none; background:linear-gradient(135deg,rgba(114,78,190,.18),rgba(32,42,52,.94)); box-shadow:0 8px 24px rgba(0,0,0,.13); transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease; }
.chat-attachment-card:hover { transform:translateY(-2px); border-color:rgba(190,160,255,.62); box-shadow:0 12px 28px rgba(70,45,130,.22); }
.chat-attachment-icon { display:grid; place-items:center; flex:0 0 42px; height:42px; border-radius:12px; background:rgba(151,116,230,.18); color:#d9c8ff; font-size:19px; font-weight:800; }
.chat-attachment-copy { display:grid; min-width:0; gap:4px; }
.chat-attachment-copy b { overflow-wrap:anywhere; font-size:13px; }
.chat-attachment-copy small { color:var(--muted); font-size:11px; }
.chat-attachment-open { margin-left:auto; color:#cbb4ff; }
@media(max-width:600px) { .chat-form .attach-btn { flex-basis:40px; width:40px; min-width:40px; height:42px; } .chat-attachment-card { min-width:0; } }
@media(prefers-reduced-motion:reduce) { .chat-form .attach-btn,.chat-attachment-card { transition:none; } .chat-form .attach-btn:hover,.chat-attachment-card:hover { transform:none; } }
.chat-attachment-preview { padding:9px 14px 0; background:rgba(17,21,27,.96); }
.chat-attachment-preview-card { display:flex; align-items:center; gap:10px; max-width:420px; padding:8px 10px; border:1px solid rgba(180,150,255,.24); border-radius:13px; background:rgba(115,76,190,.1); color:var(--muted); font-size:12px; }
.chat-attachment-preview-card img { width:46px; height:46px; object-fit:cover; border-radius:9px; }
.chat-attachment-preview-card progress { width:82px; height:6px; accent-color:#a98af4; margin-left:auto; }

/* Step 2AV — inline social-style photo and video messages */
.chat-media-figure{display:grid;gap:0;width:min(100%,390px);max-width:min(390px,78vw);margin:3px 0 5px;overflow:hidden;border:1px solid rgba(180,150,255,.22);border-radius:18px;background:linear-gradient(145deg,rgba(100,73,157,.18),rgba(18,22,30,.96));box-shadow:0 12px 32px rgba(0,0,0,.18)}
.chat-media-open{display:block;overflow:hidden;max-height:420px;background:#10121a}
.chat-media-image img{display:block;width:100%;max-height:420px;aspect-ratio:auto;object-fit:contain;transition:transform .28s ease,filter .28s ease}
.chat-media-open:hover img{transform:scale(1.025);filter:brightness(1.04)}
.chat-media-video video{display:block;width:100%;max-height:420px;aspect-ratio:16/10;object-fit:contain;background:#08090d}
.chat-media-figure figcaption{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;padding:9px 12px;color:var(--ink);font-size:11px}
.chat-media-figure figcaption span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:750}
.chat-media-figure figcaption small{flex-shrink:0;color:var(--muted);font-size:10px}
@media(max-width:600px){.chat-media-figure{max-width:min(320px,78vw);border-radius:15px}.chat-media-open,.chat-media-open img,.chat-media-video video{max-height:330px}}
@media(prefers-reduced-motion:reduce){.chat-media-image img{transition:none}.chat-media-open:hover img{transform:none}}

/* Step 2AW — immersive conversation media viewer */
.chat-media-viewer-top,.chat-media-viewer-foot{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px clamp(14px,3vw,30px);color:#fff}
.chat-media-viewer-meta{display:grid;gap:4px;min-width:0}.chat-media-viewer-meta b{overflow-wrap:anywhere;font-size:14px}.chat-media-viewer-meta small{color:rgba(255,255,255,.62);font-size:11px}
.chat-media-viewer-stage{position:relative;display:flex;align-items:center;justify-content:center;gap:12px;flex:1;min-height:0;padding:12px 64px;overflow:hidden}
.chat-media-viewer-asset{display:block;max-width:100%;max-height:calc(100dvh - 150px);width:auto;height:auto;object-fit:contain;border-radius:16px;box-shadow:0 24px 90px rgba(0,0,0,.5);animation:chat-media-enter .24s cubic-bezier(.2,.8,.2,1) both}
video.chat-media-viewer-asset{width:min(100%,1100px);background:#000}
.chat-media-viewer-nav{position:absolute;z-index:2;top:50%;transform:translateY(-50%);width:46px;height:58px;border:1px solid rgba(255,255,255,.2);border-radius:16px;background:rgba(31,22,49,.68);backdrop-filter:blur(14px);color:#fff;font-size:34px;cursor:pointer;transition:background .18s,transform .18s}
.chat-media-viewer-nav:hover{background:rgba(126,86,210,.8);transform:translateY(-50%) scale(1.06)}.chat-media-viewer-nav.prev{left:12px}.chat-media-viewer-nav.next{right:12px}
.chat-media-viewer-foot{justify-content:center;gap:16px;color:#d6c4ff;font-size:10px;font-weight:800;letter-spacing:1.1px}.chat-media-viewer-foot a{color:#fff;text-decoration:none;border:1px solid rgba(190,164,255,.34);border-radius:999px;padding:8px 12px;letter-spacing:0;font-size:11px}
.chat-media-expand{border:0;background:transparent;color:var(--purple);font:inherit;font-size:11px;font-weight:800;cursor:pointer}.chat-media-expand:hover{color:var(--pink)}
@keyframes chat-media-enter{from{opacity:0;transform:scale(.975)}to{opacity:1;transform:scale(1)}}
@media(max-width:600px){.chat-media-viewer-stage{padding:8px 48px}.chat-media-viewer-asset{max-height:calc(100dvh - 132px);border-radius:10px}.chat-media-viewer-nav{width:36px;height:46px;font-size:27px}.chat-media-viewer-nav.prev{left:5px}.chat-media-viewer-nav.next{right:5px}.chat-media-viewer-top{padding:10px 12px}}
@media(prefers-reduced-motion:reduce){.chat-media-viewer-asset{animation:none}.chat-media-viewer-nav{transition:none}}

/* Step 2AX — uncluttered composer: keep the message field clear, tuck extras away */
.chat-page .chat-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 66px;
  padding: 9px 14px max(9px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(180,150,255,.13);
  background: color-mix(in srgb, var(--card, #171322) 96%, transparent);
  backdrop-filter: blur(18px);
}
.chat-page .chat-form #chat-input {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid rgba(180,150,255,.16);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  color: var(--ink);
  font-size: 15px;
  box-shadow: none;
}
.chat-page .chat-form #chat-input:focus {
  border-color: rgba(167,139,250,.62);
  box-shadow: 0 0 0 3px rgba(139,92,246,.10);
}
.chat-page .chat-form .attach-btn,
.chat-page .chat-form .send-btn {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 15px;
}
.chat-page .chat-form .attach-btn {
  border: 1px solid rgba(180,150,255,.22);
  background: rgba(139,92,246,.11);
  color: #d8c7ff;
  font-size: 24px;
  font-weight: 400;
  box-shadow: none;
}
.chat-page .chat-form .attach-btn[aria-expanded="true"] { background: rgba(139,92,246,.24); border-color: rgba(180,150,255,.48); }
.chat-page .chat-form .send-btn {
  border: 1px solid rgba(190,165,255,.35);
  background: linear-gradient(145deg,#a78bfa,#7956d8);
  color: white;
  font-size: 22px;
  box-shadow: 0 5px 16px rgba(103,72,185,.24);
}
.chat-composer-menu {
  position: absolute;
  z-index: 40;
  left: 12px;
  bottom: calc(100% + 9px);
  display: grid;
  width: min(286px, calc(100vw - 28px));
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(180,150,255,.24);
  border-radius: 18px;
  background: rgba(24,19,38,.98);
  box-shadow: 0 18px 55px rgba(0,0,0,.42), 0 0 28px rgba(139,92,246,.10);
  backdrop-filter: blur(20px);
}
.chat-composer-menu[hidden] { display: none; }
.chat-composer-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #eee8ff;
  text-align: left;
  cursor: pointer;
}
.chat-composer-menu button:hover,
.chat-composer-menu button:focus-visible { outline: none; background: rgba(167,139,250,.13); }
.chat-composer-menu button>span:first-child { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 11px; background: rgba(167,139,250,.14); color: #d8c7ff; font-size: 19px; }
.chat-composer-menu button>span:last-child { display: grid; gap: 2px; }
.chat-composer-menu b { font-size: 12px; font-weight: 700; }
.chat-composer-menu small { color: #aaa1bd; font-size: 10px; }
.chat-composer-menu button:focus-visible { box-shadow: inset 0 0 0 1px #c4b5fd; }
.chat-page .chat-attachment-preview { padding: 5px 14px 0; background: transparent; }
.chat-page .chat-attachment-preview-card { min-height: 48px; max-height: 58px; overflow: hidden; padding: 5px 9px; border-radius: 12px; }
.chat-page .chat-attachment-preview-card img { width: 38px; height: 38px; flex: 0 0 38px; }
.chat-page .chat-attachment-preview-card progress { width: 68px; }
.chat-page .chat-send-status { min-height: 0; padding: 3px 16px; font-size: 10px; line-height: 1.35; }
@media (max-width: 600px) {
  .chat-page .chat-form { min-height: 60px; gap: 7px; padding: 7px 9px max(7px, env(safe-area-inset-bottom, 0px)); }
  .chat-page .chat-form .attach-btn,
  .chat-page .chat-form .send-btn { flex-basis: 40px; width: 40px; min-width: 40px; height: 40px; border-radius: 13px; }
  .chat-page .chat-form #chat-input { min-height: 42px; padding: 9px 12px; font-size: 16px; }
  .chat-composer-menu { left: 7px; bottom: calc(100% + 7px); }
}
@media (max-width: 360px) {
  .chat-page .chat-form { gap: 5px; padding-inline: 7px; }
  .chat-page .chat-form .attach-btn,
  .chat-page .chat-form .send-btn { flex-basis: 38px; width: 38px; min-width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-page .chat-form *, .chat-composer-menu * { transition: none !important; animation: none !important; }
}
.chat-page .chat-form .attach-btn.recording { border-color: rgba(255,132,158,.72); color: #ffc2d0; background: rgba(210,70,110,.18); box-shadow: 0 0 0 3px rgba(210,70,110,.09); }

/* Step 2AY — reclaim conversation space and keep the composer anchored */
.chat-page,
.chat-page .chat-workspace,
.chat-page .chat-main-column {
  min-height: 0;
}
.chat-page .chat-workspace {
  flex: 1 1 0;
  height: 0;
}
.chat-page .chat-main-column {
  overflow: hidden;
}
.chat-page .chat-main-column .chat-log,
.chat-page > .chat-log {
  flex: 1 1 0;
  min-height: 0;
  overscroll-behavior: contain;
}
.chat-page .chat-main-column > .chat-form,
.chat-page > .chat-form {
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
}
.chat-page .chat-main-column > .chat-identity,
.chat-page > .thread-header,
.chat-page .chat-main-column > .chat-mobile-wallpapers,
.chat-page .chat-main-column > .chat-search,
.chat-page .chat-main-column > .typing-line,
.chat-page .chat-main-column > #reply-banner-slot,
.chat-page .chat-main-column > .chat-send-status,
.chat-page .chat-main-column > .chat-attachment-preview {
  flex: 0 0 auto;
  min-width: 0;
}
.chat-page .chat-main-column > #reply-banner-slot:empty,
.chat-page .chat-main-column > .typing-line:empty {
  display: none;
}
.chat-page .chat-conversation-rail,
.chat-page .chat-details-rail {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-page .chat-attachment-preview[hidden],
.chat-page .chat-send-status[hidden],
.chat-page .connection-banner[hidden] {
  display: none !important;
}
@media (max-width: 760px) {
  .chat-page .chat-workspace { height: 0; }
  .chat-page .chat-conversation-rail { flex: 0 0 auto; max-height: 66px; overflow: hidden; }
  .chat-page .chat-conversation-rail .chat-channels { min-height: 40px; }
  .chat-page .chat-mobile-wallpapers { flex: 0 0 auto; min-height: 0; max-height: 38px; padding-block: 3px; }
  .chat-page .chat-mobile-wallpaper { min-height: 28px; padding-block: 2px; }
  .chat-page .chat-main-column { flex: 1 1 0; height: 0; }
  .chat-page .chat-main-column .chat-identity { min-height: 54px; padding-block: 6px; }
  .chat-page .chat-main-column .chat-log { flex: 1 1 0; min-height: 0; padding: 10px; }
}
@media (max-width: 420px) {
  .chat-page .chat-conversation-rail { max-height: 58px; padding-block: 6px 3px; }
  .chat-page .chat-main-column .chat-identity { min-height: 50px; }
  .chat-page .chat-main-column .chat-identity-avatar,
  .chat-page .chat-main-column .chat-identity-avatar img { width: 36px !important; height: 36px !important; }
  .chat-page .chat-main-column .chat-identity-copy strong { font-size: 13px; }
  .chat-page .chat-main-column .chat-identity-copy span { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-page .chat-main-column,
  .chat-page .chat-log,
  .chat-page .chat-form { scroll-behavior: auto; }
}

/* Step 2BE — welcoming first-use stash state */
.stash-welcome{grid-column:1/-1;position:relative;isolation:isolate;display:grid;grid-template-columns:minmax(150px,.72fr) minmax(0,1.45fr);align-items:center;gap:clamp(18px,4vw,52px);min-height:270px;margin:10px 0 24px;padding:clamp(22px,4vw,42px);overflow:hidden;border:1px solid color-mix(in srgb,var(--purple) 30%,var(--line));border-radius:26px;background:radial-gradient(ellipse at 12% 20%,color-mix(in srgb,var(--purple) 22%,transparent),transparent 55%),radial-gradient(ellipse at 88% 90%,color-mix(in srgb,var(--pink) 12%,transparent),transparent 48%),linear-gradient(135deg,color-mix(in srgb,var(--card) 94%,#171027),color-mix(in srgb,var(--card-2) 92%,#211438));box-shadow:0 22px 65px rgba(0,0,0,.17),inset 0 1px rgba(255,255,255,.07)}
.stash-welcome:before,.stash-welcome:after{content:"";position:absolute;z-index:-1;border:1px solid color-mix(in srgb,var(--purple) 28%,transparent);border-radius:50%;width:260px;height:260px;right:-80px;top:-150px;transform:rotate(-24deg)}.stash-welcome:after{width:190px;height:190px;right:-42px;top:-112px;border-color:color-mix(in srgb,var(--pink) 25%,transparent)}
.stash-welcome-art{position:relative;display:grid;place-items:center;min-height:180px;perspective:700px}.stash-welcome-art b{display:grid;place-items:center;width:116px;height:116px;border:1px solid rgba(255,255,255,.22);border-radius:32px;background:linear-gradient(145deg,rgba(155,125,255,.3),rgba(255,95,168,.15));box-shadow:0 28px 55px rgba(0,0,0,.3),inset 0 1px rgba(255,255,255,.22);font-size:54px;transform:rotateY(-15deg) rotateX(8deg);animation:stash-welcome-float 5s ease-in-out infinite}.stash-welcome-art span,.stash-welcome-art i{position:absolute;color:var(--lime);font-style:normal;font-size:27px;text-shadow:0 0 22px color-mix(in srgb,var(--lime) 60%,transparent)}.stash-welcome-art span{top:20px;left:22%}.stash-welcome-art i{right:18%;bottom:20px;color:var(--pink)}
.stash-welcome-copy{max-width:620px}.stash-welcome-kicker{font-size:9px;font-weight:900;letter-spacing:2px;color:var(--pink)}.stash-welcome-copy h2{margin:10px 0 9px;font-size:clamp(25px,3.4vw,38px);line-height:1.1;letter-spacing:-1.5px;color:var(--ink)}.stash-welcome-copy p{max-width:520px;margin:0;color:var(--muted);font-size:13px;line-height:1.75}.stash-welcome-actions{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin-top:21px}.stash-welcome-secondary{border:0;background:transparent;color:var(--ink);font:inherit;font-size:12px;font-weight:800;padding:10px 5px;cursor:pointer}.stash-welcome-secondary span{color:var(--pink);margin-left:5px}.stash-welcome-foot{display:flex;align-items:center;gap:7px;margin-top:21px;color:var(--muted);font-size:10px}.stash-welcome-foot span{color:var(--lime);font-size:17px}
@keyframes stash-welcome-float{0%,100%{transform:translateY(0) rotateY(-15deg) rotateX(8deg)}50%{transform:translateY(-9px) rotateY(-8deg) rotateX(4deg)}}
@media(max-width:620px){.stash-welcome{grid-template-columns:1fr;gap:4px;padding:22px;min-height:0;border-radius:20px}.stash-welcome-art{min-height:112px}.stash-welcome-art b{width:82px;height:82px;border-radius:24px;font-size:40px}.stash-welcome-art span{top:7px;left:28%}.stash-welcome-art i{right:27%;bottom:4px}.stash-welcome-copy h2{font-size:27px}.stash-welcome-foot{margin-top:16px}}
@media(prefers-reduced-motion:reduce){.stash-welcome-art b{animation:none;transform:none}}

/* ================================================================
   Step 2BI — premium chat redesign
   One consolidated layer for the whole chat experience. It sits last on purpose and
   is scoped to .chat-page so it can supersede the older incremental passes above.
   ================================================================ */
.shell:has(main[data-page="chat"]) .rightbar { display: none; }
@media (min-width: 1280px) { .shell:has(main[data-page="chat"]) { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }
main[data-page="chat"] .content { max-width: none; padding: 14px clamp(12px, 2vw, 26px) 18px; }

.chat-page {
  --cp-panel: color-mix(in srgb, var(--card) 88%, transparent);
  --cp-raise: color-mix(in srgb, var(--card-2) 78%, var(--bg));
  --cp-hair: color-mix(in srgb, var(--ink) 9%, transparent);
  --cp-hair-2: color-mix(in srgb, var(--ink) 15%, transparent);
  --cp-me-a: color-mix(in srgb, var(--purple) 62%, #0c0920);
  --cp-me-b: color-mix(in srgb, var(--pink) 56%, #0c0920);
  --cp-ease: cubic-bezier(.22, 1, .36, 1);
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--topbar-h) - 32px); min-height: 420px;
  border: 1px solid var(--cp-hair-2); border-radius: 26px; overflow: hidden;
  background:
    radial-gradient(900px 420px at 0% -10%, color-mix(in srgb, var(--purple) 13%, transparent), transparent 70%),
    radial-gradient(700px 420px at 100% 110%, color-mix(in srgb, var(--pink) 9%, transparent), transparent 70%),
    color-mix(in srgb, var(--bg-2) 96%, var(--bg));
  box-shadow: 0 30px 80px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.05);
}
.chat-page::before { display: none; }
.chat-page svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chat-page .chat-workspace { position: relative; flex: 1 1 0; height: 0; min-height: 0; display: grid; grid-template-columns: clamp(290px, 28vw, 352px) minmax(0, 1fr); overflow: hidden; }

/* ---------- conversation list ---------- */
.chat-page .chat-workspace .chat-conversation-rail {
  display: flex; flex-direction: column; gap: 12px; padding: 20px 14px 14px; min-height: 0; max-height: none; overflow: hidden;
  background: var(--cp-panel); border: 0; border-right: 1px solid var(--cp-hair);
}
.chat-page .chat-rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 2px; }
.chat-page .chat-rail-heading div { display: grid; gap: 3px; }
.chat-page .chat-rail-heading div span { font-size: 10px; letter-spacing: 2px; font-weight: 800; color: var(--muted-2); }
.chat-page .chat-rail-heading strong { font-size: 26px; letter-spacing: -.8px; line-height: 1.1; }
.chat-page .chat-rail-spark { width: 40px; height: 40px; border: 1px solid var(--cp-hair-2); border-radius: 50%; background: var(--cp-raise); color: var(--ink); cursor: pointer; display: grid; place-items: center; font-size: 20px; box-shadow: none; transition: transform .2s var(--cp-ease), border-color .2s; }
.chat-page .chat-rail-spark:hover { transform: scale(1.06); border-color: var(--purple); }
.chat-page .chat-rail-caption, .chat-page .chat-rail-note { display: none; }
.chat-page .chat-list-search { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 14px; border-radius: 999px; background: var(--cp-raise); border: 1px solid var(--cp-hair); color: var(--muted); transition: border-color .2s, box-shadow .2s; }
.chat-page .chat-list-search:focus-within { border-color: color-mix(in srgb, var(--purple) 65%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 14%, transparent); }
.chat-page .chat-list-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; box-shadow: none; padding: 0; color: var(--ink); font: inherit; font-size: 14px; }
.chat-page .chat-list-search input::placeholder { color: var(--muted-2); }
.chat-page .chat-collection-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid var(--cp-hair); }
.chat-page .chat-collection-tab { flex: 1; min-height: 32px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .2s, color .2s; }
.chat-page .chat-collection-tab.on { background: var(--cp-raise); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.06); }
.chat-page .chat-workspace .chat-channels { display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--cp-hair-2) transparent; border: 0; background: none; }
.chat-page .chat-workspace .channel-row { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 66px; padding: 9px 10px; border: 0 !important; border-radius: 18px !important; background: transparent !important; box-shadow: none !important; color: var(--ink); text-align: left; cursor: pointer; transition: background .18s; }
.chat-page .chat-workspace .channel-row:hover { background: color-mix(in srgb, var(--ink) 5%, transparent) !important; }
.chat-page .chat-workspace .channel-row.on { background: linear-gradient(100deg, color-mix(in srgb, var(--purple) 22%, transparent), color-mix(in srgb, var(--pink) 9%, transparent)) !important; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--purple) 32%, transparent) !important; }
.chat-page .channel-row-avatar { position: relative; display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 50%; }
.chat-page .channel-row-avatar .av { width: 48px !important; height: 48px !important; font-size: 19px !important; }
.chat-page .channel-row:has(.channel-unread) .channel-row-avatar { padding: 2px; background: conic-gradient(from 210deg, var(--pink), var(--purple), var(--cyan), var(--pink)); }
.chat-page .channel-row:has(.channel-unread) .channel-row-avatar .av { width: 44px !important; height: 44px !important; border: 2px solid var(--bg-2); }
.chat-page .channel-general-avatar { background: linear-gradient(145deg, var(--purple), var(--pink)); color: #fff; }
.chat-page .channel-general-avatar svg, .chat-page .channel-general-avatar { font-size: 20px; }
.chat-page .channel-row-copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
.chat-page .channel-row-top, .chat-page .channel-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.chat-page .channel-row-top b { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .channel-row-top time { font-size: 11px; color: var(--muted-2); flex: none; font-variant-numeric: tabular-nums; }
.chat-page .channel-row-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-page .channel-row:has(.channel-unread) .channel-row-top b, .chat-page .channel-row:has(.channel-unread) .channel-row-preview { color: var(--ink); font-weight: 700; }
.chat-page .channel-row:has(.channel-unread) .channel-row-top time { color: var(--purple); font-weight: 700; }
.chat-page .channel-unread { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; font-size: 11px; font-weight: 800; flex: none; box-shadow: 0 4px 12px color-mix(in srgb, var(--purple) 40%, transparent); }
.chat-page .channel-collection-mark { color: var(--muted-2); font-size: 11px; }
.chat-page .chat-list-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- conversation header ---------- */
.chat-page .chat-main-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.chat-page .chat-main-column .chat-identity { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; min-height: 72px; padding: 10px 14px 10px 18px; border: 0; border-bottom: 1px solid var(--cp-hair); background: var(--cp-panel); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); z-index: 4; }
.chat-page .chat-back { display: none; width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); font-size: 26px; place-items: center; cursor: pointer; }
.chat-page .chat-back:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.chat-page .chat-identity-avatar { position: relative; display: grid; place-items: center; width: 46px; height: 46px; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; cursor: default; }
.chat-page .chat-identity-avatar.is-profile-trigger { cursor: pointer; }
.chat-page .chat-identity-avatar:disabled { opacity: 1; }
.chat-page .chat-identity-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(145deg, var(--purple), var(--pink)); color: #fff; font-size: 22px; box-shadow: 0 8px 22px color-mix(in srgb, var(--purple) 38%, transparent); }
.chat-page .chat-presence { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--bg-2); background: var(--muted-2); display: none; }
.chat-page .chat-presence.is-online { display: block; background: #3ddc97; }
.chat-page .chat-identity-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.chat-page .chat-identity-copy strong { font-size: 17px; font-weight: 800; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .chat-identity-copy span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .chat-identity-copy span.is-live { color: #3ddc97; }
.chat-page .chat-identity-actions { display: flex; align-items: center; gap: 4px; }
.chat-page .chat-hd-btn { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 21px; cursor: pointer; transition: background .18s, color .18s, transform .2s var(--cp-ease); }
.chat-page .chat-hd-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.chat-page .chat-hd-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--purple) 22%, transparent); color: var(--ink); }
.chat-page .chat-hd-btn:active { transform: scale(.92); }
.chat-page .chat-search { display: flex; align-items: center; gap: 10px; margin: 10px 16px 0; padding: 0 8px 0 14px; min-height: 44px; border-radius: 999px; background: var(--cp-raise); border: 1px solid var(--cp-hair-2); animation: cp-drop .22s var(--cp-ease); }
.chat-page .chat-search[hidden] { display: none; }
.chat-page .chat-search-icon { color: var(--muted); font-size: 18px; display: grid; }
.chat-page .chat-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; box-shadow: none; color: var(--ink); font: inherit; font-size: 14px; padding: 0; }
.chat-page .chat-search .search-count { font-size: 12px; color: var(--muted); }
.chat-page .chat-search button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.chat-page .chat-search button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
@keyframes cp-drop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- message stream ---------- */
.chat-page .chat-main-column .chat-log, .chat-page > .chat-log { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 18px clamp(14px, 3vw, 30px) 10px; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; background-color: transparent; scrollbar-width: thin; scrollbar-color: var(--cp-hair-2) transparent; }
.chat-page .day-divider { position: sticky; top: 2px; z-index: 2; display: flex; justify-content: center; margin: 16px 0 8px; pointer-events: none; }
.chat-page .day-divider span { padding: 5px 13px; border-radius: 999px; background: color-mix(in srgb, var(--bg-2) 82%, transparent); border: 1px solid var(--cp-hair); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--muted); }
.chat-page .chat-log .msg { position: relative; display: flex; align-items: flex-end; gap: 8px; margin: 12px 0 0; padding: 0; width: 100%; background: none; border-radius: 0; animation: cp-in .32s var(--cp-ease) both; }
.chat-page .chat-log .msg:not(.grp-first) { margin-top: 2px; }
.chat-page .chat-log .msg.mine { flex-direction: row; justify-content: flex-end; }
@keyframes cp-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.chat-page .chat-log .msg-avatar { width: 32px; flex: none; align-self: flex-end; margin-bottom: 1px; }
.chat-page .chat-log .msg.mine .msg-avatar { display: none; }
.chat-page .chat-log .msg-avatar .av { width: 32px !important; height: 32px !important; font-size: 14px !important; border: 0; box-shadow: 0 0 0 2px var(--bg-2); }
.chat-page .chat-log .msg:not(.grp-last) .msg-avatar > * { visibility: hidden; }
.chat-page .chat-log .msg-body { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(560px, 78%); }
.chat-page .chat-log .msg.mine .msg-body { align-items: flex-end; }
.chat-page .chat-log .msg-name { margin: 0 0 4px 12px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .1px; }
.chat-page .chat-log .msg:not(.grp-first) .msg-name, .chat-page .chat-log[data-scope="dm"] .msg-name { display: none; }
.chat-page .chat-log .msg.mine .msg-name { display: none; }

.chat-page .chat-log .bubble { position: relative; z-index: 1; max-width: 100%; padding: 10px 15px; border: 0; border-radius: 20px; font-size: 15px; line-height: 1.45; letter-spacing: -.1px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; color: var(--ink); background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair), 0 1px 2px rgba(0,0,0,.18); }
.chat-page .chat-log .bubble::before, .chat-page .chat-log .bubble::after { display: none !important; }
.chat-page .chat-log .msg:not(.mine):not(.grp-first) .bubble:not(.bubble-sticker) { border-top-left-radius: 6px; }
.chat-page .chat-log .msg:not(.mine):not(.grp-last) .bubble:not(.bubble-sticker) { border-bottom-left-radius: 6px; }
.chat-page .chat-log .msg.mine:not(.grp-first) .bubble:not(.bubble-sticker) { border-top-right-radius: 6px; }
.chat-page .chat-log .msg.mine:not(.grp-last) .bubble:not(.bubble-sticker) { border-bottom-right-radius: 6px; }
.chat-page .chat-log .msg.mine .bubble:not(.bubble-sticker) { color: #fff; background: linear-gradient(135deg, var(--cp-me-a), var(--cp-me-b)); box-shadow: 0 6px 18px color-mix(in srgb, var(--cp-me-a) 45%, transparent), inset 0 1px rgba(255,255,255,.14); }
.chat-page .chat-log .bubble a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.chat-page .chat-log .bubble .inline-emoji { height: 1.4em; vertical-align: -.3em; }
.chat-page .chat-log .sticker { font-size: 76px; line-height: 1.05; filter: drop-shadow(0 8px 14px rgba(0,0,0,.28)); }
.chat-page .chat-log .bubble-sticker { background: none !important; box-shadow: none !important; padding: 0 !important; }
.chat-page .chat-log .bubble-sticker img { max-width: 170px; max-height: 170px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.3)); }

/* replied-to context tucks behind the bubble */
.chat-page .chat-log .quote { position: relative; z-index: 0; display: grid; gap: 1px; max-width: 100%; margin: 0 0 -12px; padding: 8px 13px 19px; border: 0; border-radius: 17px; background: color-mix(in srgb, var(--ink) 7%, transparent); box-shadow: inset 3px 0 0 var(--purple); font-size: 12px; color: var(--muted); cursor: pointer; }
.chat-page .chat-log .msg.mine .quote { background: color-mix(in srgb, var(--cp-me-a) 38%, transparent); box-shadow: inset -3px 0 0 var(--pink); color: color-mix(in srgb, var(--ink) 72%, transparent); }
.chat-page .chat-log .quote b { font-size: 12px; color: var(--ink); filter: none; }
.chat-page .chat-log .quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; opacity: 1; }
.chat-page .chat-log .quote:hover { filter: none; background: color-mix(in srgb, var(--ink) 11%, transparent); }

/* media */
.chat-page .chat-log .chat-media-figure { position: relative; margin: 0; width: auto; max-width: min(380px, 100%); border: 0; border-radius: 20px; overflow: hidden; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair), 0 10px 28px rgba(0,0,0,.3); }
.chat-page .chat-log .chat-media-figure img, .chat-page .chat-log .chat-media-figure video { display: block; width: 100%; max-height: 420px; object-fit: cover; background: #000; }
.chat-page .chat-log .chat-media-figure figcaption { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 26px 12px 9px; background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; font-size: 11.5px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.chat-page .chat-log .chat-media-figure figcaption * { color: inherit; }
.chat-page .chat-log .chat-media-figure:hover figcaption, .chat-page .chat-log .chat-media-figure:focus-within figcaption { opacity: 1; pointer-events: auto; }
.chat-page .chat-log .chat-media-video figcaption { position: static; opacity: 1; pointer-events: auto; background: var(--cp-raise); padding: 8px 12px; }
.chat-page .chat-log .chat-attachment-card { display: flex; align-items: center; gap: 12px; min-width: 220px; max-width: 340px; padding: 11px 14px 11px 11px; border: 0; border-radius: 18px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); color: var(--ink); text-decoration: none; }
.chat-page .chat-log .chat-attachment-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(145deg, var(--purple), var(--pink)); color: #fff; font-weight: 800; font-size: 12px; flex: none; }
.chat-page .chat-log .chat-attachment-copy { display: grid; gap: 2px; min-width: 0; }
.chat-page .chat-log .chat-attachment-copy b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .chat-log .chat-attachment-copy small { color: var(--muted); font-size: 12px; }
.chat-page .chat-log .link-card { display: block; margin-top: 6px; max-width: min(340px, 100%); overflow: hidden; border: 0; border-radius: 18px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); color: var(--ink); text-decoration: none; }
.chat-page .chat-log .lc-body { padding: 10px 14px 12px; display: grid; gap: 3px; }
.chat-page .chat-log .lc-site { font-size: 10.5px; letter-spacing: 1.2px; font-weight: 800; color: var(--muted-2); text-transform: uppercase; opacity: 1; }
.chat-page .chat-log .lc-title { font-size: 14px; font-weight: 700; }
.chat-page .chat-log .lc-desc { font-size: 12.5px; color: var(--muted); opacity: 1; }
.chat-page .chat-log .msg.mine .link-card { background: color-mix(in srgb, var(--cp-me-a) 40%, var(--cp-raise)); }
.chat-page .chat-log .msg.mine .lc-site, .chat-page .chat-log .msg.mine .lc-desc { color: color-mix(in srgb, var(--ink) 75%, transparent); }

/* voice notes */
.chat-page .chat-log .bubble-voice { display: flex; align-items: center; gap: 12px; min-width: 230px; padding: 9px 16px 9px 9px; }
.chat-page .chat-log .bubble-voice .play-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: linear-gradient(145deg, var(--purple), var(--pink)); color: #fff; font-size: 14px; cursor: pointer; box-shadow: 0 5px 14px color-mix(in srgb, var(--purple) 38%, transparent); }
.chat-page .chat-log .msg.mine .bubble-voice .play-btn { background: #fff; color: var(--cp-me-a); box-shadow: 0 5px 14px rgba(0,0,0,.25); }
.chat-page .chat-log .bubble-voice .wave { flex: 1; height: 28px; display: flex; align-items: center; gap: 2.5px; padding: 0; background: none; cursor: pointer; }
.chat-page .chat-log .bubble-voice .wave i { flex: 1; max-width: 3px; min-width: 2px; border-radius: 3px; background: currentColor; opacity: .38; }
.chat-page .chat-log .bubble-voice .wave i.played { opacity: 1; background: var(--purple); }
.chat-page .chat-log .msg.mine .bubble-voice .wave i.played { background: #fff; }
.chat-page .chat-log .bubble-voice .dur { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .85; }

/* time + reactions */
.chat-page .chat-log .msg-under { display: flex; align-items: center; gap: 8px; margin: 3px 6px 0; padding: 0; min-height: 0; font-size: 11px; color: var(--muted-2); }
.chat-page .chat-log .msg.mine .msg-under { flex-direction: row; justify-content: flex-end; }
.chat-page .chat-log .msg-time { order: 1; display: none; opacity: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.chat-page .chat-log .msg.grp-last .msg-time { display: inline; }
.chat-page .chat-log .msg:not(.grp-last):not(.has-reactions) .msg-under { display: none; }
.chat-page .chat-log .reactions { order: 0; display: flex; gap: 4px; flex-wrap: wrap; margin: 0; }
.chat-page .chat-log .reactions:empty { display: none; }
.chat-page .chat-log .msg.has-reactions .msg-under { position: relative; z-index: 2; margin-top: -9px; }
.chat-page .chat-log .msg.has-reactions.grp-last .msg-under, .chat-page .chat-log .msg.has-reactions .msg-under { margin-bottom: 4px; }
.chat-page .chat-log .reaction-chip { display: inline-flex; align-items: center; gap: 4px; min-width: 0; height: 24px; padding: 0 8px; border: 0; border-radius: 999px; background: var(--cp-raise); color: var(--ink); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; box-shadow: 0 0 0 2px var(--bg-2), inset 0 0 0 1px var(--cp-hair-2); transition: transform .18s var(--cp-ease); }
.chat-page .chat-log .reaction-chip img { width: 15px; height: 15px; }
.chat-page .chat-log .reaction-chip:hover { transform: translateY(-1px) scale(1.05); }
.chat-page .chat-log .reaction-chip.mine { background: color-mix(in srgb, var(--purple) 30%, var(--cp-raise)); box-shadow: 0 0 0 2px var(--bg-2), inset 0 0 0 1px color-mix(in srgb, var(--purple) 70%, transparent); }

/* hover toolbar */
.chat-page .chat-log .msg-actions { position: absolute; top: -34px; left: 6px; z-index: 6; display: flex; align-items: center; gap: 1px; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--bg-2) 92%, var(--card)); box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 0 0 1px var(--cp-hair-2); opacity: 0; transform: translateY(5px) scale(.96); pointer-events: none; transition: opacity .15s, transform .2s var(--cp-ease); }
.chat-page .chat-log .msg.mine .msg-actions { left: auto; right: 6px; }
.chat-page .chat-log .msg:hover .msg-actions, .chat-page .chat-log .msg:focus-within .msg-actions { opacity: 1; transform: none; pointer-events: auto; }
.chat-page .chat-log .msg-actions .react-row { position: static; display: flex; gap: 0; width: auto; height: auto; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; opacity: 1; transform: none; transition: none; }
.chat-page .chat-log .msg-actions button { display: grid; place-items: center; width: 30px; height: 30px; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; position: static; opacity: 1; transform: none; transition: background .15s, transform .18s var(--cp-ease), color .15s; }
.chat-page .chat-log .msg-actions .react-row button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); transform: scale(1.22) translateY(-2px); }
.chat-page .chat-log .msg-actions .reply-btn, .chat-page .chat-log .msg-actions .message-more-btn { font-size: 17px; }
.chat-page .chat-log .msg-actions .reply-btn { margin-left: 3px; border-left: 1px solid var(--cp-hair); border-radius: 0 50% 50% 0; width: 32px; }
.chat-page .chat-log .msg-actions .reply-btn:hover, .chat-page .chat-log .msg-actions .message-more-btn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); transform: none; }
.chat-page .chat-log .msg:first-of-type .msg-actions, .chat-page .chat-log .day-divider + .msg .msg-actions { top: -30px; }
@media (hover: none) { .chat-page .chat-log .msg-actions { display: none; } }

/* heart burst on double-tap */
.chat-page .chat-log .heart-burst { position: absolute; z-index: 8; font-size: 46px; line-height: 1; transform: translate(-50%, -50%); pointer-events: none; filter: drop-shadow(0 6px 14px rgba(255,60,120,.5)); animation: cp-heart .85s var(--cp-ease) forwards; }
@keyframes cp-heart { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); } 25% { opacity: 1; transform: translate(-50%, -60%) scale(1.25); } 60% { opacity: 1; transform: translate(-50%, -70%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -140%) scale(1); } }
.chat-page .chat-log .msg.flash .bubble { animation: cp-flash 1.2s ease-out; }
@keyframes cp-flash { 0%, 40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 55%, transparent); } }
.chat-page .chat-log .msg.swiping-now::after, .chat-page .chat-log .msg.swipe-armed::after { color: var(--purple); }

/* empty state */
.chat-page .chat-empty { margin: auto; display: grid; justify-items: center; gap: 10px; max-width: 340px; padding: 40px 20px; text-align: center; }
.chat-page .chat-empty-icon { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; font-size: 30px; color: #fff; background: linear-gradient(145deg, var(--purple), var(--pink)); box-shadow: 0 16px 40px color-mix(in srgb, var(--purple) 35%, transparent); }
.chat-page .chat-empty h3 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.4px; }
.chat-page .chat-empty p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.chat-page .chat-empty-hint { font-size: 12px; color: var(--muted-2); }

/* typing + jump */
.chat-page .typing-line { flex: 0 0 auto; display: none; align-items: center; gap: 9px; margin: 0 0 4px; padding: 0 clamp(14px, 3vw, 30px) 4px 56px; font-size: 12px; color: var(--muted); min-height: 0; }
.chat-page .typing-line.is-typing { display: flex; }
.chat-page .typing-dots { display: inline-flex; align-items: center; gap: 4px; padding: 9px 12px; border-radius: 16px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); }
.chat-page .typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: cp-dot 1.2s ease-in-out infinite; }
.chat-page .typing-dots i:nth-child(2) { animation-delay: .15s; } .chat-page .typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cp-dot { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-page .jump-latest { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 5; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: linear-gradient(135deg, var(--cp-me-a), var(--cp-me-b)); color: #fff; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; box-shadow: 0 10px 28px rgba(0,0,0,.4); animation: cp-in .25s var(--cp-ease); }
.chat-page .jump-latest[hidden] { display: none; }

/* ---------- composer ---------- */
.chat-page .chat-form { position: relative; display: flex; align-items: flex-end; gap: 8px; flex: 0 0 auto; margin: 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 1px solid var(--cp-hair); border-radius: 0; background: var(--cp-panel); box-shadow: none; z-index: 5; }
.chat-page .chat-form.is-drop-target { background: color-mix(in srgb, var(--purple) 14%, var(--cp-panel)); }
.chat-page .chat-form .attach-btn, .chat-page .chat-form .mic-btn, .chat-page .chat-form .send-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; min-width: 44px; padding: 0; border: 0; border-radius: 50%; font-size: 22px; cursor: pointer; box-shadow: none; transition: transform .2s var(--cp-ease), background .18s, box-shadow .2s; }
.chat-page .chat-form .attach-btn, .chat-page .chat-form .mic-btn { background: var(--cp-raise); color: var(--muted); box-shadow: inset 0 0 0 1px var(--cp-hair); }
.chat-page .chat-form .attach-btn:hover, .chat-page .chat-form .mic-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, var(--cp-raise)); }
.chat-page .chat-form .attach-btn[aria-expanded="true"] { transform: rotate(45deg); color: var(--ink); }
.chat-page .chat-form .send-btn { color: #fff; background: linear-gradient(135deg, var(--cp-me-a), var(--cp-me-b)); box-shadow: 0 8px 22px color-mix(in srgb, var(--cp-me-a) 50%, transparent), inset 0 1px rgba(255,255,255,.2); animation: cp-pop .24s var(--cp-ease); }
.chat-page .chat-form .send-btn:hover { transform: translateY(-1px) scale(1.04); }
.chat-page .chat-form .send-btn:active, .chat-page .chat-form .mic-btn:active, .chat-page .chat-form .attach-btn:active { transform: scale(.92); box-shadow: none; }
@keyframes cp-pop { from { transform: scale(.6); opacity: 0; } }
.chat-page .chat-form:not(.has-text) .send-btn { display: none; }
.chat-page .chat-form.has-text .mic-btn:not(.recording) { display: none; }
.chat-page .chat-form .mic-btn.recording { display: grid; background: #ff4d6d; color: #fff; box-shadow: 0 0 0 0 rgba(255,77,109,.6); animation: cp-rec 1.4s ease-out infinite; }
@keyframes cp-rec { to { box-shadow: 0 0 0 14px rgba(255,77,109,0); } }
.chat-page .chat-input-wrap { position: relative; display: flex; align-items: flex-end; flex: 1; min-width: 0; padding: 3px 5px 3px 18px; border-radius: 26px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); transition: box-shadow .2s; }
.chat-page .chat-input-wrap:focus-within { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 70%, transparent), 0 0 0 5px color-mix(in srgb, var(--purple) 13%, transparent); }
.chat-page .chat-form .chat-input-wrap #chat-input, .chat-page .chat-form #chat-input { flex: 1; width: auto; min-width: 0; min-height: 0; height: 24px; max-height: 132px; margin: 0; padding: 10px 6px 10px 0; border: 0; border-radius: 0; outline: 0; resize: none; background: transparent; box-shadow: none; color: var(--ink); font: inherit; font-size: 15px; line-height: 24px; overflow-y: auto; scrollbar-width: none; }
.chat-page .chat-form #chat-input:focus { border: 0; box-shadow: none; }
.chat-page .chat-form #chat-input::placeholder { color: var(--muted-2); }
.chat-page .chat-form .emoji-btn { display: grid; place-items: center; flex: none; align-self: flex-end; width: 38px; height: 38px; margin: 1px 0; padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--muted); font-size: 22px; cursor: pointer; transition: color .15s, transform .2s var(--cp-ease); }
.chat-page .chat-form .emoji-btn:hover { color: var(--ink); transform: scale(1.1); }
.chat-page .chat-form:has(.rec-status) .chat-input-wrap { visibility: hidden; }
.chat-page .chat-form .rec-status { position: absolute; left: 68px; right: 68px; top: 50%; transform: translateY(-65%); display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 18px; border-radius: 26px; background: color-mix(in srgb, #ff4d6d 14%, var(--cp-raise)); box-shadow: inset 0 0 0 1px rgba(255,77,109,.45); color: var(--ink); font-size: 14px; font-weight: 600; animation: none; }
.chat-page .chat-form .rec-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #ff4d6d; animation: cp-blink 1s infinite; }
@keyframes cp-blink { 50% { opacity: .25; } }

.chat-page .chat-composer-menu { position: absolute; left: 16px; bottom: calc(100% + 8px); z-index: 20; display: grid; gap: 2px; width: 270px; padding: 8px; border: 0; border-radius: 22px; background: color-mix(in srgb, var(--bg-2) 94%, var(--card)); box-shadow: 0 24px 60px rgba(0,0,0,.5), inset 0 0 0 1px var(--cp-hair-2); animation: cp-rise .22s var(--cp-ease); }
.chat-page .chat-composer-menu[hidden] { display: none; }
.chat-page .chat-composer-menu button { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 54px; padding: 8px 12px; border: 0; border-radius: 15px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.chat-page .chat-composer-menu button:hover, .chat-page .chat-composer-menu button:focus-visible { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.chat-page .chat-composer-menu button > span:first-child { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, color-mix(in srgb, var(--purple) 70%, #0c0920), color-mix(in srgb, var(--pink) 60%, #0c0920)); color: #fff; font-size: 17px; flex: none; }
.chat-page .chat-composer-menu button > span:last-child { display: grid; gap: 1px; }
.chat-page .chat-composer-menu b { font-size: 14px; } .chat-page .chat-composer-menu small { font-size: 12px; color: var(--muted); }
@keyframes cp-rise { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.chat-page .emoji-picker { position: absolute; right: 16px; bottom: calc(100% + 8px); left: auto; z-index: 20; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; width: min(360px, calc(100vw - 32px)); max-height: 280px; padding: 10px; overflow-y: auto; border: 0; border-radius: 22px; background: color-mix(in srgb, var(--bg-2) 94%, var(--card)); box-shadow: 0 24px 60px rgba(0,0,0,.5), inset 0 0 0 1px var(--cp-hair-2); animation: cp-rise .22s var(--cp-ease); }
.chat-page .emoji-picker button { display: grid; place-items: center; height: 38px; padding: 0; border: 0; border-radius: 12px; background: transparent; font-size: 22px; cursor: pointer; }
.chat-page .emoji-picker button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); transform: scale(1.12); }
.chat-page .emoji-picker .ce-section { grid-column: 1 / -1; }

/* reply banner + send status + attachments */
.chat-page .reply-banner { display: flex; align-items: center; gap: 12px; margin: 0; padding: 10px 16px 10px 20px; border: 0; border-top: 1px solid var(--cp-hair); border-radius: 0; background: var(--cp-panel); box-shadow: inset 3px 0 0 var(--purple); animation: cp-drop .2s var(--cp-ease); }
.chat-page .reply-banner .r-text { flex: 1; min-width: 0; display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .reply-banner .r-text b { color: var(--ink); }
.chat-page .reply-banner .r-close { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--muted); cursor: pointer; }
.chat-page .chat-send-status { margin: 0 16px 6px; padding: 7px 13px; border-radius: 12px; font-size: 12.5px; background: var(--cp-raise); color: var(--muted); }
.chat-page .chat-send-status[data-state="error"], .chat-page .chat-send-status.is-error { background: color-mix(in srgb, #ff4d6d 16%, var(--cp-raise)); color: var(--ink); }
.chat-page .chat-attachment-preview-card { display: flex; align-items: center; gap: 12px; margin: 0 16px 8px; padding: 10px; border-radius: 16px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); font-size: 13px; }
.chat-page .chat-attachment-preview-card img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; }
.chat-page .connection-banner { flex: 0 0 auto; padding: 8px 16px; text-align: center; font-size: 12.5px; font-weight: 600; background: color-mix(in srgb, var(--orange) 18%, var(--bg-2)); color: var(--ink); border-bottom: 1px solid var(--cp-hair); }

/* ---------- details drawer ---------- */
.chat-page .chat-workspace .chat-details-rail { position: absolute; top: 0; right: 0; bottom: 0; z-index: 12; display: flex; flex-direction: column; align-items: stretch; gap: 14px; width: min(360px, 100%); max-height: none; padding: 22px 18px 28px; overflow-y: auto; border: 0; border-left: 1px solid var(--cp-hair-2); background: color-mix(in srgb, var(--bg-2) 97%, var(--card)); box-shadow: -30px 0 60px rgba(0,0,0,.35); transform: translateX(104%); visibility: hidden; transition: transform .32s var(--cp-ease), visibility 0s .32s; }
.chat-page.details-open .chat-workspace .chat-details-rail { transform: none; visibility: visible; transition: transform .32s var(--cp-ease); }
.chat-page .chat-details-close { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--muted); font-size: 18px; cursor: pointer; }
.chat-page .chat-details-close:hover { color: var(--ink); }
.chat-page .chat-details-scrim { display: none; position: absolute; inset: 0; z-index: 11; border: 0; padding: 0; background: rgba(4,2,12,.5); backdrop-filter: blur(2px); cursor: default; }
.chat-page.details-open .chat-details-scrim { display: block; animation: cp-fade .25s; }
@keyframes cp-fade { from { opacity: 0; } }
.chat-page .chat-details-orb { display: grid; place-items: center; width: 76px; height: 76px; margin: 14px auto 2px; border-radius: 50%; background: linear-gradient(145deg, var(--purple), var(--pink)); color: #fff; font-size: 32px; box-shadow: 0 16px 40px color-mix(in srgb, var(--purple) 35%, transparent); }
.chat-page .chat-details-orb .av { width: 76px !important; height: 76px !important; font-size: 30px !important; }
.chat-page .chat-details-eyebrow { text-align: center; font-size: 10px; letter-spacing: 2px; font-weight: 800; color: var(--muted-2); }
.chat-page .chat-details-rail h3 { margin: -6px 0 0; text-align: center; font-size: 22px; letter-spacing: -.5px; }
.chat-page .chat-details-rail > p { margin: 0 0 4px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--muted); }
.chat-page .chat-detail-stat { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border: 0; border-radius: 16px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); }
.chat-page .chat-detail-stat span { font-size: 12px; letter-spacing: .2px; text-transform: none; font-weight: 600; color: var(--muted); }
.chat-page .chat-detail-stat b { font-size: 13px; }
.chat-page .chat-notification-settings, .chat-page .chat-collection-actions, .chat-page .chat-wallpaper-section, .chat-page .shared-media-section { display: grid; gap: 10px; padding: 14px; border: 0; border-radius: 18px; background: var(--cp-raise); box-shadow: inset 0 0 0 1px var(--cp-hair); }
.chat-page .shared-media-heading { display: flex; align-items: center; justify-content: space-between; }
.chat-page .shared-media-heading b { font-size: 13px; }
.chat-page .shared-media-heading span { padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 9%, transparent); font-size: 10px; letter-spacing: 1px; font-weight: 800; color: var(--muted); }
.chat-page .chat-notification-settings p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.chat-page .chat-profile-action { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 46px; padding: 0 16px; border: 0; border-radius: 14px; background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer; transition: background .18s; }
.chat-page .chat-profile-action:hover { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.chat-page .chat-notification-settings .chat-profile-action, .chat-page .chat-collection-actions .chat-profile-action { background: color-mix(in srgb, var(--bg) 40%, transparent); }
.chat-page .chat-wallpaper-section { display: grid !important; }
.chat-page .chat-wallpaper-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chat-page .chat-wallpaper-choice { min-height: 66px; justify-items: center; align-content: center; padding: 8px 4px; }
.chat-page .shared-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chat-page .shared-media-item { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); text-decoration: none; font-size: 26px; }
.chat-page .shared-media-image img { width: 100%; height: 100%; object-fit: cover; }
.chat-page .shared-media-empty { display: grid; justify-items: center; gap: 4px; padding: 14px 6px; text-align: center; color: var(--muted); }
.chat-page .shared-media-empty small { font-size: 12px; line-height: 1.5; }
.chat-page .chat-details-stories { margin-top: 2px; min-height: 48px; border: 0; border-radius: 16px; background: linear-gradient(135deg, var(--cp-me-a), var(--cp-me-b)); color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }

/* ---------- thread view ---------- */
.chat-page .thread-header { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; min-height: 66px; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--cp-hair); background: var(--cp-panel); }
.chat-page .thread-header .chat-back { display: grid; }
.chat-page .thread-title { display: grid; gap: 1px; }
.chat-page .thread-title strong { font-size: 16px; }
.chat-page .thread-label { font-size: 12px; color: var(--muted); }

/* ---------- message menu ---------- */
.msg-menu { z-index: 1000; min-width: 232px; padding: 8px; border: 0; border-radius: 20px; background: color-mix(in srgb, var(--bg-2) 94%, var(--card)); box-shadow: 0 28px 70px rgba(0,0,0,.55), inset 0 0 0 1px var(--cp-hair-2, rgba(255,255,255,.14)); animation: cp-rise .2s cubic-bezier(.22,1,.36,1); }
.msg-menu-react { display: flex; justify-content: space-between; gap: 2px; padding: 4px 4px 8px; margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.09); }
.msg-menu-react button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 22px; cursor: pointer; transition: transform .18s cubic-bezier(.22,1,.36,1), background .15s; }
.msg-menu-react button:hover { background: rgba(255,255,255,.1); transform: scale(1.25) translateY(-3px); }
.msg-menu > button[role="menuitem"] { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.msg-menu > button[role="menuitem"]:hover { background: rgba(255,255,255,.08); }
.msg-menu > button.danger { color: #ff6b8a; }

/* ---------- tablets & phones ---------- */
@media (max-width: 960px) {
  .chat-page .chat-workspace { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  main[data-page="chat"] .content { padding: 8px 8px 12px; }
  .chat-page { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px) - 16px); min-height: 0; border-radius: 22px; }
  .chat-page .chat-workspace { display: block; }
  .chat-page .chat-workspace .chat-conversation-rail { position: absolute; inset: 0; z-index: 1; border-right: 0; padding-top: 16px; }
  .chat-page .chat-main-column { position: absolute; inset: 0; z-index: 2; background: color-mix(in srgb, var(--bg-2) 98%, var(--bg)); }
  .chat-page[data-pane="list"] .chat-main-column { display: none; }
  .chat-page[data-pane="convo"] .chat-workspace .chat-conversation-rail { display: none; }
  .chat-page .chat-back { display: grid; }
  .chat-page .chat-main-column .chat-identity { min-height: 64px; padding: 8px 8px 8px 12px; gap: 10px; }
  .chat-page .chat-hd-btn { width: 40px; height: 40px; }
  .chat-page .chat-log .msg-body { max-width: 82%; }
  .chat-page .chat-form { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  .chat-page .chat-form .rec-status { left: 56px; right: 56px; }
  .chat-page .chat-composer-menu { left: 10px; }
  .chat-page .emoji-picker { right: 10px; grid-template-columns: repeat(7, 1fr); }
  .chat-page .jump-latest { bottom: 84px; }
  .chat-page .typing-line { padding-left: 52px; }

  /* conversation open: take over the whole screen, like a native messenger */
  body.chat-immersive main[data-page="chat"] > .topbar, body.chat-immersive .tabbar { display: none; }
  body.chat-immersive main[data-page="chat"] .content { padding: 0; }
  body.chat-immersive .chat-page { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  body.chat-immersive .chat-page .chat-identity { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  body.chat-immersive .chat-page .thread-header { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
}
@media (max-width: 380px) {
  .chat-page .chat-form .attach-btn, .chat-page .chat-form .mic-btn, .chat-page .chat-form .send-btn { width: 40px; height: 40px; min-width: 40px; }
  .chat-page .chat-identity-actions .chat-stories-shortcut { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-page *, .chat-page *::before, .chat-page *::after, .msg-menu, .msg-menu * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Step 2BI — polish pass */
main[data-page="chat"] > .topbar #chat-search-btn { display: none; }
.chat-page .chat-collection-tabs { width: 100%; box-sizing: border-box; }
.chat-page .day-divider::before, .chat-page .day-divider::after { display: none; }
.chat-page .chat-log .msg.grp-last .msg-avatar { margin-bottom: 19px; }
.chat-page .chat-log .msg.grp-last:not(.has-reactions) .msg-avatar { margin-bottom: 19px; }
.chat-page .chat-log .quote b, .chat-page .chat-log .quote span { text-transform: none; letter-spacing: 0; }
.chat-page .chat-log .quote b { font-size: 12px; font-weight: 700; }
.chat-page .chat-log .msg.mine .quote b { color: #fff; }
.chat-page .chat-log .msg.mine .quote { border-radius: 17px; }
.chat-page .chat-log .chat-media-figure { display: block; }
.chat-page .chat-log .chat-media-figure img { aspect-ratio: auto; height: auto; max-height: 380px; }
.chat-page .chat-log .chat-media-open { display: block; line-height: 0; }
.chat-page .chat-log .msg.mine .chat-media-figure { margin-left: auto; }
@media (max-width: 760px) { .chat-page .chat-workspace .chat-main-column { height: auto; flex: none; } }
.chat-page .chat-details-rail > * { flex: none; }
.chat-page, .chat-page .chat-workspace { overflow: clip; }
.chat-page .chat-form #chat-input, .chat-page .chat-form .chat-input-wrap #chat-input { box-sizing: border-box; height: 40px; min-height: 40px; padding: 8px 6px 8px 0; }
.chat-page .chat-form .attach-btn, .chat-page .chat-form .mic-btn, .chat-page .chat-form .send-btn { width: 46px; height: 46px; min-width: 46px; }
.chat-page .chat-form .emoji-btn { width: 40px; height: 40px; margin: 0; }
.chat-page .jump-latest { position: relative; left: auto; bottom: auto; transform: none; align-self: center; flex: 0 0 auto; height: 36px; margin: -48px auto 12px; }
@media (max-width: 760px) { .chat-page .jump-latest { bottom: auto; } }
.chat-page .chat-main-column .chat-log, .chat-page > .chat-log { scroll-behavior: auto; }
.chat-page .day-divider { position: static; }
.chat-page .chat-form { z-index: 6; }

/* ================================================================
   Step 2BJ — premium design system for the whole app
   Shared tokens + shell, controls, cards, settings and stash. Same soft-glass
   language as the chat so every tab feels like one product.
   ================================================================ */
:root {
  --pm-hair: color-mix(in srgb, var(--ink) 9%, transparent);
  --pm-hair-2: color-mix(in srgb, var(--ink) 15%, transparent);
  --pm-panel: color-mix(in srgb, var(--card) 86%, transparent);
  --pm-raise: color-mix(in srgb, var(--card-2) 78%, var(--bg));
  --pm-a: color-mix(in srgb, var(--purple) 62%, #0c0920);
  --pm-b: color-mix(in srgb, var(--pink) 56%, #0c0920);
  --pm-grad: linear-gradient(135deg, var(--pm-a), var(--pm-b));
  --pm-ease: cubic-bezier(.22, 1, .36, 1);
  --pm-shadow: 0 18px 50px rgba(0, 0, 0, .32);
  --shadow-btn: none; --shadow-card: none;
}
body { font-size: 15px; }
body[data-textsize="sm"] { font-size: 14px; }
body[data-textsize="lg"] { font-size: 17px; }
body[data-density="compact"] .content { padding-top: 12px; }
body[data-density="compact"] .settings-section, body[data-density="compact"] .poll-card, body[data-density="compact"] .member-profile-card { padding-block: 12px; }
svg { flex: none; }
.ic svg, .icon-btn svg, .box svg, .dz-icon svg, .view-toggle svg, .more-item svg, .more-signout svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sidebar ---------- */
@media (min-width: 960px) {
  .sidebar { padding: 22px 14px 16px; border-right: 1px solid var(--pm-hair); background: color-mix(in srgb, var(--bg-2) 88%, transparent); backdrop-filter: blur(18px); }
}
.brand { transform: none; margin: 2px 8px 26px; gap: 11px; font-size: 21px; font-weight: 800; letter-spacing: -.6px; }
.brand .box, .topbar .brand-mobile .box { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 11px; background: var(--pm-grad); color: #fff; font-size: 18px; box-shadow: 0 8px 22px color-mix(in srgb, var(--pm-a) 45%, transparent), inset 0 1px rgba(255,255,255,.2); }
.brand span:not(.box) { color: var(--muted); font-weight: 600; }
.nav { display: grid; gap: 3px; }
.nav-btn { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 46px; padding: 0 14px; border: 0 !important; border-radius: 14px; background: transparent; color: var(--muted); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background .18s, color .18s; position: relative; }
.nav-btn .ic { display: grid; place-items: center; width: 22px; font-size: 20px; color: inherit; transition: transform .25s var(--pm-ease); }
.nav-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.nav-btn:hover .ic { transform: scale(1.08); }
.nav-btn.on { color: var(--ink); background: linear-gradient(100deg, color-mix(in srgb, var(--purple) 24%, transparent), color-mix(in srgb, var(--pink) 10%, transparent)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--purple) 34%, transparent); }
.nav-btn.on .ic { color: var(--lime); }
.nav-btn.on::before { display: none; }
.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--pm-hair); }
.me-card { padding: 8px; border: 0; border-radius: 16px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.me-card .icon-btn { width: 34px; height: 34px; background: transparent; border: 0; color: var(--muted); }
.me-card .icon-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.av { border: 0; box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg-2) 90%, transparent); }

/* ---------- top bar ---------- */
.topbar { height: var(--topbar-h); padding: 0 clamp(14px, 2.4vw, 28px); background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); border-bottom: 1px solid var(--pm-hair); }
.topbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -.5px; text-transform: capitalize; }
.topbar .brand-mobile b { font-size: 17px; letter-spacing: -.4px; }
.topbar .brand-mobile .box { width: 32px; height: 32px; font-size: 16px; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 19px; box-shadow: inset 0 0 0 1px var(--pm-hair); transition: background .18s, color .18s, transform .2s var(--pm-ease); }
.icon-btn:hover { transform: none; border: 0; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }

/* ---------- content + right rail ---------- */
.content { max-width: 980px; padding: 18px clamp(14px, 2.4vw, 28px) 28px; }
@media (min-width: 960px) { .content { max-width: 980px; padding: 26px clamp(20px, 3vw, 40px) 40px; } }
@media (min-width: 1280px) { .content { max-width: 940px; } }
.rightbar { border-left: 1px solid var(--pm-hair) !important; background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
.rail-card { border: 0; border-radius: 20px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.rail-card h4 { font-size: 11px; letter-spacing: 1.8px; }
.online-user { padding: 3px 0; }
.online-user .dot { border: 0; background: #3ddc97; box-shadow: 0 0 0 3px rgba(61,220,151,.18); }

/* ---------- mobile tab bar + more sheet ---------- */
.tabbar { height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 6px 8px env(safe-area-inset-bottom, 0px); gap: 2px; background: color-mix(in srgb, var(--bg-2) 90%, transparent); backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3); border-top: 1px solid var(--pm-hair); }
.tab { border-radius: 16px; font-size: 10.5px; font-weight: 700; letter-spacing: .1px; gap: 3px; transition: color .18s, background .18s; }
.tab .ic { display: grid; place-items: center; font-size: 22px; transition: transform .25s var(--pm-ease); }
.tab.on { color: var(--ink); background: color-mix(in srgb, var(--purple) 16%, transparent); }
.tab.on .ic { color: var(--lime); transform: translateY(-1px) scale(1.06); }
.more-sheet-wrap { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; background: rgba(4,2,12,.55); backdrop-filter: blur(3px); animation: pm-fade .2s; }
.more-sheet { width: 100%; max-width: 560px; margin: 0 auto; padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 28px 28px 0 0; background: color-mix(in srgb, var(--bg-2) 96%, var(--card)); box-shadow: 0 -20px 60px rgba(0,0,0,.5), inset 0 1px var(--pm-hair-2); animation: pm-sheet .3s var(--pm-ease); }
.more-grip { display: block; width: 40px; height: 4px; margin: 4px auto 14px; border-radius: 4px; background: var(--pm-hair-2); }
.more-user { display: flex; align-items: center; gap: 12px; padding: 4px 6px 14px; }
.more-user b { display: block; font-size: 16px; } .more-user small { color: var(--muted); }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { display: grid; justify-items: center; gap: 8px; padding: 16px 8px 14px; border: 0; border-radius: 20px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; text-transform: capitalize; cursor: pointer; transition: transform .2s var(--pm-ease), background .18s; }
.more-item span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--pm-grad); color: #fff; font-size: 22px; }
.more-item.on { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 70%, transparent); }
.more-item:active { transform: scale(.95); }
.more-signout { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 50px; margin-top: 14px; border: 0; border-radius: 16px; background: color-mix(in srgb, #ff4d6d 14%, transparent); color: #ff7b93; font: inherit; font-weight: 700; cursor: pointer; }
@keyframes pm-fade { from { opacity: 0; } }
@keyframes pm-sheet { from { transform: translateY(40px); opacity: 0; } }

/* ---------- buttons ---------- */
.btn { min-height: 42px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--pm-grad); color: #fff; font-size: 14px; font-weight: 700; letter-spacing: -.1px; box-shadow: 0 8px 22px color-mix(in srgb, var(--pm-a) 42%, transparent), inset 0 1px rgba(255,255,255,.18); transition: transform .2s var(--pm-ease), box-shadow .2s, background .18s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px color-mix(in srgb, var(--pm-a) 52%, transparent), inset 0 1px rgba(255,255,255,.2); }
.btn:active { transform: scale(.97); box-shadow: none; }
.btn.small { min-height: 36px; padding: 0 16px; border-radius: 999px; font-size: 13px; box-shadow: 0 6px 16px color-mix(in srgb, var(--pm-a) 36%, transparent), inset 0 1px rgba(255,255,255,.16); }
.btn.ghost { background: var(--pm-raise); color: var(--ink); box-shadow: inset 0 0 0 1px var(--pm-hair-2); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 9%, var(--pm-raise)); box-shadow: inset 0 0 0 1px var(--pm-hair-2); transform: none; }
.btn.danger { background: color-mix(in srgb, #ff4d6d 18%, var(--pm-raise)); color: #ff8aa0; box-shadow: inset 0 0 0 1px rgba(255,77,109,.4); }
.btn.danger:hover { background: color-mix(in srgb, #ff4d6d 28%, var(--pm-raise)); transform: none; }
.btn.cyan { background: color-mix(in srgb, var(--cyan) 20%, var(--pm-raise)); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 50%, transparent); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--lime) 80%, transparent); outline-offset: 2px; }

/* ---------- inputs ---------- */
.field label { font-size: 11px; letter-spacing: 1.4px; font-weight: 800; color: var(--muted); }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), textarea, select) { width: 100%; min-height: 46px; padding: 0 16px; border: 0; border-radius: 16px; outline: 0; background: var(--pm-raise); color: var(--ink); font: inherit; font-size: 14.5px; box-shadow: inset 0 0 0 1px var(--pm-hair); transition: box-shadow .2s; }
textarea { padding: 12px 16px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select):focus { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 75%, transparent), 0 0 0 5px color-mix(in srgb, var(--purple) 13%, transparent); }
:where(select) { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238b7fb0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; cursor: pointer; }
input[type="file"] { width: 100%; padding: 10px; border-radius: 16px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); color: var(--muted); font-size: 13px; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--pm-grad); color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--purple); width: 18px; height: 18px; }
.err { color: #ff8aa0; font-size: 13px; }

/* ---------- toast ---------- */
.toast { bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom, 0px)); padding: 12px 20px; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--bg-2) 94%, var(--card)); color: var(--ink); font-weight: 600; font-size: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.5), inset 0 0 0 1px var(--pm-hair-2); backdrop-filter: blur(14px); }
@media (min-width: 960px) { .toast { bottom: 28px; } }

/* ---------- settings ---------- */
.settings-nav { display: flex; gap: 6px; margin: 0 0 18px; padding: 5px; overflow-x: auto; scrollbar-width: none; border-radius: 999px; background: color-mix(in srgb, var(--bg) 55%, transparent); box-shadow: inset 0 0 0 1px var(--pm-hair); position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 5; backdrop-filter: blur(14px); }
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav button { flex: 1 0 auto; min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; transition: background .2s, color .2s; }
.settings-nav button:hover { color: var(--ink); }
.settings-nav button.on { background: var(--pm-raise); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.06); }
.settings-section { margin: 0 0 16px; padding: 22px; border: 0; border-radius: 24px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair), 0 14px 40px rgba(0,0,0,.18); animation: pm-rise .35s var(--pm-ease) both; }
.settings-section h3 { margin: 0 0 14px; padding: 0; border: 0; font-size: 17px; font-weight: 800; letter-spacing: -.3px; text-transform: none; color: var(--ink); }
.settings-section h3::after { display: none; }
.settings-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.settings-heading-row > span { display: none; }
@keyframes pm-rise { from { opacity: 0; transform: translateY(10px); } }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.theme-choice { display: grid; gap: 10px; padding: 14px; border: 0; border-radius: 20px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); color: var(--ink); text-align: left; cursor: pointer; transition: transform .2s var(--pm-ease), box-shadow .2s; }
.theme-choice:hover { transform: translateY(-2px); }
.theme-choice.on { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--purple) 80%, transparent), 0 10px 30px color-mix(in srgb, var(--purple) 22%, transparent); }
.appearance-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--pm-hair); }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.pref-row + .pref-row { border-top: 1px solid var(--pm-hair); }
.pref-row b { display: block; font-size: 14.5px; } .pref-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; max-width: 34ch; }
.pref-divider { height: 1px; margin: 16px 0 4px; background: var(--pm-hair); }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 55%, transparent); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.seg button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--pm-grad); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--pm-a) 40%, transparent); }
.tip-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.tip-list li { padding: 11px 14px; border-radius: 14px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); color: var(--muted); font-size: 14px; }
.tip-list b { color: var(--ink); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 10px; }
.avatar-swatch { aspect-ratio: 1; border: 0; border-radius: 50%; font-weight: 800; font-size: 18px; color: #0b0715; cursor: pointer; transition: transform .2s var(--pm-ease); }
.avatar-swatch:hover { transform: scale(1.1); }
.avatar-swatch.on { box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 5px var(--purple); }
.avatar-preview { display: grid; place-items: center; width: 84px; height: 84px; border: 0; border-radius: 50%; font-size: 32px; font-weight: 800; color: #0b0715; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.session-row { border: 0 !important; border-radius: 18px !important; background: var(--pm-raise) !important; box-shadow: inset 0 0 0 1px var(--pm-hair); }
#ce-grid > div { border: 0 !important; border-radius: 16px !important; background: var(--pm-raise) !important; box-shadow: inset 0 0 0 1px var(--pm-hair); }

/* ---------- stash ---------- */
.dropzone, .hero-card.dropzone { position: relative; display: flex; align-items: center; gap: 18px; padding: 20px 24px; margin: 0 0 18px; border: 1.5px dashed var(--pm-hair-2); border-radius: 24px; background: linear-gradient(110deg, color-mix(in srgb, var(--purple) 12%, transparent), color-mix(in srgb, var(--pink) 7%, transparent)); box-shadow: none; text-align: left; cursor: pointer; overflow: hidden; transition: border-color .2s, background .2s, transform .2s var(--pm-ease); }
.dropzone::before, .dropzone::after { display: none; }
.dropzone:hover { border-color: color-mix(in srgb, var(--purple) 70%, transparent); transform: translateY(-1px); }
.dz-icon { display: grid; place-items: center; width: 54px; height: 54px; flex: none; border-radius: 18px; background: var(--pm-grad); color: #fff; font-size: 26px; box-shadow: 0 10px 26px color-mix(in srgb, var(--pm-a) 45%, transparent); }
.dz-copy { flex: 1; min-width: 0; } .dz-copy h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.3px; } .dz-copy p { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.dropzone .hint { flex: none; margin: 0; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 50%, transparent); color: var(--muted); font-size: 12px; font-weight: 600; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 6px; }
.chip { min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--pm-raise); color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; box-shadow: inset 0 0 0 1px var(--pm-hair); cursor: pointer; transition: all .18s; }
.chip:hover { color: var(--ink); }
.chip.on { background: var(--pm-grad); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--pm-a) 36%, transparent); }
.filters .sort-select { width: auto; min-height: 36px; padding: 0 36px 0 14px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.filters .search-input { width: 190px; min-height: 36px; padding: 0 16px; border-radius: 999px; font-size: 13px; max-width: none; }
.view-toggle { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.view-toggle button { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 17px; cursor: pointer; }
.view-toggle button.on { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink); }
.stash-summary { margin: 10px 4px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted-2); min-height: 18px; }
.folders { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.folder-tile { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); font-weight: 700; font-size: 13.5px; cursor: pointer; transition: transform .2s var(--pm-ease), box-shadow .2s; }
.folder-tile:hover { transform: translateY(-1px); }
.folder-tile.active { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 75%, transparent); background: color-mix(in srgb, var(--purple) 16%, var(--pm-raise)); }
.folder-tile .fc { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 10%, transparent); font-size: 11px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; overflow: hidden; border: 0; border-radius: 22px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair), 0 10px 30px rgba(0,0,0,.2); cursor: pointer; transition: transform .25s var(--pm-ease), box-shadow .25s; animation: pm-rise .35s var(--pm-ease) both; }
.tile:hover { transform: translateY(-4px); box-shadow: inset 0 0 0 1px var(--pm-hair-2), 0 22px 44px rgba(0,0,0,.34); }
.tile .thumb { position: relative; aspect-ratio: 4 / 3.2; overflow: hidden; background: color-mix(in srgb, var(--bg) 70%, var(--card-2)); display: grid; place-items: center; }
.tile .thumb img, .tile .thumb video { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--pm-ease); }
.tile:hover .thumb img { transform: scale(1.05); }
.tile .em { font-size: 40px; }
.tile .badge-ext { position: absolute; left: 10px; bottom: 10px; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,.5); color: #fff; font-size: 10.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; }
.tile .play-icon { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.5); backdrop-filter: blur(6px); color: #fff; font-size: 16px; }
.tile-info { display: grid; gap: 4px; padding: 12px 14px 14px; min-width: 0; }
.tile-info b { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-info .av-row { gap: 6px; }
.grid[data-view="list"] { grid-template-columns: 1fr; gap: 8px; }
.grid[data-view="list"] .tile { flex-direction: row; align-items: center; border-radius: 18px; }
.grid[data-view="list"] .tile:hover { transform: translateX(3px); }
.grid[data-view="list"] .tile .thumb { width: 72px; height: 72px; aspect-ratio: auto; flex: none; border-radius: 14px; margin: 8px; }
.grid[data-view="list"] .tile .em { font-size: 28px; }
.grid[data-view="list"] .tile .badge-ext { display: none; }
.grid[data-view="list"] .tile .play-icon { width: 30px; height: 30px; font-size: 11px; }
.grid[data-view="list"] .tile-info { flex: 1; padding: 8px 16px 8px 4px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.stash-welcome { border-radius: 28px !important; border: 0 !important; box-shadow: inset 0 0 0 1px var(--pm-hair) !important; }
.stash-welcome .btn { color: #fff; }
.queue { display: grid; gap: 8px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .content { padding: 14px 14px 24px; }
  .topbar { padding: 0 14px; }
  .settings-nav { top: calc(var(--topbar-h) + 4px); }
  .settings-section { padding: 18px; border-radius: 22px; }
  .theme-grid { gap: 10px; }
  .pref-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .dropzone, .hero-card.dropzone { padding: 16px; gap: 14px; }
  .dropzone .hint { display: none; }
  .filters .search-input { flex: 1 1 100%; width: auto; order: 9; }
  .filters .grow { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid[data-view="list"] { grid-template-columns: 1fr; }
}

.brand span:not(.box) { margin-left: -9px; }
.filters #search.search-input { width: 190px; }
.tile .thumb, .tile-info { border: 0; }
@media (max-width: 760px) { .filters #search.search-input { width: auto; } }

/* ---------- polls ---------- */
.poll-create, .poll-card, .story-compose, .panel, .stat-card, .bulk-bar, .vault-intro, .vault-note, .vault-guide { border: 0; border-radius: 24px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair), 0 14px 40px rgba(0,0,0,.18); }
.poll-create { padding: 22px; margin-bottom: 18px; }
.poll-create h2, .story-compose-head h2, .story-compose h2 { margin: 0 0 14px; font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.poll-option-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.poll-create-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.poll-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted-2); }
.poll-list { display: grid; gap: 14px; }
.poll-card { padding: 22px; animation: pm-rise .35s var(--pm-ease) both; }
.poll-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.poll-card-head small { color: var(--muted); font-size: 12.5px; }
.poll-card-head h3 { margin: 4px 0 0; font-size: 19px; font-weight: 800; letter-spacing: -.4px; }
.poll-state { flex: none; padding: 4px 11px; border-radius: 999px; background: color-mix(in srgb, #3ddc97 16%, transparent); color: #3ddc97; font-size: 11px; font-weight: 800; letter-spacing: .5px; border: 0; }
.poll-state.closed { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--muted); }
.poll-options { display: grid; gap: 9px; }
.poll-choice { min-height: 52px; padding: 0 18px; border: 0; border-radius: 16px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 600; text-align: left; cursor: pointer; transition: transform .2s var(--pm-ease), box-shadow .2s, background .2s; }
.poll-choice:hover:not(:disabled) { transform: translateX(3px); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 70%, transparent); background: color-mix(in srgb, var(--purple) 12%, var(--pm-raise)); }
.poll-result { display: grid; gap: 7px; padding: 12px 16px; border-radius: 16px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.poll-result.mine { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 70%, transparent); }
.poll-result-label { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; }
.poll-result-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.poll-bar { height: 7px; border-radius: 7px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.poll-bar i, .poll-bar > span { display: block; height: 100%; border-radius: 7px; background: var(--pm-grad) !important; box-shadow: none; transition: width .8s var(--pm-ease); }
.poll-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* ---------- members ---------- */
.member-discovery-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 18px; }
.member-discovery-head h2 { margin: 4px 0 6px; font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.member-discovery-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 46ch; }
.eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--muted-2); }
.member-count { padding: 7px 14px; border-radius: 999px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.member-discovery-tools { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; }
.member-search { position: relative; flex: 1; display: block; }
.member-search > span { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.member-search input { padding-left: 42px; border-radius: 999px; }
.member-online-filter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }
.member-list { display: grid; gap: 10px; }
.member-profile-card, .member { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 0; border-radius: 22px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair); transition: transform .2s var(--pm-ease), box-shadow .2s; animation: pm-rise .35s var(--pm-ease) both; }
.member-profile-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--pm-hair-2), 0 14px 34px rgba(0,0,0,.25); }
.member-avatar-wrap { position: relative; flex: none; }
.member-presence { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--bg-2); background: var(--muted-2); }
.member-presence.is-online { background: #3ddc97; }

/* ---------- stories ---------- */
.story-compose { padding: 22px; margin-bottom: 18px; display: grid; gap: 14px; }
.story-compose-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.story-expiry { padding: 4px 11px; border-radius: 999px; background: color-mix(in srgb, var(--purple) 20%, transparent); font-size: 11px; font-weight: 800; letter-spacing: .6px; }
.story-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.story-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.story-card { overflow: hidden; border: 0; border-radius: 24px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair), 0 14px 40px rgba(0,0,0,.2); }
.story-reaction { min-width: 40px; height: 36px; border: 0; border-radius: 999px; background: var(--pm-raise); box-shadow: inset 0 0 0 1px var(--pm-hair); cursor: pointer; transition: transform .2s var(--pm-ease); }
.story-reaction:hover { transform: scale(1.12); }
.story-reaction.selected { background: color-mix(in srgb, var(--purple) 28%, var(--pm-raise)); }

/* ---------- vault ---------- */
.vault-intro { display: flex; gap: 18px; padding: 24px; margin-bottom: 16px; }
.vault-intro-icon { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: 18px; background: var(--pm-grad); font-size: 26px; }
.vault-guide, .vault-note { padding: 16px 18px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.panel { padding: 20px; margin-bottom: 14px; }

/* ---------- administration ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 18px 20px; border-bottom: 0 !important; }
.stat-card b, .stat-card .n { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin: 12px 0; border-radius: 18px; }
.rows { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; border-radius: 18px; background: var(--pm-panel); box-shadow: inset 0 0 0 1px var(--pm-hair); }
.row.sel { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--purple) 75%, transparent); background: color-mix(in srgb, var(--purple) 12%, var(--pm-panel)); }
.mod-toggle { accent-color: var(--purple); }
.btn.danger.small { box-shadow: inset 0 0 0 1px rgba(255,77,109,.4); }
@media (max-width: 760px) { .poll-option-inputs { grid-template-columns: 1fr; } .member-discovery-tools { flex-direction: column; align-items: stretch; } .member-discovery-head h2 { font-size: 26px; } .poll-create, .poll-card, .story-compose { padding: 18px; } }
.topbar .brand-mobile b { display: none; }
.member-profile-copy { min-width: 0; display: grid; gap: 2px; }
.member-profile-copy b { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.member-role { padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--purple) 24%, transparent); font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; }
.member-profile-copy small { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.member-card-actions { display: flex; align-items: center; gap: 8px; flex: none; }
@media (max-width: 760px) {
  .member-profile-card { flex-wrap: wrap; }
  .member-profile-copy { flex: 1 1 calc(100% - 80px); }
  .member-card-actions { width: 100%; justify-content: flex-end; }
}
.pill { border: 0 !important; border-radius: 999px; background: var(--pm-raise) !important; box-shadow: inset 0 0 0 1px var(--pm-hair); }

/* A more deliberate encrypted-vault entry experience. */
.vault-intro { position:relative; overflow:hidden; align-items:center; padding:clamp(22px,4vw,34px); border-radius:26px !important; background:radial-gradient(ellipse at 100% 0%,color-mix(in srgb,var(--purple) 20%,transparent),transparent 56%),linear-gradient(135deg,color-mix(in srgb,var(--card-2) 94%,transparent),color-mix(in srgb,var(--card) 94%,transparent)) !important; }
.vault-intro::after { content:""; position:absolute; width:180px; height:180px; right:-64px; bottom:-112px; border:1px solid color-mix(in srgb,var(--cyan) 30%,transparent); border-radius:50%; box-shadow:0 0 0 18px color-mix(in srgb,var(--cyan) 5%,transparent),0 0 0 38px color-mix(in srgb,var(--purple) 5%,transparent); pointer-events:none; }
.vault-intro-icon { width:68px; height:68px; border-radius:21px; color:var(--ink); background:linear-gradient(145deg,color-mix(in srgb,var(--purple) 30%,var(--card)),color-mix(in srgb,var(--cyan) 15%,var(--card))) !important; box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--purple) 32%,transparent),0 12px 30px rgba(0,0,0,.2); }
.vault-intro-icon svg { width:39px; height:39px; filter:drop-shadow(0 0 9px color-mix(in srgb,var(--cyan) 40%,transparent)); }
.vault-intro h2 { font-size:clamp(24px,4vw,32px); letter-spacing:-1.2px; }
.vault-intro .eyebrow { color:var(--cyan); }
.vault-entry-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:14px 0; padding:12px 14px; border-radius:16px; background:color-mix(in srgb,var(--bg) 50%,transparent); box-shadow:inset 0 0 0 1px var(--pm-hair); }
.vault-lock-state { margin-left:auto; color:var(--muted); font-size:12px; font-weight:700; }
.vault-guide article { border:0 !important; background:color-mix(in srgb,var(--bg) 40%,transparent) !important; box-shadow:inset 0 0 0 1px var(--pm-hair); }
.vault-guide-icon,.vault-file-icon,.vault-empty-icon { display:grid; place-items:center; color:var(--cyan); }
.vault-guide-icon { width:40px; height:40px; border-radius:13px; background:color-mix(in srgb,var(--purple) 13%,var(--card)); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--purple) 17%,transparent); }
.vault-guide-icon svg,.vault-file-icon svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.vault-file-row { display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); }
.vault-file-icon { flex:none; width:42px; height:42px; border-radius:14px; background:color-mix(in srgb,var(--cyan) 9%,var(--card)); }
.vault-file-name { flex:1; min-width:0; overflow-wrap:anywhere; font-weight:650; }
.vault-file-name small { display:block; margin-top:3px; font-size:11px; font-weight:500; }
.vault-empty { display:grid; justify-items:center; text-align:center; gap:8px; padding:30px 18px; border-radius:20px; background:color-mix(in srgb,var(--bg) 36%,transparent); box-shadow:inset 0 0 0 1px var(--pm-hair); }
.vault-empty-icon { width:62px; height:62px; border-radius:20px; color:var(--purple); background:color-mix(in srgb,var(--purple) 13%,var(--card)); }
.vault-empty-icon svg { width:38px; height:38px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.vault-empty p { max-width:42ch; margin:0; color:var(--muted); font-size:13px; }
.vault-shell { border-radius:28px !important; padding:clamp(16px,3vw,28px) !important; }
.vault-entry-card { display:grid; gap:12px; margin:16px 0 18px; padding:20px; border-radius:22px; background:linear-gradient(140deg,color-mix(in srgb,var(--purple) 10%,var(--card)),color-mix(in srgb,var(--cyan) 5%,var(--card))); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--purple) 20%,transparent),0 14px 32px rgba(0,0,0,.14); }
.vault-entry-card .field { gap:8px; }
.vault-entry-card .field > span { color:var(--ink); font-size:14px; letter-spacing:0; text-transform:none; }
.vault-entry-card .field small { color:var(--muted); font-size:12px; }
.vault-entry-card input { min-height:50px; border-radius:14px; border:1px solid color-mix(in srgb,var(--purple) 32%,var(--line)); background:color-mix(in srgb,var(--bg) 75%,transparent); padding:0 15px; }
.vault-pass-control { display:flex; align-items:center; gap:8px; }
.vault-pass-control input { flex:1; min-width:0; }
.vault-pass-control .btn { min-height:44px; }
.vault-entry-actions { margin:0; padding:0; background:none; box-shadow:none; }
.vault-entry-actions #vault-unlock { min-height:48px; padding-inline:24px; font-weight:800; }
.vault-lock-state { padding:8px 11px; border-radius:999px; background:color-mix(in srgb,var(--bg) 48%,transparent); }
.vault-status { padding:11px 13px; border-radius:13px; color:var(--muted); font-size:13px; background:color-mix(in srgb,var(--bg) 38%,transparent); }
.vault-load-error { max-width:600px; margin:30px auto; padding:24px; border-radius:24px; }
@media(max-width:560px){.vault-entry-card{padding:15px}.vault-entry-actions #vault-unlock{flex:1}.vault-entry-actions{gap:8px}}
@media(max-width:560px){.vault-intro-icon{width:50px;height:50px;flex-basis:50px;border-radius:16px}.vault-intro-icon svg{width:31px;height:31px}.vault-lock-state{width:100%;margin:0 2px 2px}}

/* ---------- premium finish: quieter surfaces, clearer hierarchy ---------- */
:root {
  --bg: #0b0715;
  --bg-2: #120d22;
  --card: #17122c;
  --card-2: #221a3f;
  --ink: #f4eeff;
  --muted: #b0a4d1;
  --muted-2: #8275a8;
  --line: #392b61;
  --lime: #c8ff3d;
  --pink: #ff5fa8;
  --cyan: #4de3ff;
  --orange: #ffa63d;
  --purple: #8a7dff;
  --pm-grad: linear-gradient(135deg, #9b97ef, #7fc9ce);
  --pm-ease: cubic-bezier(.2,.75,.25,1);
}
.blobs {
  opacity: .72;
  background: radial-gradient(650px 520px at 0% 0%, rgba(255,95,168,.18), transparent 68%),
    radial-gradient(700px 600px at 100% 8%, rgba(77,227,255,.14), transparent 68%),
    radial-gradient(720px 680px at 50% 110%, rgba(138,125,255,.14), transparent 70%);
  animation: none;
}
.sidebar, .topbar, .tabbar { border-color: var(--line); }
.sidebar { background: color-mix(in srgb, var(--card) 88%, transparent); }
.topbar, .tabbar { background: color-mix(in srgb, var(--bg) 90%, transparent); }
.brand { transform: none; }
.brand .box, .topbar .brand-mobile .box { background: var(--pm-grad); border: 0; box-shadow: none; color: #10131d; }
.nav-btn { border-width: 1px; }
.nav-btn.on { background: rgba(169,163,255,.1); border-color: rgba(169,163,255,.2); }
.icon-btn, .me-card { border-width: 1px; }
.icon-btn:hover { border-color: rgba(169,163,255,.55); }
.rail-card, .poll-create, .poll-card, .story-compose, .panel, .stat-card, .bulk-bar, .vault-intro, .vault-note, .vault-guide,
.member-profile-card, .member, .story-card, .row {
  box-shadow: inset 0 0 0 1px rgba(205,213,237,.075), 0 16px 42px rgba(0,0,0,.16);
}
.hero-card { border-radius: 26px; }
.tile { border-radius: 19px; }
.tile .thumb { border-radius: 18px 18px 0 0; }
.btn { transition: transform .18s var(--pm-ease), filter .18s, box-shadow .18s; }
.btn:hover { filter: brightness(1.08); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ================================================================
   Sign in / create account
   One self-contained layer (.au*). Uses the theme tokens, so all four
   themes work. No legacy .auth-* rules remain.
   ================================================================ */
body:has(.au) { --au-grad: linear-gradient(135deg, color-mix(in srgb, var(--purple) 70%, #0c0920), color-mix(in srgb, var(--pink) 58%, #0c0920)); }
body:has(.au) .blobs {
  animation: none;
  background:
    radial-gradient(900px 520px at 50% -10%, color-mix(in srgb, var(--purple) 24%, transparent), transparent 70%),
    radial-gradient(700px 480px at 105% 112%, color-mix(in srgb, var(--pink) 11%, transparent), transparent 70%);
}
body:has(.au) .blobs::after {
  content: ""; position: absolute; inset: 0; opacity: .55;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 14%, transparent) 1px, transparent 1.3px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 62% 56% at 50% 40%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 62% 56% at 50% 40%, #000 0%, transparent 78%);
}
.au {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 100vh; min-height: 100dvh;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}
.au-stack { width: min(412px, 100%); display: grid; gap: 22px; justify-items: center; }
.au-brand { display: flex; align-items: center; gap: 11px; }
.au-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #fff;
  background: var(--au-grad);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--purple) 34%, transparent), inset 0 1px rgba(255,255,255,.22);
}
.au-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.au-word { font-size: 21px; font-weight: 650; letter-spacing: -.02em; }

.au-card {
  width: 100%; padding: 30px 28px 26px; border-radius: 22px;
  background: color-mix(in srgb, var(--card) 62%, transparent);
  box-shadow: inset 0 0 0 1px var(--pm-hair), inset 0 1px rgba(255,255,255,.04), 0 30px 80px rgba(0,0,0,.42);
  -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2);
  animation: au-rise .55s var(--pm-ease) both;
}
.auth-card-heading h1 { margin: 0 0 6px; font-size: 23px; font-weight: 650; letter-spacing: -.022em; line-height: 1.2; }
.auth-card-heading p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.au-slot.au-in { animation: au-fade .28s var(--pm-ease) both; }
.au-form { display: grid; gap: 16px; margin-top: 24px; }
.au-field { display: grid; gap: 7px; }
.au-field label { font-size: 13px; font-weight: 550; color: color-mix(in srgb, var(--ink) 84%, transparent); }
.au-field input {
  width: 100%; height: 46px; padding: 0 14px; border: 0; border-radius: 12px; outline: 0;
  background: color-mix(in srgb, var(--bg) 58%, transparent); color: var(--ink); font-size: 15px;
  box-shadow: inset 0 0 0 1px var(--pm-hair-2);
  transition: box-shadow .18s ease, background .18s ease;
}
.au-field input::placeholder { color: var(--muted-2); }
.au-field input:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 26%, transparent); }
.au-field input:focus {
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  box-shadow: inset 0 0 0 1px var(--purple), 0 0 0 4px color-mix(in srgb, var(--purple) 24%, transparent);
}
.au-field input[aria-invalid="true"] {
  box-shadow: inset 0 0 0 1px var(--pink), 0 0 0 4px color-mix(in srgb, var(--pink) 18%, transparent);
}
.au-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  -webkit-box-shadow: inset 0 0 0 1px var(--pm-hair-2), inset 0 0 0 100px color-mix(in srgb, var(--bg) 80%, var(--card));
}
.au-pw { position: relative; }
.au-pw input { padding-right: 48px; }
.au-eye {
  position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s;
}
.au-eye:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.au-eye:focus-visible { outline: 2px solid var(--purple); outline-offset: -2px; }
.au-eye svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.au-help, .au-caps { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.au-caps { color: var(--orange); }
.au-strength { display: grid; gap: 8px; margin-top: -4px; }
.au-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.au-meter i { height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 12%, transparent); transition: background .25s ease; }
.au-meter[data-level="1"] i:nth-child(-n+1) { background: var(--pink); }
.au-meter[data-level="2"] i:nth-child(-n+2) { background: var(--orange); }
.au-meter[data-level="3"] i:nth-child(-n+3) { background: var(--cyan); }
.au-meter[data-level="4"] i { background: var(--lime); }

.au-err {
  display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 10px 12px; border-radius: 11px;
  font-size: 13px; line-height: 1.4; color: color-mix(in srgb, var(--pink) 50%, var(--ink));
  background: color-mix(in srgb, var(--pink) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pink) 28%, transparent);
}
.au-err:empty { display: none; }
.au-err svg { flex: none; width: 17px; height: 17px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.au-submit {
  display: grid; place-items: center; height: 48px; margin-top: 2px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--au-grad); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: -.005em; cursor: pointer;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--purple) 26%, transparent), inset 0 1px rgba(255,255,255,.22);
  transition: transform .16s var(--pm-ease), filter .16s ease, box-shadow .2s ease;
}
.au-submit:hover { filter: brightness(1.09); transform: translateY(-1px); }
.au-submit:active { transform: translateY(0) scale(.992); }
.au-submit:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.au-submit:disabled { cursor: progress; filter: none; transform: none; opacity: .86; }
.au-spin { display: inline-block; width: 15px; height: 15px; margin-right: 9px; vertical-align: -3px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: au-spin .7s linear infinite; }

.au-switch { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--pm-hair); text-align: center; font-size: 14px; color: var(--muted); }
.au-link { margin-left: 4px; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ink) 30%, transparent); text-underline-offset: 3px; }
.au-link:hover { text-decoration-color: currentColor; }
.au-link:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 4px; }
.auth-access-note { max-width: 340px; margin: 0; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }
.auth-access-note:empty { display: none; }
.au-host {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 12px; border-radius: 999px;
  font: 500 12px/1 var(--mono); color: var(--muted);
  background: color-mix(in srgb, var(--card) 50%, transparent); box-shadow: inset 0 0 0 1px var(--pm-hair);
}
.au-host span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-host svg { flex: none; width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.au-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 20%, transparent); }

.au-card.au-shake { animation: au-shake .38s var(--pm-ease); }
@keyframes au-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes au-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes au-spin { to { transform: rotate(360deg); } }
@keyframes au-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  .au-card, .au-slot.au-in, .au-card.au-shake { animation: none; }
  .au-spin { animation-duration: 1.6s; }
}
/* Phones: drop the card chrome, let the form sit directly on the page. */
@media (max-width: 520px) {
  .au { align-items: flex-start; padding-top: max(52px, calc(env(safe-area-inset-top) + 32px)); }
  .au-stack { gap: 26px; }
  .au-card { padding: 4px 0 0; border-radius: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .au-field input { height: 50px; font-size: 16px; }
  .au-submit { height: 52px; }
  .au-host { order: 3; }
}
.au ::selection { background: color-mix(in srgb, var(--purple) 48%, transparent); color: var(--ink); }

/* Invitation management */
.invite-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 190px) auto;
  align-items: end;
  gap: 12px;
  margin: 16px 0;
}
.invite-create-form .field { min-width: 0; }
.invite-create-form input,
.invite-create-form select,
.invite-code-row input {
  width: 100%;
  min-width: 0;
}
.invite-created {
  padding: 12px;
  margin: 12px 0;
  border: 1px solid var(--line, rgba(255,255,255,.12));
  border-radius: 12px;
  background: var(--panel, rgba(255,255,255,.035));
}
.invite-created p { margin: 0 0 10px; }
.invite-code-row { display: flex; gap: 8px; align-items: center; }
.invite-code-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; font-weight: 700; }
.invite-member { gap: 12px; }
@media (max-width: 680px) {
  .invite-create-form { grid-template-columns: 1fr; }
  .invite-create-form .btn { width: 100%; }
  .invite-code-row { align-items: stretch; flex-direction: column; }
}
.au-remember{display:flex;align-items:center;gap:9px;margin:2px 0 12px;color:var(--muted,#7b8794);font-size:13px;line-height:1.4}.au-remember input{width:16px;height:16px;accent-color:var(--accent,#6c8cff)}
