:root {
  --bg: #fff; --fg: #0a0a0a; --muted: #6b6b6b; --line: #e3e3e3; --card: #fafafa; --radius: 14px;
}
[data-theme="dark"] {
  --bg: #000; --fg: #f4f4f4; --muted: #9b9b9b; --line: #262626; --card: #0d0d0d;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
h2 { margin: 18px 0 12px; font-size: 22px; letter-spacing: -.02em; }
h3 { margin: 0 0 8px; font-size: 16px; }
.splash { text-align: center; margin-top: 30vh; font-weight: 800; font-size: 28px; letter-spacing: -.04em; }
.dim { color: var(--muted); font-size: 13px; }
.empty, .note { color: var(--muted); text-align: center; padding: 28px 8px; }
.note { padding: 10px 0; text-align: left; font-size: 14px; }

/* header + nav */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.04em; margin-right: auto; }
.brand span, .logo span { opacity: .5; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.nav a.on { background: var(--fg); color: var(--bg); }
.badge { background: var(--fg); color: var(--bg); border-radius: 999px; font-size: 11px; padding: 0 6px; }
.nav a.on .badge { background: var(--bg); color: var(--fg); }
.banner { background: var(--fg); color: var(--bg); text-align: center; font-size: 13px; padding: 8px 12px; }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 110px; }

/* buttons + inputs */
.btn, .icon, .chip, .act {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; font-size: 14px; display: inline-block; text-align: center;
}
.btn:hover, .icon:hover, .chip:hover, .act:hover { border-color: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.big { padding: 14px 22px; font-size: 16px; width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon { padding: 6px 11px; font-size: 16px; line-height: 1; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--fg); }
textarea { resize: vertical; min-height: 84px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }

/* cards */
.card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.post { cursor: pointer; }
.post:hover { border-color: var(--fg); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.who { display: inline-flex; align-items: center; gap: 8px; }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--fg); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.av.lg { width: 72px; height: 72px; font-size: 30px; }
.tag { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border: 1px solid var(--fg); border-radius: 999px; padding: 2px 9px; }
.text { white-space: pre-wrap; word-break: break-word; margin: 12px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.act { padding: 5px 13px; font-size: 13px; }
.act.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chip { padding: 6px 14px; white-space: nowrap; }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.composer .row2 { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.composer select { width: auto; }
.composer .count { margin-left: auto; }
.back { display: inline-block; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .btns { margin-left: auto; display: flex; gap: 6px; }
.profile-head { text-align: center; padding: 10px 0 4px; }
.profile-head h2 { margin: 10px 0 2px; }
.profile-head .btns { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* chat */
.msgs { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; background: var(--card); }
.bub { max-width: 80%; padding: 8px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); align-self: flex-start; word-break: break-word; }
.bub.me { align-self: flex-end; background: var(--fg); color: var(--bg); border-color: var(--fg); }
.bub small { display: block; opacity: .55; font-size: 10px; margin-top: 2px; }
.mform { display: flex; gap: 8px; margin-top: 10px; }

/* login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; }
.login .corner { position: absolute; top: 16px; right: 16px; }
.hero { max-width: 380px; width: 100%; text-align: center; }
.logo { font-size: 52px; font-weight: 800; letter-spacing: -.05em; margin: 0; }
.hero .sub { color: var(--muted); margin: 8px 0 28px; }
.hero .btn { margin-bottom: 10px; }
.rules { text-align: left; color: var(--muted); font-size: 13px; padding-left: 18px; margin-top: 22px; }
.demo { margin-top: 18px; font-size: 12px; border: 1px dashed var(--muted); border-radius: 10px; padding: 8px 10px; color: var(--muted); }
.formwrap { max-width: 420px; margin: 0 auto; padding: 40px 20px; }

/* toast */
#toast { position: fixed; left: 0; right: 0; bottom: 84px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; display: flex; gap: 12px; align-items: center; max-width: 92vw; }
.toast button { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* mobile: nav at the bottom */
@media (max-width: 640px) {
  .nav { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); z-index: 20; }
  #toast { bottom: 90px; }
}

/* media in posts */
.pimg { display: block; width: 100%; max-height: 460px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); margin: 4px 0 12px; }
.paud { display: block; width: 100%; margin: 2px 0 12px; }
.composer .row2 { flex-wrap: wrap; }
.composer .row2 + .row2 { margin-top: 10px; }
.pv { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; }
.pv img { max-height: 160px; max-width: calc(100% - 40px); border-radius: 10px; border: 1px solid var(--line); }
.pv audio { flex: 1; min-width: 0; }
.pv .x { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 50%; width: 28px; height: 28px; flex: none; }
.pv .x:hover { border-color: var(--fg); }
.banner + .banner { border-top: 1px solid var(--bg); }

/* login tabs, setup */
.tabs { display: flex; gap: 6px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tabs button { flex: 1; font: inherit; font-weight: 600; font-size: 14px; border: 0; background: none; color: var(--muted); padding: 8px 0; border-radius: 999px; cursor: pointer; }
.tabs button.on { background: var(--fg); color: var(--bg); }
.linkbtn { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.notlive { border: 2px solid var(--fg); border-radius: 12px; padding: 12px; margin: 0 0 16px; font-size: 14px; text-align: left; }
.notlive a { text-decoration: underline; font-weight: 700; }
.setup { max-width: 560px; }
.steps { padding-left: 20px; line-height: 1.6; }
.steps li { margin: 14px 0; }
.steps a { text-decoration: underline; }
.steps code { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.steps textarea { margin-top: 8px; min-height: 130px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
#recaptcha { margin-top: 8px; }

/* ---------- v3: blue tick, inbox, chat media, admin ---------- */
.vt { display: inline-flex; vertical-align: -3px; margin-left: 4px; }
.vt:empty { display: none; }
.vt svg { width: 15px; height: 15px; }
h2 .vt svg { width: 20px; height: 20px; }
.stat { display: inline-block; margin-top: 6px; font-size: 14px; color: var(--muted); }
.stat b { color: var(--fg); font-size: 16px; }
.uid { display: block; margin-top: 6px; font-size: 12px; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; user-select: all; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }

/* tabs as links (inbox) */
.tabs a { flex: 1; text-align: center; font-weight: 600; font-size: 14px; color: var(--muted); padding: 8px 0; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.tabs a.on { background: var(--fg); color: var(--bg); }
.tabs a .badge[hidden] { display: none; }
.tabs a.on .badge { background: var(--bg); color: var(--fg); }

/* inbox lists */
.convs { padding: 4px 0; }
.conv { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.conv:last-child { border-bottom: 0; }
.conv:hover { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.cbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cname { display: flex; align-items: center; gap: 4px; }
.cname .ctime { margin-left: auto; padding-left: 8px; flex: none; }
.cprev { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .cprev { color: var(--fg); font-weight: 600; }
.pill { background: #1d9bf0; color: #fff; border-radius: 999px; font-size: 12px; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #1d9bf0; flex: none; }
.nic { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 700; }
.nrow.unread { background: color-mix(in srgb, #1d9bf0 8%, transparent); }
.reqbar { display: flex; justify-content: space-between; align-items: center; }
.alertcard { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.alertcard .dim { flex: 1; }

/* chat */
.chat-head { margin: 10px 0 8px; }
.chat-head h2 { margin: 0; font-size: 20px; }
.msgs { height: calc(100dvh - 330px); min-height: 260px; }
.bub { max-width: 82%; }
.bub.media { padding: 6px; }
.bub.media small { padding: 0 6px 2px; }
.mtext { white-space: pre-wrap; padding: 2px 6px; }
.bub:not(.media) .mtext { padding: 0; }
.mimg { display: block; max-width: 100%; max-height: 300px; border-radius: 12px; cursor: zoom-in; }
.maud { display: block; width: 240px; max-width: 100%; }
.loc { display: block; width: 240px; max-width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.loc iframe { display: block; width: 100%; height: 140px; border: 0; pointer-events: none; }
.locl { display: block; padding: 7px 10px; font-size: 12px; font-weight: 600; }
.tick { letter-spacing: -2px; }
.tick.seen { color: #4cc2ff; opacity: 1; }
.bub small { display: flex; justify-content: flex-end; gap: 4px; }
.seenlbl { align-self: flex-end; font-size: 11px; color: var(--muted); margin-top: -4px; }
.mform { align-items: center; }
.mform input { flex: 1; min-width: 0; border-radius: 999px; }
.mform[hidden], .rbar[hidden], .tray[hidden] { display: none; }
.plus { width: 40px; height: 40px; padding: 0; font-size: 22px; flex: none; }
.tray { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rbar { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; }
.rbar .btn:first-of-type { margin-left: auto; }
.rdot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
#cpv .pv { margin-top: 10px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }

/* me + admin */
.vcard { border-color: #1d9bf0; }
.vcard h3 { display: flex; align-items: center; gap: 4px; }
.agrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.agrid .tile { margin: 0; padding: 12px 14px; }
.tile b { font-size: 22px; letter-spacing: -.02em; }
.arow { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.arow:last-child { border-bottom: 0; }
.ainfo { display: flex; gap: 10px; align-items: center; }
.agrant { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.agrant select, .agrant input { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 999px; }
.agrant input { width: 80px; }
.tier { font-size: 12px; font-weight: 700; border: 1px solid #1d9bf0; color: #1d9bf0; border-radius: 999px; padding: 3px 10px; }
@media (min-width: 641px) { .arow { flex-direction: row; align-items: center; justify-content: space-between; } }
[data-theme="dark"] .tick.seen { color: #1478c8; }

/* ===== v4: avatars, usernames, profile form ===== */
.av { overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.un { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 4px; }
.un:empty { display: none; }
.nat { font-size: 14px; margin-top: 2px; }
.bio { margin: 6px auto 4px; max-width: 460px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.dprow { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.dprow .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.uwrap { display: flex; align-items: center; gap: 6px; }
.uwrap span { font-weight: 700; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; min-height: 16px; }
.hint.ok { color: #1a8f4a; }
.hint.bad { color: #d23a3a; }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

/* ===== feed: search, topics, visibility, trending, video ===== */
.search { margin: 4px 0 8px; border-radius: 999px; }
.chip small { opacity: .6; margin-left: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.tg { font: inherit; font-size: 13px; cursor: pointer; border: 0; background: none; color: #6d3dff; padding: 0 2px; font-weight: 600; }
.tg:hover { text-decoration: underline; }
.topicin { margin-top: 8px; font-size: 14px; }
.vis { font-size: 11px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.vsel { width: auto; padding-right: 22px; }
.pvid { display: block; width: 100%; max-height: 480px; background: #000; border-radius: 12px; margin: 4px 0 12px; }
.pv video { max-height: 160px; max-width: calc(100% - 40px); border-radius: 10px; background: #000; }
.hothead { margin: 6px 0 8px; font-size: 15px; }
.post.hot { border-color: #ff6a1a; box-shadow: 0 0 0 1px #ff6a1a33; }
.hotb { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(90deg, #ff6a1a, #ff2e63); border-radius: 999px; padding: 2px 10px; margin-bottom: 8px; }

/* ===== chat: reply, edit, delete ===== */
.bub { position: relative; }
.mdots { position: absolute; top: 2px; right: 4px; font: inherit; line-height: 1; border: 0; background: none; color: inherit; opacity: .45; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.mdots:hover { opacity: 1; }
.bub:not(.media):not(.gone) { padding-right: 26px; }
.bub.media .mdots { background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--fg); opacity: .8; }
.mmenu { position: absolute; z-index: 5; top: 24px; right: 4px; min-width: 130px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px #0003; overflow: hidden; }
.bub:not(.me) .mmenu { right: auto; left: 4px; }
.mmenu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 9px 12px; border: 0; background: none; color: inherit; cursor: pointer; }
.mmenu button:hover { background: var(--card); }
.rq { border-left: 3px solid #6d3dff; background: color-mix(in srgb, currentColor 10%, transparent); border-radius: 8px; padding: 4px 8px; margin: 0 0 6px; font-size: 12px; cursor: pointer; display: flex; flex-direction: column; max-width: 100%; }
.rq span { opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bub.gone { opacity: .6; font-style: italic; }
.bub.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px #6d3dff88; } 100% { box-shadow: none; } }
.ctxbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 10px; border: 1px solid var(--line); border-left: 3px solid #6d3dff; border-radius: 10px; font-size: 13px; background: var(--card); }
.ctxbar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctxbar[hidden] { display: none; }
.ctxbar .x { font: inherit; cursor: pointer; border: 0; background: none; color: var(--fg); font-size: 16px; }
[hidden] { display: none !important; }
