:root {
  --bg: #0e1621;
  --panel: #17212b;
  --panel-2: #232e3c;
  --border: #0e1621;
  --text: #f5f5f5;
  --muted: #6d7f8f;
  --accent: #6ab3f3;
  --accent-2: #2b5278;
  --bubble-mine: #2b5278;
  --bubble-r: 10px;
  --bubble-tail: 4px;
  --theirs: #182533;
  --chat-bg: var(--bg);
  --danger: #e05c5c;
  --online: #4dcd5e;
  --radius: 12px;
  --font: 15px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --side: 300px;
  --profile: 320px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: var(--font)/1.4 "Segoe UI", system-ui, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.screen {
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b));
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid #101921;
  border-radius: 10px;
  padding: 28px 24px;
}
.auth-card.wide { width: min(520px, 100%); }
.auth-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 650; }
.lead { color: var(--muted); margin: 0 0 18px; }
.fine { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
#ios-install, #ios-install-set { margin-top: 14px; }
label { display: block; margin: 0 0 12px; color: var(--muted); font-size: 13px; }
label > input, label > textarea, label > select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid #243140;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  color: var(--text);
}
label > input:focus, label > textarea:focus, label > select:focus, #draft:focus, #chat-search:focus, #inchat-q:focus {
  border-color: #3d4f63;
}
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }

.btn {
  border: 1px solid #243140;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
}
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; width: 100%; }
.btn.danger { color: var(--danger); border-color: #5a3030; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-row .btn { width: auto; }

#view-app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--side) 5px minmax(0, 1fr);
  grid-template-rows: 100%;
  overflow: hidden;
}
#view-app.profile-open {
  grid-template-columns: var(--side) 5px minmax(0, 1fr) var(--profile);
}
#split {
  cursor: col-resize;
  background: #101921;
  z-index: 5;
  position: relative;
}
#split::after {
  content: "";
  position: absolute;
  inset: 0 -5px;
}
#split:hover, body.resizing #split {
  background: #3d7eaf;
}
body.resizing {
  cursor: col-resize;
  user-select: none;
}
body.resizing iframe,
body.resizing video,
body.resizing img {
  pointer-events: none;
}

#sidebar,
#conversation,
#profile-pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#sidebar {
  background: var(--panel);
  border-right: 1px solid #101921;
}
#profile-pane {
  background: var(--panel);
  border-left: 1px solid #101921;
}

.side-head, #chat-head, #composer, #reply-bar, .sheet header, #profile-pane > header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid #101921;
  min-height: 46px;
  flex: 0 0 auto;
  background: var(--panel);
  z-index: 3;
}
.side-head, #chat-head, .sheet header, #profile-pane > header {
  padding-top: calc(4px + var(--safe-t));
  min-height: calc(46px + var(--safe-t));
}
#chat-head { cursor: pointer; }
#chat-head:hover { background: #1c2834; }
#composer, #reply-bar { border-bottom: 0; border-top: 1px solid #101921; }
.side-title { display: flex; flex-direction: column; min-width: 0; }
.side-title strong, .side-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-title span { color: var(--muted); font-size: 13px; }
.push-banner {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  border-bottom: 1px solid #101921;
  flex: 0 0 auto;
}
.grow { flex: 1; min-width: 0; }
.avatar-btn, .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #2b3a4a; overflow: hidden; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 13px; color: #d2dce6;
}
.avatar-btn.lg { width: 72px; height: 72px; font-size: 22px; }
.avatar-btn.xl { width: 120px; height: 120px; font-size: 36px; margin: 8px auto 12px; display: grid; }
.avatar-btn img, .avatar img, #set-avatar img, #me-avatar img, #peer-avatar img, #profile-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; color: var(--muted);
  display: grid; place-items: center; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.send { color: var(--accent); }
.mobile-only { display: none; }
.search-wrap { padding: 4px 8px 8px; flex: 0 0 auto; }
#chat-search, #inchat-q {
  width: 100%;
  background: var(--bg);
  border: 0;
  border-radius: 16px;
  padding: 6px 10px;
  outline: none;
}
#chat-list, #profile-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}
#search-hits {
  overflow-y: auto;
  flex: 0 1 auto;
  max-height: 36%;
  overscroll-behavior: contain;
  border-bottom: 1px solid #101921;
}
.chat-item, .hit {
  display: flex; gap: 8px; align-items: center;
  padding: 5px 8px; width: 100%; text-align: left;
  border-radius: 0;
}
.chat-item:hover, .hit:hover { background: #202b36; }
.chat-item.active { background: #2b5278; }
.chat-item.active .preview, .chat-item.active .chat-top small { color: #c5d4e0; }
.chat-meta { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-top small { color: var(--muted); font-size: 12px; }
.preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #3c90d6; color: #fff; font-size: 12px; display: grid; place-items: center;
}

#conversation { background-color: var(--chat-bg); position: relative; }
#conversation.empty-main #chat-head,
#conversation.empty-main #composer,
#conversation.empty-main #msg-scroll,
#conversation.empty-main #inchat-search,
#conversation.empty-main #reply-bar,
#conversation.empty-main #jump-down,
#conversation.empty-main #pin-bar,
#conversation.empty-main #album-bar,
#conversation.empty-main #select-bar,
#conversation.empty-main #sched-bar,
#conversation.empty-main #file-queue { display: none !important; }
#conversation:not(.empty-main) #empty-chat { display: none !important; }
.placeholder {
  margin: auto;
  color: var(--muted);
  background: #1c2a38;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
}

#inchat-search { padding: 4px 8px; flex: 0 0 auto; background: var(--panel); }
#msg-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 8px 6px;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}
#msg-list {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}
.msg-row {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(82%, 380px);
  align-self: flex-start;
  touch-action: pan-y;
  transition: transform 0.14s ease;
  will-change: auto;
}
.msg-row.swiping {
  transition: none;
  z-index: 2;
}
.msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-row.circle { max-width: none; }
.day {
  align-self: center;
  color: #fff;
  background: #1c2a38;
  font-size: 12px;
  margin: 6px 0;
  padding: 2px 8px;
  border-radius: 10px;
}
.unread-sep {
  align-self: stretch;
  text-align: center;
  color: #9ec4e6;
  background: #1c2a38;
  font-size: 13px;
  margin: 8px 0;
  padding: 4px 8px;
}
.msg.flash { outline: 2px solid #3d7eaf; }
.msg {
  max-width: 100%;
  padding: 3px 7px 2px;
  border-radius: var(--bubble-r);
  background: var(--theirs);
  position: relative;
  width: fit-content;
  overflow: hidden;
}
.msg.mine { align-self: flex-end; background: var(--bubble-mine); border-bottom-right-radius: var(--bubble-tail); }
.msg.theirs { align-self: flex-start; border-bottom-left-radius: var(--bubble-tail); }
.msg.deleted { color: var(--muted); font-style: italic; }
.msg.media { padding: 3px; }
.fwd, .reply-q {
  display: block;
  font-size: 13px;
  color: #9ec4e6;
  border-left: 2px solid #7ab0d8;
  padding-left: 8px;
  margin: 2px 4px 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-q { cursor: pointer; }
.msg .meta {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
  font-size: 11px;
  color: #9bb2c5;
  margin: 2px 2px 0 auto;
  float: right;
  padding-left: 10px;
}
.ticks { display: inline-flex; width: 18px; height: 12px; }
.ticks svg { width: 18px; height: 12px; }
.ticks.read { color: #72d4fd; }
.msg img.photo, .msg video.clip {
  max-width: 100%; max-height: 360px; border-radius: var(--bubble-r); display: block; cursor: pointer;
}
.msg .cap { display: block; padding: 4px 6px 0; white-space: pre-wrap; }
.link-card {
  display: block;
  margin: 4px 0 2px;
  padding: 8px 10px;
  border-left: 2px solid #6ab3f3;
  background: rgba(0,0,0,.18);
  border-radius: 0 8px 8px 0;
  color: inherit;
}
.link-card strong, .link-card small { display: block; }
.link-card small { color: var(--muted); margin-top: 4px; font-size: 12px; }
.album {
  display: grid;
  gap: 2px;
  width: min(280px, 72vw);
  border-radius: 10px;
  overflow: hidden;
}
.album.count-1 { grid-template-columns: 1fr; }
.album.count-2, .album.count-4 { grid-template-columns: 1fr 1fr; }
.album.count-3 { grid-template-columns: 1fr 1fr; }
.album.count-3 .cell:first-child { grid-column: 1 / -1; }
.album .cell { position: relative; }
.album .more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  pointer-events: none;
}
.album .cell img {
  width: 100%;
  height: 118px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.album.count-1 .cell img { height: auto; max-height: 360px; }
.msg-row.picked > .msg { outline: 2px solid #3d7eaf; }
.msg-row .pick {
  position: absolute;
  top: 8px;
  width: 18px;
  height: 18px;
  border: 1.6px solid #9bb2c5;
  border-radius: 50%;
  display: none;
}
.msg-row.theirs .pick { left: -22px; }
.msg-row.mine .pick { right: -22px; }
body.selecting .msg-row .pick { display: block; }
body.selecting .msg-row.picked .pick { background: #3c90d6; border-color: #3c90d6; }
#pin-bar, #album-bar, #select-bar, #sched-bar, #file-queue {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel);
  border-bottom: 1px solid #101921;
  flex: 0 0 auto;
  min-height: 44px;
}
#album-bar, #select-bar, #file-queue { border-bottom: 0; border-top: 1px solid #101921; }
#pin-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
}
#pin-open small { color: #6ab3f3; font-size: 12px; }
#pin-preview, #select-count { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#album-thumbs { display: flex; gap: 6px; overflow-x: auto; flex: 1; }
#album-thumbs img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
#select-bar { justify-content: space-between; }
#select-bar strong { flex: 1; }
body.selecting #composer, body.selecting #album-bar, body.selecting #reply-bar { display: none !important; }
#lightbox {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: rgba(8,12,18,.92);
  z-index: 40;
  position: fixed;
  inset: 0;
}
#lightbox[hidden] { display: none !important; }
.viewer-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-top: calc(8px + var(--safe-t));
}
#lb-pos { flex: 1; color: #d4d4d8; }
#lb-stage {
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  height: 100%;
}
#lb-stage img, #lb-stage video {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
}
#lb-stage video.circle-view {
  width: min(72vw, 420px);
  height: min(72vw, 420px);
  border-radius: 50%;
  object-fit: cover;
  background: #000;
}
.viewer-nav {
  font-size: 42px;
  color: #d4d4d8;
  height: 100%;
}
#lb-cap {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 16px calc(12px + var(--safe-b));
  color: #ececec;
  text-align: center;
}
.msg a { overflow-wrap: anywhere; word-break: break-word; }
.msg.call-log {
  background: transparent;
  padding: 0;
  max-width: none;
  align-self: center;
}
.msg.call-log > div {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.msg.circle,
.msg.circle.mine,
.msg.circle.theirs {
  background: transparent;
  padding: 0;
  border-radius: 0;
  max-width: none;
  overflow: visible;
}
.msg.circle > div { background: transparent; padding: 0; }
.msg.circle .meta { display: none; }
.msg-reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.react-chip {
  background: #1c2a38;
  border: 1px solid #243140;
  border-radius: 12px;
  padding: 1px 7px;
  min-height: 22px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
}
.react-chip.mine {
  background: var(--bubble-mine);
  border-color: #3d6a94;
}
.quick-react {
  position: absolute;
  top: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  display: none;
  place-items: center;
  z-index: 3;
}
.quick-react svg { width: 16px; height: 16px; }
.msg-row.theirs .quick-react { right: -34px; }
.msg-row.mine .quick-react { left: -34px; }
@media (hover: hover) and (min-width: 861px) {
  .msg-row:hover .quick-react { display: grid; }
}
.circle-wrap {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  background: #111;
  position: relative;
  clip-path: circle(50%);
}
.circle-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.circle-time {
  position: absolute;
  right: 16px;
  bottom: 14px;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}

.voice {
  display: grid;
  grid-template-columns: 44px minmax(140px, 1fr) 36px;
  gap: 2px 8px;
  align-items: center;
  min-width: min(280px, 70vw);
  width: min(340px, 78vw);
  padding: 2px 4px 2px 2px;
}
.voice-play {
  width: 44px; height: 44px; border-radius: 50%;
  background: #5ca3d6; color: #fff;
  display: grid; place-items: center;
}
.msg.mine .voice-play { background: #e8f4ff; color: #2b5278; }
.voice-play svg { width: 18px; height: 18px; }
.voice-mid { min-width: 0; }
.voice-wave {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
}
.voice-wave i {
  display: block;
  width: 2px;
  border-radius: 1px;
  background: rgba(255,255,255,.38);
  flex: 0 0 auto;
}
.msg.mine .voice-wave i { background: rgba(255,255,255,.42); }
.voice-wave i.on { background: #fff; }
.voice-sub {
  font-size: 12px;
  color: #b7c9d8;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.voice-sub .ticks { color: #9bb2c5; }
.voice-sub .ticks.read { color: #72d4fd; }
.voice-speed {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35);
  font-size: 12px; color: #eaf4ff;
}
.voice audio { display: none; }

#typing-line { color: var(--muted); font-size: 13px; padding: 4px 8px; }
#composer {
  background: var(--panel);
  padding: 2px 4px calc(2px + var(--safe-b));
  gap: 0;
  min-height: 42px;
}
#composer.recording > :not(#rec-bar) { display: none !important; }
#rec-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
}
#btn-voice { touch-action: none; }
#rec-hint {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  min-width: 118px;
}
#rec-bar.cancel { background: #3a1d1d; }
#rec-bar.cancel #rec-hint { color: #e05c5c; }
#conversation:has(#reply-bar:not([hidden])) #jump-down {
  bottom: calc(102px + var(--safe-b));
}
#jump-down {
  position: absolute;
  right: 12px;
  bottom: calc(54px + var(--safe-b));
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid #101921;
  color: var(--text);
  z-index: 6;
  display: grid;
  place-items: center;
}
#jump-down svg { width: 20px; height: 20px; }
#jump-count {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #3d7eaf;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  padding: 0 5px;
}
.media-tabs {
  display: flex;
  margin: 16px 0 8px;
  border-bottom: 1px solid #101921;
  text-align: left;
}
.media-tabs button {
  flex: 1;
  padding: 8px 4px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.media-tabs button.on {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
#profile-media { text-align: left; min-height: 48px; padding-bottom: 24px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.media-grid button { padding: 0; background: #111; }
.media-grid img, .media-grid video {
  width: 100%; height: 90px; object-fit: cover; display: block;
}
.media-list { display: flex; flex-direction: column; gap: 2px; }
.media-list a, .media-list button {
  display: block;
  text-align: left;
  padding: 8px 6px;
  color: var(--text);
  background: var(--panel-2);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e53935;
  flex: 0 0 auto;
  animation: recblink 1s steps(1) infinite;
}
@keyframes recblink { 50% { opacity: 0; } }
.rec-wave {
  flex: 1;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}
.rec-wave i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 1px;
  background: #6ab3f3;
  flex: 0 0 auto;
}
#voice-timer {
  min-width: 40px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#draft {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 8px 6px;
  outline: none;
  line-height: 1.35;
}
#load-older { align-self: center; color: var(--muted); padding: 8px; }

#emoji-pop, #attach-pop, #msg-menu, #react-pop, #send-pop {
  position: fixed; z-index: 20; background: var(--panel); border: 1px solid #101921;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
#emoji-pop {
  width: min(360px, calc(100vw - 16px)); height: 280px; overflow: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px;
}
#emoji-pop button { font-size: 22px; height: 40px; }
#react-pop {
  width: min(288px, calc(100vw - 16px));
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
}
#react-pop button { font-size: 20px; height: 36px; border-radius: 8px; }
#react-pop button:hover { background: var(--panel-2); }
#attach-pop, #msg-menu, #send-pop { display: flex; flex-direction: column; min-width: 180px; padding: 6px; }
#msg-menu { min-width: 272px; }
#attach-pop button, #msg-menu > button, #send-pop button { text-align: left; padding: 10px 12px; border-radius: 8px; }
#attach-pop button:hover, #msg-menu > button:hover, #send-pop button:hover { background: var(--panel-2); }
.react-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 2px 2px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid #101921;
}
.react-row button {
  text-align: center;
  padding: 6px 0;
  font-size: 18px;
  min-width: 0;
  border-radius: 8px;
}
.react-row button:hover { background: var(--panel-2); }

#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30;
  display: grid; place-items: center; padding: 16px;
}
.sheet {
  width: min(520px, 100%); max-height: min(92vh, 860px); overflow: auto;
  background: var(--panel); border: 1px solid #101921; border-radius: 10px;
}
.sheet header { position: sticky; top: 0; background: var(--panel); }
.sheet-body { padding: 16px 18px 24px; }
.sheet-body h3 { margin: 20px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }
.profile-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
#profile-scroll { padding: 20px 18px 32px; text-align: center; }
#profile-scroll h3 { margin: 0 0 4px; font-size: 20px; }
#profile-user, #profile-status, #profile-bio { color: var(--muted); margin: 0 0 8px; }
#profile-bio { margin: 12px 0 18px; color: var(--text); }
#profile-scroll .btn { width: 100%; margin: 6px 0; }

input[type="range"] {
  appearance: none; -webkit-appearance: none; width: 100%; height: 4px;
  background: #2c2c32; border-radius: 0; outline: none; margin-top: 10px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; background: #ececec; border-radius: 50%;
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: #ececec; border: 0; border-radius: 50%; }
.rights { list-style: none; padding: 0; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; margin-right: 6px; }
.dot.on { background: var(--online); }

.rec-overlay {
  position: fixed; inset: 0; background: rgba(8,12,18,.78); z-index: 40;
  display: grid; place-items: center;
}
.circle-rec { display: flex; flex-direction: column; align-items: center; gap: 16px; }
#circle-preview {
  width: 220px; height: 220px; border-radius: 50%; object-fit: cover; background: #000; display: block;
}
.circle-rec-bar {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel);
  border-radius: 24px;
  padding: 6px 10px;
}

#toast {
  position: fixed; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid #101921; padding: 10px 14px;
  border-radius: 8px; z-index: 50; max-width: 90vw;
}

.spoiler {
  background: #3a4a58;
  color: transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0 3px;
}
.spoiler.on {
  background: rgba(0,0,0,.2);
  color: inherit;
}
.md-code, .msg code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}
.md-code {
  display: block;
  margin: 4px 0;
  padding: 8px;
  background: rgba(0,0,0,.22);
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
}
#reply-bar { z-index: 4; }
.archive-row, .archive-back {
  color: var(--muted);
  font-weight: 600;
}
.archive-row .badge { background: #52687a; }
#sched-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
#sched-bar small { color: #6ab3f3; }
#sched-list { display: flex; flex-direction: column; gap: 4px; }
.sched-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  width: 100%;
  padding: 4px 0;
}
.sched-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-item small { color: var(--muted); }
#call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,12,18,.88);
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 16px;
}
.call-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid #101921;
  border-radius: 12px;
  padding: 20px 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}
#call-remote, #call-local { display: none; background: #000; border-radius: 10px; }
#call-overlay.video #call-remote {
  display: block;
  width: 100%;
  max-height: 48vh;
  object-fit: cover;
}
#call-overlay.video #call-local {
  display: block;
  position: absolute;
  right: 22px;
  top: 22px;
  width: 96px;
  height: 128px;
  object-fit: cover;
  transform: scaleX(-1);
  border: 1px solid #101921;
}
#call-title { font-size: 18px; }
#call-state { color: var(--muted); }
.call-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.call-actions .btn { width: auto; min-width: 96px; padding: 8px 10px; }
@media (max-width: 520px) {
  .call-actions .btn { min-width: 0; flex: 1 1 40%; }
}
#lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
#lock-overlay[hidden] { display: none; }
#file-queue-list { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.mute-row { margin: 4px 0 8px; }
#chat-head .icon-btn { flex: 0 0 auto; }
#reply-bar.editing small { color: #6ab3f3; }

@media (min-width: 861px) {
  #msg-scroll { padding-left: 40px; padding-right: 40px; }
}
@media (max-width: 860px) {
  #view-app, #view-app.profile-open { grid-template-columns: 1fr; }
  #split { display: none; }
  .mobile-only { display: grid; }
  body.chat-open #sidebar { display: none; }
  body:not(.chat-open) #conversation { display: none; }
  body:not(.chat-open) #profile-pane { display: none; }
  #profile-pane {
    position: fixed;
    inset: 0;
    z-index: 16;
    width: auto;
    border: 0;
  }
  .msg { max-width: 86%; }
  #msg-list { width: 100%; }
  .album { width: min(86vw, 320px); }
}

.doc { max-width: 720px; margin: 0 auto; padding: 32px 18px 64px; overflow: auto; height: 100%; }
.doc h1 { font-size: 24px; }
.doc h2 { font-size: 18px; margin-top: 28px; }
.doc p, .doc li { color: #d4d4d8; }

.backup-codes {
  margin: 8px 0;
  padding: 10px 12px;
  background: #101921;
  border: 1px solid #1d2a36;
  border-radius: 8px;
  letter-spacing: 0.12em;
  font-size: 15px;
  line-height: 1.7;
  user-select: all;
  white-space: pre;
}
#session-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
#session-list .sess-name { flex: 1; min-width: 140px; }
.totp-qr {
  width: 168px;
  height: 168px;
  margin: 8px 0;
  background: #fff;
  padding: 6px;
  border-radius: 8px;
}
.totp-qr svg { width: 100%; height: 100%; display: block; }
.once-lock {
  min-width: 160px;
  min-height: 88px;
  display: grid;
  place-items: center;
  background: #101921;
  color: #d4d4d8;
  border: 1px solid #1d2a36;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  font: inherit;
}
.once-lock.circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
}
.voice.once .voice-play { outline: 1px solid #e6c36a; }
#attach-once.on { color: #e6c36a; }
.msg.once-gone { color: var(--muted); font-size: 13px; }

.swatch-row, .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #243140;
  padding: 0;
  min-height: 0;
  min-width: 0;
}
.swatch.sq { border-radius: 6px; }
.swatch.on { border-color: #f5f5f5; }
.swatch[data-accent="blue"] { background: #2b5278; }
.swatch[data-accent="graphite"] { background: #3a3f46; }
.swatch[data-accent="olive"] { background: #3d4a38; }
.swatch[data-accent="rust"] { background: #5a3a32; }
.swatch[data-accent="steel"] { background: #3d4e5c; }
.swatch[data-wall="default"] { background: #0e1621; }
.swatch[data-wall="deep"] { background: #0b1218; }
.swatch[data-wall="graphite"] { background: #121212; }
.swatch[data-wall="forest"] { background: #101612; }
.swatch[data-wall="wine"] { background: #161014; }
.chip {
  border: 1px solid #243140;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 32px;
  font-size: 13px;
}
.chip.on { border-color: var(--accent); }

html.amoled {
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #1a1a1a;
  --border: #0a0a0a;
  --theirs: #161616;
}
html.amoled .swatch[data-wall="default"] { background: #0a0a0a; }
html.amoled .chat-item.active { background: #2a2a2a; }
html.amoled .chat-item:hover, html.amoled .hit:hover { background: #1a1a1a; }
html.amoled #chat-head:hover { background: #1a1a1a; }
html.amoled .day, html.amoled .unread-sep { background: #1a1a1a; }

html.corners-round { --bubble-r: 16px; --bubble-tail: 6px; }
html.corners-sharp { --bubble-r: 5px; --bubble-tail: 2px; }

html.density-compact .chat-item,
html.density-compact .hit { padding: 3px 8px; }
html.density-compact .chat-item .avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}
html.density-compact .msg-row { max-width: min(74%, 320px); }
html.density-compact #msg-list { gap: 1px; }
html.density-compact .msg { padding: 2px 6px 1px; }
html.density-compact #msg-scroll { padding: 2px 6px 4px; }
html.density-compact .avatar-btn:not(.lg):not(.xl),
html.density-compact .icon-btn { width: 32px; height: 32px; }
html.density-compact #composer { min-height: 36px; }
html.density-compact #draft { min-height: 32px; padding: 6px 4px; }
html.density-compact .preview { font-size: 12px; }

html.hide-av .chat-item > .avatar,
html.hide-av #peer-avatar { display: none; }

html.time-under .msg-row > .meta {
  float: none;
  margin: 0 4px 2px;
  padding-left: 0;
}

html.wall-dots #conversation {
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.5px);
  background-size: 16px 16px;
}
html.wall-grid #conversation {
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(255, 255, 255, 0.03) 24px),
    repeating-linear-gradient(90deg, transparent, transparent 23px, rgba(255, 255, 255, 0.03) 24px);
}
html.wall-noise #conversation {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

html.reduce-motion .msg-row { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .msg-row { transition: none; }
}
