/* 星语 · styles */
:root {
  --bg: #ffffff;
  --bg2: #f4f4f5;
  --bg3: #e9e9eb;
  --chatbg: #e7ecf0;
  --rail: #f0f0f2;
  --text: #1c1c1e;
  --text2: #707579;
  --text3: #a2acb4;
  --line: #e6e6e8;
  --acc: #3390ec;
  --acc-dark: #2a7bd0;
  --acc-bg: rgba(51, 144, 236, 0.12);
  --out: #effdde;
  --in: #ffffff;
  --tick: #4fae4e;
  --danger: #e53935;
  --online: #4dcd5b;
  --hover: rgba(0, 0, 0, 0.045);
  --sep: rgba(0, 0, 0, 0.28);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  --shadow2: 0 6px 28px rgba(0, 0, 0, 0.2);
  --sel: var(--acc);
  --sel-text: #ffffff;
  --scroll: rgba(0, 0, 0, 0.18);
  --quote-bg: rgba(51, 144, 236, 0.1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --bg2: #181818; --bg3: #2c2c2c; --chatbg: #0f1620; --rail: #181818;
    --text: #f2f2f2; --text2: #a3a8ad; --text3: #6f767d; --line: #2f2f31;
    --acc: #5aa2ec; --acc-dark: #4a90d9; --acc-bg: rgba(90, 162, 236, 0.16);
    --out: #2b5278; --in: #1f2a36; --tick: #7ec1f5; --hover: rgba(255, 255, 255, 0.06);
    --sep: rgba(0, 0, 0, 0.45); --shadow: 0 1px 1px rgba(0, 0, 0, 0.4); --shadow2: 0 6px 28px rgba(0, 0, 0, 0.6);
    --scroll: rgba(255, 255, 255, 0.18); --quote-bg: rgba(255, 255, 255, 0.08);
  }
}
:root[data-theme="dark"] {
  --bg: #212121; --bg2: #181818; --bg3: #2c2c2c; --chatbg: #0f1620; --rail: #181818;
  --text: #f2f2f2; --text2: #a3a8ad; --text3: #6f767d; --line: #2f2f31;
  --acc: #5aa2ec; --acc-dark: #4a90d9; --acc-bg: rgba(90, 162, 236, 0.16);
  --out: #2b5278; --in: #1f2a36; --tick: #7ec1f5; --hover: rgba(255, 255, 255, 0.06);
  --sep: rgba(0, 0, 0, 0.45); --shadow: 0 1px 1px rgba(0, 0, 0, 0.4); --shadow2: 0 6px 28px rgba(0, 0, 0, 0.6);
  --scroll: rgba(255, 255, 255, 0.18); --quote-bg: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px; line-height: 1.4; color: var(--text); background: var(--bg);
  overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app { height: 100%; height: 100dvh; }
button { font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--acc); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
.ic { width: 22px; height: 22px; flex-shrink: 0; }
.hidden { display: none !important; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- avatars ---------- */
.av {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; font-size: 20px; user-select: none; background: var(--bg3); overflow: hidden;
}
.av .ic { width: 55%; height: 55%; }
.av.s { width: 42px; height: 42px; font-size: 16px; }
.av.xs { width: 34px; height: 34px; font-size: 13px; }
.av.m { width: 64px; height: 64px; font-size: 24px; }
.av.l { width: 96px; height: 96px; font-size: 36px; }
.av-c0 { background: #e17076; } .av-c1 { background: #faa774; } .av-c2 { background: #a695e7; }
.av-c3 { background: #7bc862; } .av-c4 { background: #6ec9cb; } .av-c5 { background: #65aadd; }
.av-c6 { background: #ee7aae; }
.avwrap { position: relative; flex-shrink: 0; }
.avwrap .dot {
  position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg);
}

/* ---------- auth ---------- */
.auth { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg2); padding: 16px; }
.acard { width: min(380px, 100%); background: var(--bg); border-radius: 16px; padding: 36px 28px 28px; box-shadow: 0 2px 16px rgba(0,0,0,.07); }
.alogo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; }
.alogo .mark { width: 76px; height: 76px; border-radius: 22px; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; }
.alogo .mark .ic { width: 42px; height: 42px; }
.alogo h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.alogo p { margin: 0; color: var(--text2); font-size: 14px; }
.atabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.atabs button { flex: 1; border: 0; background: none; padding: 10px; font-size: 15px; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.atabs button.on { color: var(--acc); border-bottom-color: var(--acc); font-weight: 600; }
.field { margin-bottom: 12px; }
.inp {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; font-size: 16px;
  background: var(--bg); color: var(--text); outline: 0; transition: border-color .15s;
}
.inp:focus { border-color: var(--acc); }
textarea.inp { resize: vertical; min-height: 72px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.btn {
  border: 0; background: var(--acc); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 15px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--acc-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--acc); }
.btn.ghost:hover { background: var(--acc-bg); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: rgba(229, 57, 53, .1); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.soft { background: var(--acc-bg); color: var(--acc); }
.btn.soft:hover { background: var(--acc-bg); opacity: .85; }

/* ---------- main layout ---------- */
#main { display: flex; height: 100%; }
#rail {
  width: 66px; background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; padding: 12px 0; gap: 4px; flex-shrink: 0;
}
#rail .me { margin-bottom: 10px; cursor: pointer; }
.rbtn {
  width: 50px; height: 50px; border-radius: 12px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: var(--text2); position: relative; cursor: pointer; border: 0; background: transparent;
  font-size: 10px;
}
.rbtn:hover { background: var(--hover); }
.rbtn.on { color: var(--acc); background: var(--acc-bg); }
.rbtn .ic { width: 26px; height: 26px; }
.rbtn .badge { position: absolute; top: 3px; right: 1px; }
#rail .spacer { flex: 1; }

#side { width: 380px; min-width: 300px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg); position: relative; flex-shrink: 0; }
@media (min-width: 901px) { #main.side-hidden #side { display: none; } }
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chatbg); position: relative; }
.pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pane.on { display: flex; }
.shead { height: 56px; display: flex; align-items: center; gap: 4px; padding: 0 8px 0 18px; flex-shrink: 0; }
.shead h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; }
.searchbox { margin: 0 12px 8px; background: var(--bg2); border-radius: 20px; display: flex; align-items: center; padding: 0 12px; height: 40px; gap: 8px; color: var(--text2); flex-shrink: 0; }
.searchbox .ic { width: 20px; height: 20px; }
.searchbox input { flex: 1; border: 0; background: transparent; outline: 0; font-size: 15px; color: var(--text); min-width: 0; }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.empty { padding: 40px 24px; text-align: center; color: var(--text2); font-size: 14px; }
.empty .ic { width: 48px; height: 48px; color: var(--text3); margin-bottom: 10px; }

.badge {
  background: var(--acc); color: #fff; font-size: 12px; min-width: 20px; height: 20px; border-radius: 10px;
  padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; line-height: 1;
}
.badge.gray { background: var(--text3); }
.badge.red { background: var(--danger); }

/* chat list */
.citem { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 12px; cursor: pointer; user-select: none; margin: 0 6px; border-radius: 12px; }
.citem:hover { background: var(--hover); }
.citem.sel { background: var(--sel); color: var(--sel-text); }
.citem .body { flex: 1; min-width: 0; }
.citem .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.citem .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; display: flex; align-items: center; gap: 4px; min-width: 0; }
.citem .name span { overflow: hidden; text-overflow: ellipsis; }
.citem .name .ic { width: 14px; height: 14px; color: var(--text3); flex-shrink: 0; }
.citem .time { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.citem .row2 { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; gap: 8px; }
.citem .prev { color: var(--text2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.citem .prev b { font-weight: 500; color: var(--text); }
.citem .prev.typing { color: var(--acc); }
.citem.sel .time, .citem.sel .prev, .citem.sel .prev b, .citem.sel .prev.typing, .citem.sel .name .ic { color: var(--sel-text); }
.citem.sel .badge { background: #fff; color: var(--acc); }
.citem.sel .avwrap .dot { border-color: var(--sel); }

/* contact rows */
.sect { padding: 14px 18px 6px; font-size: 12.5px; color: var(--text2); font-weight: 600; letter-spacing: .3px; }
.crow { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin: 0 6px; border-radius: 12px; cursor: pointer; user-select: none; }
.crow:hover { background: var(--hover); }
.crow.sel { background: var(--sel); color: var(--sel-text); }
.crow .body { flex: 1; min-width: 0; }
.crow .name { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .sub { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow.sel .sub { color: var(--sel-text); opacity: .85; }
.crow .icbox { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.crow .icbox.orange { background: #faa774; } .crow .icbox.green { background: #7bc862; } .crow .icbox.blue { background: #65aadd; }
.crow .right { display: flex; align-items: center; gap: 8px; }
.crow .chev { color: var(--text3); width: 18px; height: 18px; }

/* tab bar (mobile) */
#tabbar { display: none; height: calc(54px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
#tabbar button { flex: 1; border: 0; background: transparent; color: var(--text2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; position: relative; cursor: pointer; }
#tabbar button.on { color: var(--acc); }
#tabbar button .ic { width: 26px; height: 26px; }
#tabbar button .badge { position: absolute; top: 4px; left: calc(50% + 6px); }

/* offline banner */
.offline { background: #f5b53f; color: #1c1c1e; font-size: 13px; text-align: center; padding: 5px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.offline .ic { width: 16px; height: 16px; }

/* ---------- chat view ---------- */
.chead { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chead .tbody { flex: 1; min-width: 0; cursor: pointer; }
.chead .title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead .sub { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead .sub.online, .chead .sub.typing { color: var(--acc); }
.ibtn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--text2); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0; }
.ibtn:hover { background: var(--hover); color: var(--text); }
.ibtn.on { color: var(--acc); }
.ibtn .ic { width: 24px; height: 24px; }
.ibtn.backbtn { display: none; }

.msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 6px; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msgs .inner { max-width: 860px; width: 100%; margin: auto auto 0; display: flex; flex-direction: column; gap: 3px; }
.loadmore { text-align: center; color: var(--text2); font-size: 12px; padding: 8px; }
.daysep, .sysmsg { align-self: center; background: var(--sep); color: #fff; font-size: 12.5px; padding: 3px 10px; border-radius: 12px; margin: 6px 0; font-weight: 500; text-align: center; max-width: 80%; }
.sysmsg { font-weight: 400; }
.m { display: flex; align-items: flex-end; gap: 8px; max-width: 80%; position: relative; }
.m.out { align-self: flex-end; flex-direction: row-reverse; }
.m.in { align-self: flex-start; }
.m + .m.same { margin-top: -1px; }
.m .avslot { width: 34px; flex-shrink: 0; align-self: flex-end; }
.m .avslot .av { cursor: pointer; }
.bub {
  background: var(--in); border-radius: 12px; padding: 6px 10px 6px 10px; position: relative; box-shadow: var(--shadow);
  min-width: 56px; max-width: 100%; word-break: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.4;
}
.m.in .bub { border-bottom-left-radius: 4px; }
.m.out .bub { background: var(--out); border-bottom-right-radius: 4px; }
.m.same.in .bub { border-top-left-radius: 6px; }
.m.same.out .bub { border-top-right-radius: 6px; }
.bub .txt { white-space: pre-wrap; }
.bub .txt a { word-break: break-all; }
.bub .sender { font-weight: 600; font-size: 13.5px; color: var(--acc); margin-bottom: 1px; display: block; cursor: pointer; }
.bub .meta { float: right; font-size: 11.5px; color: var(--text2); margin: 8px -2px -4px 10px; display: inline-flex; align-items: center; gap: 2px; line-height: 1; position: relative; top: 1px; white-space: nowrap; }
.bub .meta .ic { width: 16px; height: 16px; color: var(--tick); }
.bub .meta .ic.pend { color: var(--text3); }
.m.failed .bub { outline: 1.5px solid var(--danger); cursor: pointer; }
.m.failed .meta { color: var(--danger); }
.bub.del { color: var(--text2); font-style: italic; }
.bub .quote { border-left: 3px solid var(--acc); background: var(--quote-bg); padding: 4px 8px; border-radius: 6px; margin: 2px 0 5px; font-size: 13.5px; cursor: pointer; line-height: 1.3; }
.bub .quote .qn { color: var(--acc); font-weight: 600; font-size: 12.5px; }
.bub .quote .qt { color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.bub .fwd { font-size: 12.5px; color: var(--acc); font-weight: 600; margin-bottom: 2px; }
.bub.pic { padding: 3px; background: var(--in); }
.m.out .bub.pic { background: var(--out); }
.bub.pic .pic { display: block; max-width: min(100%, 340px); max-height: 380px; border-radius: 9px; cursor: pointer; background: var(--bg3); object-fit: cover; }
.bub.pic .meta { position: absolute; top: auto; right: 8px; bottom: 8px; margin: 0; float: none; background: rgba(0,0,0,.45); color: #fff; border-radius: 10px; padding: 3px 7px; }
.bub.pic .meta .ic { color: #fff; }
.bub.pic .sender, .bub.pic .quote, .bub.pic .fwd { margin-left: 6px; margin-right: 6px; }
.bub.pic .sender { margin-top: 3px; }
.bub.pic video { display: block; max-width: min(100%, 340px); max-height: 380px; border-radius: 9px; background: #000; }
.fileb { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 4px 2px; text-decoration: none; color: inherit; }
.fileb .fi { width: 44px; height: 44px; border-radius: 50%; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fileb .fi .ic { width: 22px; height: 22px; }
.fileb .fn { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.fileb .fs { font-size: 12.5px; color: var(--text2); }
.voice { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 4px 2px; }
.voice .pb { width: 40px; height: 40px; border-radius: 50%; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; border: 0; }
.voice .pb .ic { width: 20px; height: 20px; }
.voice .wave { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.voice .bar { height: 5px; background: rgba(0,0,0,.14); border-radius: 3px; position: relative; cursor: pointer; }
.voice .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--acc); border-radius: 3px; width: 0; transition: width .2s linear; }
.voice .dur { font-size: 12px; color: var(--text2); }
.m.out .voice .bar { background: rgba(0,0,0,.1); }
.uploading { position: absolute; inset: 3px; background: rgba(0,0,0,.35); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 600; }

.jump { position: absolute; right: 16px; bottom: 84px; width: 44px; height: 44px; border-radius: 50%; background: var(--bg); color: var(--text2); border: 0; box-shadow: var(--shadow2); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5; }
.jump .badge { position: absolute; top: -6px; right: -4px; }
.jump .ic { width: 24px; height: 24px; }

.composer { flex-shrink: 0; padding: 6px 12px calc(8px + env(safe-area-inset-bottom)); position: relative; }
.composer .box { max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.composer .fieldbox { flex: 1; min-width: 0; background: var(--bg); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.composer .frow { display: flex; align-items: flex-end; padding: 4px 6px; min-height: 46px; }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; resize: none; font: inherit; font-size: 16px; line-height: 22px; max-height: 150px; padding: 8px 4px; color: var(--text); }
.composer textarea::placeholder { color: var(--text3); }
.sendbtn { width: 46px; height: 46px; border-radius: 50%; background: var(--acc); color: #fff; border: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; box-shadow: var(--shadow); }
.sendbtn:active { transform: scale(.94); }
.sendbtn .ic { width: 22px; height: 22px; margin-left: 2px; }
.sendbtn.mic .ic { margin-left: 0; }
.sendbtn.rec { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,.5); } 70% { box-shadow: 0 0 0 12px rgba(229,57,53,0); } }
.replybar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 0 14px; font-size: 13px; }
.replybar .rl { flex: 1; min-width: 0; border-left: 3px solid var(--acc); padding-left: 8px; }
.replybar .rl b { color: var(--acc); display: block; font-size: 12.5px; }
.replybar .rl span { color: var(--text2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replybar .ibtn { width: 32px; height: 32px; }
.recbar { display: flex; align-items: center; gap: 12px; padding: 0 8px 0 16px; min-height: 46px; }
.recbar .rdot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.recbar .rt { font-variant-numeric: tabular-nums; font-weight: 600; flex: 1; }
.emojipop { position: absolute; bottom: 100%; left: 12px; width: 340px; max-width: calc(100vw - 24px); height: 280px; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow2); display: grid; grid-template-columns: repeat(8, 1fr); align-content: start; overflow-y: auto; padding: 8px; margin-bottom: 6px; z-index: 20; }
.emojipop button { font-size: 24px; border: 0; background: none; height: 40px; cursor: pointer; border-radius: 8px; line-height: 1; padding: 0; }
.emojipop button:hover { background: var(--hover); }

.emptychat { flex: 1; display: flex; align-items: center; justify-content: center; }
.emptychat span { background: var(--sep); color: #fff; padding: 6px 14px; border-radius: 14px; font-size: 14px; }

/* ---------- info / profile views ---------- */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg2); }
.view .scroll { flex: 1; overflow-y: auto; padding-bottom: 32px; }
.pcard { background: var(--bg); padding: 26px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pcard .avbtn { position: relative; cursor: pointer; }
.pcard .avbtn .cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.pcard .avbtn .cam .ic { width: 15px; height: 15px; }
.pcard h2 { margin: 6px 0 0; font-size: 20px; font-weight: 600; word-break: break-word; }
.pcard .un { color: var(--text2); font-size: 14px; }
.pcard .bio { color: var(--text); font-size: 14px; max-width: 420px; white-space: pre-wrap; word-break: break-word; }
.pcard .st { font-size: 13px; color: var(--text2); }
.pcard .st.online { color: var(--acc); }
.pcard .actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.group { background: var(--bg); margin: 12px 12px 0; border-radius: 12px; overflow: hidden; }
.sitem { display: flex; align-items: center; gap: 14px; padding: 12px 16px; cursor: pointer; user-select: none; min-height: 50px; }
.sitem:hover { background: var(--hover); }
.sitem + .sitem { border-top: 1px solid var(--line); }
.sitem .ic { color: var(--text2); width: 22px; height: 22px; }
.sitem .lbl { flex: 1; min-width: 0; }
.sitem .lbl small { display: block; color: var(--text2); font-size: 12.5px; }
.sitem .val { color: var(--text2); font-size: 14px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitem .chev { color: var(--text3); width: 18px; height: 18px; }
.sitem.danger, .sitem.danger .ic { color: var(--danger); }
.sitem.static { cursor: default; }
.sitem.static:hover { background: none; }
.toggle { width: 44px; height: 26px; border-radius: 13px; background: var(--bg3); position: relative; flex-shrink: 0; transition: background .2s; border: 0; padding: 0; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on { background: var(--acc); }
.toggle.on::after { left: 21px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 14px 6px; padding: 14px 16px; }
.mcell { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); cursor: pointer; position: relative; }
.mcell span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcell .av.s { width: 48px; height: 48px; }
.mcell .add { width: 48px; height: 48px; border-radius: 50%; border: 1.5px dashed var(--text3); display: flex; align-items: center; justify-content: center; color: var(--text2); }
.mcell .rm { position: absolute; top: -4px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.mcell .rm .ic { width: 12px; height: 12px; }
.mcell .crown { position: absolute; top: -2px; left: 6px; color: #f5b53f; width: 16px; height: 16px; }

/* requests */
.reqrow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); }
.reqrow + .reqrow { border-top: 1px solid var(--line); }
.reqrow .body { flex: 1; min-width: 0; }
.reqrow .name { font-weight: 500; }
.reqrow .msg { color: var(--text2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg); border-radius: 16px; width: min(440px, 100%); max-height: calc(100% - 24px); display: flex; flex-direction: column; box-shadow: var(--shadow2); overflow: hidden; }
.modal .mh { padding: 18px 20px 10px; font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.modal .mh span { flex: 1; }
.modal .mb { padding: 0 20px 10px; overflow-y: auto; min-height: 0; }
.modal .mb p { margin: 6px 0 14px; color: var(--text2); font-size: 14px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 12px 12px; }
.modal .mb .list { max-height: 50vh; margin: 0 -8px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.pick:hover { background: var(--hover); }
.pick .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .cb { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text3); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.pick.on .cb { background: var(--acc); border-color: var(--acc); }
.pick .cb .ic { width: 14px; height: 14px; }
.urow { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.urow .body { flex: 1; min-width: 0; }
.urow .name { font-weight: 500; }
.urow .sub { font-size: 13px; color: var(--text2); }

/* context menu */
.cmenu { position: fixed; z-index: 200; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow2); padding: 6px 0; min-width: 170px; animation: fade .1s; }
.cmenu button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 10px 16px; font-size: 14.5px; color: var(--text); cursor: pointer; text-align: left; }
.cmenu button:hover { background: var(--hover); }
.cmenu button .ic { width: 20px; height: 20px; color: var(--text2); }
.cmenu button.danger, .cmenu button.danger .ic { color: var(--danger); }
.cmenu .mi-hdr { padding: 6px 16px 8px; font-size: 12px; color: var(--text2); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menuback { position: fixed; inset: 0; z-index: 199; }

/* toast */
#toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 400; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80vw; text-align: center; }
#toast.on { opacity: 1; }

/* image viewer */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; z-index: 300; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .vtools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.viewer .vtools .ibtn, .viewer .vtools a { color: #fff; background: rgba(255,255,255,.12); width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* pwa hint */
.hint { background: var(--acc-bg); color: var(--text); font-size: 13px; padding: 10px 14px; border-radius: 10px; margin: 12px; line-height: 1.5; }
.hint .ic { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #rail { display: none; }
  #side { width: 100%; min-width: 0; border-right: 0; }
  #tabbar { display: flex; }
  #content { position: fixed; inset: 0; z-index: 50; transform: translateX(100%); transition: transform .22s ease; visibility: hidden; }
  #content.open { transform: translateX(0); visibility: visible; }
  .ibtn.backbtn { display: inline-flex; margin-left: -6px; }
  .chead { padding-left: 6px; }
  .m { max-width: 88%; }
  .emptychat { display: none; }
  .citem, .crow { border-radius: 0; margin: 0; }
  .modal { border-radius: 16px; }
  .cmenu.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; border-radius: 16px 16px 0 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .cmenu.sheet button { padding: 14px 20px; font-size: 16px; }
  .chead { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .shead { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .view .vhead { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .jump { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- v2: reactions, pins, mentions, markdown, members panel, search ---------- */
.av-saved { background: var(--acc); }
.av.plus { border: 1.5px dashed var(--text3); background: transparent; color: var(--text2); }
.citem .prev .draft { color: var(--danger); font-style: normal; font-weight: 500; }
.chatwrap { flex: 1; min-height: 0; display: flex; }
.chatmain { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.mpanel { width: 232px; flex-shrink: 0; background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; padding-bottom: 12px; }
.mpanel .mph { padding: 14px 16px 4px; font-weight: 600; font-size: 14px; }
.mpanel .sect { padding: 12px 16px 4px; font-size: 11.5px; text-transform: uppercase; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 6px 12px; margin: 0 6px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.mrow:hover { background: var(--hover); }
.mrow.off { opacity: .55; }
.mrow .mn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.mrow .crown { width: 14px; height: 14px; color: #f5b53f; }
.mrow.add { color: var(--text2); }
.ibtn.deskonly { display: none; }
@media (min-width: 901px) { .ibtn.deskonly { display: inline-flex; } }
.pinbar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; background: var(--bg); border-bottom: 1px solid var(--line); flex-shrink: 0; cursor: pointer; }
.pinbar > .ic { color: var(--acc); width: 18px; height: 18px; }
.pinbar .pb { flex: 1; min-width: 0; border-left: 2px solid var(--acc); padding-left: 10px; font-size: 13px; line-height: 1.3; }
.pinbar .pb b { color: var(--acc); display: block; font-size: 12.5px; font-weight: 600; }
.pinbar .pb span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.pinbar .ibtn { width: 32px; height: 32px; }
.daysep { position: sticky; top: 4px; z-index: 3; }
.unreaddiv { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--acc); font-size: 12.5px; font-weight: 600; }
.unreaddiv::before, .unreaddiv::after { content: ""; flex: 1; height: 1px; background: var(--acc); opacity: .5; }
.m.hl .bub { animation: hl 1.4s; }
@keyframes hl { 0%, 60% { box-shadow: 0 0 0 3px var(--acc); } 100% { box-shadow: var(--shadow); } }
.m .quick { display: none; align-items: center; gap: 0; align-self: center; opacity: 0; transition: opacity .12s; }
.m .quick .ibtn { width: 30px; height: 30px; color: var(--text3); }
.m .quick .ibtn .ic { width: 18px; height: 18px; }
@media (hover: hover) { .m .quick { display: flex; } .m:hover .quick { opacity: 1; } }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.react { border: 0; background: rgba(0,0,0,.06); border-radius: 12px; padding: 2px 8px 2px 6px; font-size: 14px; line-height: 20px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.react span { font-size: 12.5px; font-weight: 600; color: var(--text2); }
.react.mine { background: var(--acc); color: #fff; }
.react.mine span { color: #fff; }
.bub.pic .reacts { margin: 6px 6px 4px; }
.reactpick { position: fixed; z-index: 200; background: var(--bg); border-radius: 24px; box-shadow: var(--shadow2); padding: 4px 6px; display: flex; gap: 2px; animation: pop .15s; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.reactpick button { border: 0; background: none; font-size: 24px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: transform .1s; }
.reactpick button:hover { transform: scale(1.25); background: var(--hover); }
.reactpick .morebtn { color: var(--text2); display: flex; align-items: center; justify-content: center; }
.reactpick .morebtn .ic { width: 20px; height: 20px; }
.bub pre { background: rgba(0,0,0,.07); border-radius: 8px; padding: 8px 10px; margin: 4px 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap; overflow-x: auto; }
.bub code { background: rgba(0,0,0,.07); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; }
:root[data-theme="dark"] .bub pre, :root[data-theme="dark"] .bub code { background: rgba(255,255,255,.1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bub pre, :root:not([data-theme="light"]) .bub code { background: rgba(255,255,255,.1); } }
.spoiler { background: var(--text); color: transparent; border-radius: 4px; cursor: pointer; transition: background .2s, color .2s; }
.spoiler.open { background: rgba(0,0,0,.08); color: inherit; }
.mention { color: var(--acc); font-weight: 600; cursor: pointer; }
.mention.me { background: var(--acc-bg); border-radius: 4px; padding: 0 3px; }
.mentionpop { position: absolute; bottom: 100%; left: 12px; width: 300px; max-width: calc(100vw - 24px); background: var(--bg); border-radius: 12px; box-shadow: var(--shadow2); padding: 6px; margin-bottom: 6px; z-index: 21; }
.mentionpop .mi { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.mentionpop .mi small { color: var(--text2); margin-left: auto; }
.mentionpop .mi.on, .mentionpop .mi:hover { background: var(--acc-bg); }
.srow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.srow:hover { background: var(--hover); }
.srow .body { flex: 1; min-width: 0; }
.srow .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.srow .time { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.srow .sub { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow mark { background: rgba(245,181,63,.45); color: inherit; border-radius: 3px; }
.pick .badge { margin-left: auto; }

/* ---------- bots ---------- */
.botbadge { display: inline-block; font-size: 10px; line-height: 14px; background: var(--acc); color: #fff; border-radius: 4px; padding: 0 4px; font-weight: 700; margin-left: 5px; vertical-align: 2px; letter-spacing: .3px; flex-shrink: 0; }
.citem.sel .botbadge, .crow.sel .botbadge { background: #fff; color: var(--acc); }
code.tok { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--text); }
.sitem.static .btn { flex-shrink: 0; }

/* quick switcher / mention list: keyboard selection highlight */
#qs-res .pick:hover { background: transparent; }
#qs-res .pick.on { background: var(--acc-bg); }

/* ---------- photo albums (several pictures in one message) ---------- */
.album { display: grid; gap: 2px; width: 340px; max-width: 100%; border-radius: 9px; overflow: hidden; grid-template-columns: 1fr 1fr; }
.album .cell { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg3); }
.album .cell img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; transition: filter .15s; }
.album .cell img:hover { filter: brightness(.92); }
.album.n2 .cell { aspect-ratio: 3 / 4; }
.album.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.album.n3 .cell { aspect-ratio: auto; }
.album.n3 .cell:first-child { grid-row: span 2; }
.album.n5, .album.n6, .album.n7, .album.n8, .album.n9 { grid-template-columns: repeat(6, 1fr); }
.album.n5 .cell, .album.n6 .cell, .album.n7 .cell, .album.n8 .cell, .album.n9 .cell { grid-column: span 2; }
.album.n5 .cell:nth-child(-n+2), .album.n7 .cell:nth-child(1), .album.n8 .cell:nth-child(-n+2) { grid-column: span 3; aspect-ratio: 3 / 2; }
.album.n7 .cell:nth-child(1) { grid-column: span 6; aspect-ratio: 2 / 1; }
.album .morecnt { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 26px; font-weight: 600; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.viewer .vnav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.viewer .vnav:hover { background: rgba(255,255,255,.26); }
.viewer .vnav.prev { left: 14px; } .viewer .vnav.next { right: 14px; }
.viewer .vnav .ic { width: 26px; height: 26px; }
.viewer .vcount { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 14px; background: rgba(0,0,0,.4); padding: 3px 12px; border-radius: 12px; }
@media (max-width: 900px) { .viewer .vnav { display: none; } }

/* ---------- markdown headings inside messages ---------- */
.mdh { display: block; font-weight: 700; line-height: 1.3; margin: .55em 0 .25em; }
.mdh:first-child { margin-top: .1em; }
.mdh1 { font-size: 1.3em; }
.mdh2 { font-size: 1.18em; }
.mdh3 { font-size: 1.08em; }
.mdh4, .mdh5, .mdh6 { font-size: 1em; color: var(--text2); }

/* markdown horizontal rule */
.mdhr { display: block; height: 0; border-top: 1px solid var(--text3); opacity: .55; margin: .6em 0; }

/* ---------- markdown tables ---------- */
.mdtw { display: block; overflow-x: auto; margin: .45em 0; max-width: 100%; -webkit-overflow-scrolling: touch; }
.mdt { border-collapse: collapse; font-size: .93em; line-height: 1.35; white-space: normal; min-width: 240px; }
.mdt th, .mdt td { border: 1px solid rgba(0,0,0,.14); padding: 5px 9px; text-align: left; vertical-align: top; min-width: 3em; }
.mdt th { background: rgba(0,0,0,.055); font-weight: 600; white-space: nowrap; }
.mdt tbody tr:nth-child(even) td { background: rgba(0,0,0,.022); }
:root[data-theme="dark"] .mdt th, :root[data-theme="dark"] .mdt td { border-color: rgba(255,255,255,.16); }
:root[data-theme="dark"] .mdt th { background: rgba(255,255,255,.08); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mdt th, :root:not([data-theme="light"]) .mdt td { border-color: rgba(255,255,255,.16); }
  :root:not([data-theme="light"]) .mdt th { background: rgba(255,255,255,.08); }
}
/* login logo now uses the real app icon */
.alogo .mark { background: none; border-radius: 0; width: 88px; height: 88px; }
.alogo .mark img { width: 100%; height: 100%; display: block; }

/* ---------- pinned chats: tinted row + a clear pin on the right (Telegram / WeChat) ---------- */
.citem.pinned { background: var(--bg2); }
.citem.pinned:hover { background: var(--bg3); }
.citem.pinned.sel { background: var(--sel); }
.pinmark { width: 22px; height: 22px; border-radius: 50%; background: var(--bg3); color: var(--text2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pinmark .ic { width: 13px; height: 13px; transform: rotate(40deg); }
.citem.sel .pinmark { background: rgba(255,255,255,.25); color: #fff; }
/* select-text sheet */
.seltext { white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text; font-size: 16px; line-height: 1.6; padding: 4px 2px 12px; max-height: 60vh; overflow-y: auto; }
