:root {
  --bg: #0b141a;
  --panel: #111b21;
  --head: #202c33;
  --in: #202c33;
  --out: #005c4b;
  --accent: #00a884;
  --text: #e9edef;
  --muted: #8696a0;
  --line: #2a3942;
  --tick: #53bdeb;
  --danger: #ea4335;
  --banner: #00a884;
  --hover: #2a3942;
  --elev: #233138;
  --input: #2a3942;
  --pill: #2a3942;
  --icon-btn: #2a3942;
  --chat: #0b141a;
  --sys: #182229;
  --hairline: #1c272d;
  --on-msg: #ffffff99;
  --bar: #1a2329;
  --preview: #1f2c33;
  --doodle: #ffffff0a;
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0a1014;
  color: var(--text);
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; color: var(--text); }
input {
  background: var(--input);
  color: var(--text);
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
}
input:focus { outline: 1px solid var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 16px; }

.boot-fail {
  padding: 24px;
  text-align: center;
  background: #3b0d0d;
}
.boot-fail a { color: var(--accent); }

.login {
  min-height: 100%;
  background: #111b21;
}
.login-banner { height: 180px; background: var(--banner); }
.login-card {
  width: min(460px, 92vw);
  margin: -90px auto 40px;
  background: #1d2a31;
  padding: 32px;
  border-radius: 8px;
}
.logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #042a22;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 26px;
}
.logo.big { width: 88px; height: 88px; font-size: 42px; margin: 0 auto 16px; border-radius: 24px; }
.login-card h1 { margin: 12px 0 8px; font-size: 26px; }
.login-card label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 16px 0 8px; }
.account {
  background: #2a3942;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
}
.account.active { outline: 2px solid var(--accent); }
.account b { display: block; }
.account span { color: var(--muted); font-size: 12px; }
.primary, .ghost, .danger { border-radius: 8px; padding: 11px 14px; }
.primary { background: var(--accent); color: #042a22; font-weight: 700; width: 100%; margin-top: 16px; }
.primary:disabled { opacity: 0.6; cursor: wait; }
.ghost { background: var(--input); color: var(--text); }
.danger { background: var(--danger); color: white; margin-top: 12px; }
.error { color: #ff8a80; font-size: 13px; margin: 10px 0 0; }

.app {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.sidebar .side-head,
.sidebar .search {
  flex-shrink: 0;
}
.side-head, .chat-head {
  background: var(--head);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-height: 60px;
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #042a22;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 88px; height: 88px; font-size: 32px; }
.avatar.huge { width: 120px; height: 120px; font-size: 42px; margin: 8px auto; }
.icon-btns { display: flex; gap: 2px; }
.icon-btns button, .chat-head button:not(#rooms-leave):not(#rooms-mode), .back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.icon-btns button:hover, .chat-head button:not(#rooms-leave):not(#rooms-mode):hover, .back:hover {
  background: var(--hover);
}
.icon-btns button svg,
.chat-head button:not(#rooms-leave):not(#rooms-mode) svg,
.back svg {
  width: 24px;
  height: 24px;
  display: block;
}
#rooms-leave,
#rooms-mode {
  color: var(--accent);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  width: auto;
  height: auto;
  background: transparent;
}
#rooms-leave:hover,
#rooms-mode:hover { background: var(--hover); }
.menu {
  position: absolute;
  top: 58px;
  right: 10px;
  background: var(--elev);
  border-radius: 8px;
  padding: 6px;
  z-index: 5;
  min-width: 168px;
  color: var(--text);
}
.menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 6px; color: var(--text); }
.menu button:hover { background: var(--hover); }
.search { padding: 8px 10px; background: var(--panel); position: relative; }
.search-ico {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search input { padding-left: 40px; }
.chats {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chat-item {
  display: flex;
  gap: 12px;
  padding: 11px 14px;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--hairline);
}
.chat-item:hover, .chat-item.active { background: var(--hover); }
.chat-item .meta { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; }
.preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #042a22;
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; margin-left: 6px; }

.pane { background: var(--bg); position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.empty {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  border-bottom: 6px solid var(--accent);
}
.thread { flex: 1; min-height: 0; height: 100%; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.msgs {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 7%;
  background-color: var(--chat);
  background-image: radial-gradient(var(--doodle) 1px, transparent 1px);
  background-size: 18px 18px;
}
.msgs.wp-doodle { background-image: radial-gradient(var(--doodle) 1px, transparent 1px); background-size: 18px 18px; }
.msgs.wp-none { background-image: none; }
.msgs.wp-dark { background-image: none; background-color: #0b141a; }
.msgs.wp-teal { background-image: none; background-color: #0e3b34; }
.msgs.wp-rose { background-image: none; background-color: #3b1520; }
.day {
  text-align: center;
  margin: 12px 0;
  font-size: 12px;
  color: var(--muted);
}
.day span { background: var(--sys); padding: 4px 10px; border-radius: 8px; color: var(--muted); }
.bubble {
  max-width: min(72%, 560px);
  padding: 7px 10px 4px;
  border-radius: 8px;
  margin: 2px 0;
  box-shadow: none;
  overflow-wrap: anywhere;
}
.bubble.out { margin-left: auto; background: var(--out); }
.bubble.in { background: var(--in); }
.bubble.sys { margin: 8px auto; background: var(--sys); color: var(--muted); font-size: 12px; text-align: center; }
.bubble .time { font-size: 11px; color: var(--on-msg); text-align: right; margin-top: 2px; }
.ticks { margin-left: 4px; }
.ticks.blue { color: var(--tick); }
.media img, .media video { max-width: 280px; max-height: 320px; border-radius: 8px; display: block; margin-bottom: 4px; cursor: pointer; }
.media audio { width: 240px; margin: 6px 0; }
.doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 280px;
  padding: 8px 4px 6px;
  text-decoration: none;
  color: inherit;
}
.doc-ico {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #53bdeb;
  color: #042a22;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.doc-name { font-weight: 600; word-break: break-word; }
.doc-meta { font-size: 12px; color: var(--on-msg); }

.attach-sheet {
  position: absolute;
  left: 12px;
  bottom: 68px;
  z-index: 15;
  background: var(--elev);
  border-radius: 14px;
  padding: 8px;
  min-width: 220px;
}
.attach-sheet button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
}
.attach-sheet button:hover { background: var(--hover); }
.att-ico {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.att-ico svg { width: 20px; height: 20px; display: block; }
.att-gallery { background: #7c4dff; }
.att-camera { background: #e91e63; }
.att-doc { background: #5b6abf; }
.att-audio { background: #ff8a00; }

.attach-preview {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 25;
  display: flex;
  flex-direction: column;
}
.attach-preview-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--preview);
}
.attach-preview-body {
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
}
.attach-preview-body img, .attach-preview-body video { max-width: 92vw; max-height: 62vh; border-radius: 8px; }
.attach-preview-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--preview);
  align-items: center;
}
.attach-progress { height: 3px; background: var(--input); }
.attach-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.file-chip {
  background: var(--head);
  padding: 18px 22px;
  border-radius: 12px;
  text-align: center;
  min-width: 220px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img, .lightbox video { max-width: 96vw; max-height: 88vh; }
#lightbox-close, .lightbox-dl {
  position: absolute;
  top: 14px;
  color: #fff;
  z-index: 2;
}
#lightbox-close { left: 14px; display: grid; place-items: center; width: 40px; height: 40px; }
#lightbox-close svg { width: 22px; height: 22px; display: block; color: #fff; }
.lightbox-dl { right: 14px; text-decoration: none; background: var(--input); color: var(--text); padding: 8px 12px; border-radius: 8px; }
#lightbox-img.hidden, #lightbox-video.hidden { display: none !important; }
.typing { padding: 0 7% 6px; color: var(--accent); font-size: 13px; }
.composer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  background: var(--head);
  position: relative;
}
.composer-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.composer-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--pill);
  border-radius: 24px;
  padding: 0 6px 0 4px;
  min-width: 0;
}
.composer-pill #text {
  background: transparent;
  flex: 1;
  min-width: 60px;
  padding: 11px 8px;
}
.composer-pill #text:focus { outline: none; }
#btn-emoji {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
#btn-emoji svg { width: 24px; height: 24px; display: block; }
.emoji-sheet {
  position: absolute;
  left: 52px;
  bottom: 62px;
  z-index: 16;
  width: min(320px, calc(100% - 70px));
  background: var(--elev);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.emoji-sheet button { width: 34px; height: 34px; font-size: 20px; border-radius: 8px; }
.emoji-sheet button:hover { background: var(--hover); }
.send {
  background: var(--accent);
  color: #042a22;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.send svg { width: 22px; height: 22px; display: block; }
.send.mic { background: var(--accent); }
#btn-attach {
  width: 42px;
  height: 42px;
  color: var(--muted);
  display: grid;
  place-items: center;
  border-radius: 50%;
}
#btn-attach svg { width: 26px; height: 26px; display: block; }
#btn-attach:hover { background: var(--hover); }
.voice-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--pill);
  border-radius: 24px;
  padding: 6px 6px 6px 10px;
  min-height: 48px;
}
#voice-trash, #voice-pause, #voice-once {
  width: 36px;
  height: 36px;
  color: var(--muted);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
#voice-trash svg, #voice-pause svg, #voice-once svg {
  width: 20px;
  height: 20px;
  display: block;
}
#voice-once.on { color: var(--accent); }
.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ea4335;
  flex-shrink: 0;
  animation: pulse 1s infinite;
}
.voice-dot.off { animation: none; background: #8696a0; }
@keyframes pulse { 50% { opacity: 0.35; } }
#voice-time { font-variant-numeric: tabular-nums; min-width: 36px; font-size: 14px; }
.voice-wave { flex: 1; height: 28px; min-width: 40px; }
.ptt {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 280px;
}
.ptt audio { display: none; }
.ptt-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff22;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: inherit;
}
.ptt-play svg { width: 18px; height: 18px; display: block; }
.ptt canvas { flex: 1; height: 28px; min-width: 80px; }
.ptt-dur { font-size: 12px; color: var(--on-msg); min-width: 32px; }
.ptt.viewed { opacity: 0.5; }
.ptt.viewed .ptt-play { pointer-events: none; }

.modal {
  position: fixed;
  inset: 0;
  background: #0008;
  display: grid;
  place-items: center;
  z-index: 45;
}
.modal-card {
  width: min(420px, 92vw);
  background: var(--panel);
  padding: 20px;
  border-radius: 12px;
}
.people { max-height: 320px; overflow: auto; margin-top: 12px; }
.person {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
}
.person:hover { background: var(--hover); }
.person input { width: auto; }
.contact-card { width: min(460px, 92vw); }
.contact-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.contact-actions button { background: var(--input); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.contact-actions button svg { width: 18px; height: 18px; display: block; flex-shrink: 0; }
.contact-sec {
  font-size: 12px;
  color: var(--muted);
  padding: 12px 8px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.new-contact-form { display: grid; gap: 8px; margin-top: 10px; }
.invite-btn { padding: 6px 10px; font-size: 12px; color: var(--accent); }
#contact-search { margin-top: 10px; }

.call {
  position: fixed;
  inset: 0;
  background: #0b141a;
  z-index: 30;
  overflow: hidden;
}
.call-shade {
  position: absolute;
  inset: 0;
  background: #0b141a;
  pointer-events: none;
}
.call.is-video .call-shade { background: #0006; }
#remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b141a;
}
#local-video {
  position: absolute;
  right: 16px;
  bottom: 110px;
  width: 132px;
  height: 176px;
  object-fit: cover;
  border-radius: 10px;
  background: #111;
  z-index: 2;
}
.call:not(.is-video) #local-video,
#local-video.hidden { display: none; }
.call-top {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 56px 20px 0;
}
.call-avatar {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 700;
  color: #042a22;
  background: var(--accent);
}
.call.is-video.is-active .call-avatar { display: none; }
#call-peer-name { font-size: 26px; font-weight: 600; }
#call-status, #call-timer { color: var(--muted); margin-top: 8px; }
.call-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.call-btn {
  min-width: 72px;
  height: 56px;
  padding: 0 16px;
  border-radius: 28px;
  background: #2a3942;
  font-weight: 600;
}
.call-btn.off { background: #f59e0b; color: #111; }
.call-btn.accept { background: var(--accent); color: #042a22; }
.call-btn.decline { background: var(--danger); color: #fff; }

.row.wrap { flex-wrap: wrap; margin-top: 10px; }
.backup-card { width: min(480px, 92vw); max-height: 90vh; overflow: auto; }
.backup-card h3 { margin: 0 0 8px; }
.backup-card label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.backup-card .primary { width: auto; margin-top: 0; }
.backup-card code { color: var(--accent); font-size: 12px; }
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--text);
  font-size: 14px;
}
.check-row input { width: auto; }
.file-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--input);
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--elev);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 40;
}
.inapp-notify {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: min(420px, 92vw);
  padding: 10px 14px;
  background: var(--head);
  border-radius: 12px;
  box-shadow: 0 8px 28px #0008;
  cursor: pointer;
}
.inapp-notify .avatar { width: 40px; height: 40px; }

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin: 2px 0;
  max-width: 100%;
}
.msg-row.mine { justify-content: flex-end; }
.msg-row.sys-row { justify-content: center; }
.msg-row .bubble { margin: 0; }
.msg-stack { max-width: min(72%, 560px); display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.mine .msg-stack { align-items: flex-end; }
.msg-wrap { display: flex; align-items: flex-start; gap: 2px; max-width: 100%; }
.msg-row.mine .msg-wrap { flex-direction: row-reverse; }
.msg-row.selected .bubble { outline: 2px solid var(--accent); }
.msg-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #8696a0;
  margin-top: 10px;
  flex-shrink: 0;
}
.msg-row.selected .msg-check { background: var(--accent); border-color: var(--accent); }
.bubble.deleted { font-style: italic; color: var(--on-msg); }
.quote {
  background: #0003;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.quote b { color: var(--accent); font-size: 12px; }
.star-mark { float: right; color: #ffce00; margin-left: 6px; }
.react-pills { margin-top: 2px; }
.react-pills span {
  display: inline-block;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 12px;
  margin-right: 4px;
}
.msg-menu {
  position: fixed;
  z-index: 50;
  width: 260px;
  background: var(--elev);
  border-radius: 12px;
  padding: 8px 0 6px;
  box-shadow: 0 8px 28px #0008;
  color: var(--text);
}
.react-bar {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 10px 10px;
}
.react-bar button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--input);
  font-size: 18px;
}
.react-bar button:hover { transform: scale(1.15); background: var(--hover); }
.react-plus { font-weight: 700; color: var(--muted); }
.react-more {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 10px 8px;
}
.react-more button { font-size: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--input); }
.msg-menu > button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  color: var(--text);
}
.msg-menu > button svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.msg-menu > button:hover { background: var(--hover); }
.menu-sep { height: 1px; background: var(--hairline); margin: 4px 0; }
.danger-item { color: #ea4335 !important; }
.danger-item svg { color: #ea4335 !important; }
.delete-card button { width: 100%; margin-top: 8px; text-align: left; color: var(--text); }
.delete-card button:hover { background: var(--hover); }
.pin-bar, .select-bar, .reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.pin-ico { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.select-bar button,
.pin-bar button,
#reply-cancel,
#attach-cancel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.select-bar button svg,
.pin-bar button svg,
#reply-cancel svg,
#attach-cancel svg {
  width: 20px;
  height: 20px;
  display: block;
}
.reply-bar {
  width: 100%;
  order: -1;
  border-bottom: 0;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 4px;
}
.select-bar { min-height: 60px; background: var(--head); }
.select-bar span { flex: 1; font-weight: 600; }

.back { display: none; }

.settings {
  position: absolute;
  inset: 0;
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 25;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}
.settings.hidden { display: none !important; }
.settings-nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
}
#settings-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
#settings-back:hover { background: var(--hover); }
#settings-back svg { width: 24px; height: 24px; display: block; }
.settings-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 16px 10px;
  position: relative;
}
.settings-mood {
  position: relative;
  background: var(--head);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
}
.settings-mood::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--head);
  border-bottom: 0;
}
.settings-hero-name, #settings-hero-name { font-weight: 600; margin-top: 10px; }
.settings-list { padding: 8px 8px 4px; }
.set-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 2px;
}
.set-item b { display: block; font-weight: 600; }
.set-item .muted { display: block; }
.set-item:hover, .set-item.active { background: var(--head); }
.set-ico {
  width: 22px;
  height: 22px;
  color: var(--muted);
  flex-shrink: 0;
}
.set-ico svg { width: 22px; height: 22px; display: block; }
.settings-logout {
  display: flex;
  align-items: center;
  gap: 14px;
  width: calc(100% - 16px);
  margin: 8px auto 16px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--danger);
  text-align: left;
}
.settings-logout svg { width: 22px; height: 22px; }
.settings-logout:hover { background: #ea433518; }
.settings-page {
  background: var(--panel);
  overflow: auto;
  min-width: 0;
}
.set-page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 16px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.set-page-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.set-page-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.set-page-back:hover { background: var(--hover); }
.set-page-back svg { width: 24px; height: 24px; display: block; }
.set-body { padding: 20px 28px 40px; max-width: 560px; }
.set-body label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.set-body h4 { margin: 22px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.set-body .primary { width: auto; }
.set-cta { width: auto; margin: 12px 0 18px; padding: 10px 28px; border-radius: 24px; }
.set-stat { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 10px 0; }
.set-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  border-bottom: 1px solid var(--line);
  width: calc(100% + 16px);
  text-align: left;
  color: inherit;
}
.set-row:hover { background: var(--hover); }
.set-row-ico { width: 22px; height: 22px; color: var(--muted); flex-shrink: 0; }
.set-row-ico svg { width: 22px; height: 22px; display: block; }
.set-link { color: var(--accent); font-weight: 600; padding: 8px 0 16px; }
.set-toggle .grow { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.set-profile { text-align: left; }
.set-user-row { display: flex; align-items: center; gap: 6px; }
.set-user-row span { color: var(--muted); }
.set-toggle, .set-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.set-toggle b, .set-choice { font-weight: 500; }
.set-toggle input, .set-choice input { width: auto; accent-color: var(--accent); }
.set-card {
  background: var(--head);
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
}
.set-device { padding: 6px 0; }
.set-block-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.set-keys { width: 100%; border-collapse: collapse; }
.set-keys td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-keys td:last-child { text-align: right; color: var(--muted); }
kbd {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--head);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  margin-left: 4px;
}
.wp-picks { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
.wp-pick {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 2px solid transparent;
}
.wp-pick.on { border-color: var(--accent); }
.wp-pick.wp-doodle { background: #0b141a; background-image: radial-gradient(#ffffff44 1px, transparent 1px); background-size: 8px 8px; }
.wp-pick.wp-none { background: #202c33; }
.wp-pick.wp-dark { background: #0b141a; }
.wp-pick.wp-teal { background: #0e3b34; }
.wp-pick.wp-rose { background: #3b1520; }
.av-preview { margin-top: 12px; }
.av-preview video { width: 100%; max-width: 320px; border-radius: 10px; background: #000; }
.set-help p { line-height: 1.5; }
#settings-page .person { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 8px; }
#settings-page .person:hover { background: var(--head); }

html.theme-light {
  --bg: #efeae2;
  --panel: #ffffff;
  --head: #f0f2f5;
  --in: #ffffff;
  --out: #d9fdd3;
  --text: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --tick: #53bdeb;
  --hover: #f0f2f5;
  --elev: #ffffff;
  --input: #f0f2f5;
  --pill: #ffffff;
  --icon-btn: #dfe5e7;
  --chat: #efeae2;
  --sys: #ffffff;
  --hairline: #e9edef;
  --on-msg: #667781;
  --bar: #f0f2f5;
  --preview: #ffffff;
  --doodle: #00000014;
}
html.theme-light body { background: #d1d7db; color: var(--text); }
html.theme-light .composer-pill,
html.theme-light .voice-bar {
  border: 1px solid var(--line);
}
html.theme-light .login,
html.theme-light .login-card,
html.theme-light .login h1,
html.theme-light .login button,
html.theme-light .login .account,
html.theme-light .login .account b {
  color: #e9edef;
}
html.theme-light .login input {
  background: #2a3942;
  color: #e9edef;
}
html.theme-light .login .ghost { background: #2a3942; color: #e9edef; }
html.theme-light .login .muted,
html.theme-light .login label { color: #8696a0; }
html.theme-light .call,
html.theme-light .live,
html.theme-light .call-btn,
html.theme-light .live-peer,
html.theme-light .live-idle {
  color: #e9edef;
}
html.theme-light .call .muted,
html.theme-light .live .muted,
html.theme-light #call-status,
html.theme-light #call-timer {
  color: #8696a0;
}
html.theme-light .call-btn.accept { color: #042a22; }
html.theme-light .call-btn.decline { color: #fff; }
html.theme-light .call-btn.off { color: #111; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .app.show-thread .sidebar { display: none; }
  .app:not(.show-thread) .pane { display: none; }
  .app.settings-open .sidebar, .app.settings-open .pane { display: none; }
  .back { display: grid; }
  .settings { grid-template-columns: 1fr; }
  .settings:not(.show-page) .settings-page { display: none; }
  .settings.show-page .settings-nav { display: none; }
}

.rooms-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.rooms-overlay.hidden { display: none !important; }
#rooms-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
#rooms-back:hover { background: var(--hover); }
#rooms-back svg { width: 24px; height: 24px; display: block; }
#rooms-form input {
  flex: 1;
  background: var(--input);
  color: var(--text);
  border-radius: 24px;
  padding: 10px 16px;
}
.rooms-nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.rooms-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
}
.room-item:hover, .room-item.active { background: var(--head); }
.room-item b { display: block; }
.rooms-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.rooms-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
#rooms-form { flex-shrink: 0; }
.rooms-msgs {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: var(--chat);
}
.room-msg { display: flex; gap: 10px; margin-bottom: 12px; }
.room-msg.mine b { color: var(--accent); }
.room-msg .avatar.sm { width: 32px; height: 32px; font-size: 13px; flex-shrink: 0; }
.rooms-typing { padding: 0 16px 6px; }
#room-join .primary, #room-join .ghost,
#live-join .primary, #live-join .ghost { width: 100%; margin-top: 8px; }

.live {
  position: fixed;
  inset: 0;
  background: #0b141a;
  z-index: 31;
  overflow: hidden;
}
.live.hidden { display: none !important; }
#live-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b141a;
}
.live-idle {
  position: relative;
  z-index: 2;
  text-align: center;
  padding-top: 18vh;
}
.live-peer {
  position: absolute;
  top: 24px;
  left: 20px;
  z-index: 2;
  font-weight: 600;
}
#live-local {
  position: absolute;
  right: 16px;
  bottom: 110px;
  width: 110px;
  height: 150px;
  object-fit: cover;
  border-radius: 10px;
  background: #111;
  z-index: 2;
}
.live-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .rooms-overlay { grid-template-columns: 1fr; }
  .rooms-overlay:not(.in-chat) .rooms-pane { display: none; }
  .rooms-overlay.in-chat .rooms-nav { display: none; }
}

.group-info {
  position: absolute;
  inset: 0;
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 26;
  display: flex;
  justify-content: flex-end;
  background: rgba(11, 20, 26, 0.45);
  overflow: hidden;
}
.group-info.hidden { display: none !important; }
.group-info-panel {
  width: min(400px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
}
#gi-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
#gi-back:hover { background: var(--hover); }
#gi-back svg { width: 24px; height: 24px; display: block; }
.gi-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.gi-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 20px 8px;
}
.gi-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.gi-name-row h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.gi-sub { margin-top: 4px; color: var(--muted); font-size: 14px; }
.gi-accent { color: var(--accent); }
.gi-actions {
  display: flex;
  gap: 28px;
  margin: 18px 0 8px;
}
.gi-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.gi-round-ico {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.gi-round-ico svg { width: 22px; height: 22px; }
.gi-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.gi-icon-btn svg { width: 18px; height: 18px; }
.gi-icon-btn:hover { background: var(--hover); color: var(--text); }
.gi-desc, .gi-row, .gi-add-member, .gi-member {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  color: var(--text);
}
.gi-desc { justify-content: space-between; }
.gi-desc span:first-child { white-space: pre-wrap; }
.gi-row-ico {
  width: 22px;
  height: 22px;
  color: var(--muted);
  flex-shrink: 0;
}
.gi-row-ico svg { width: 22px; height: 22px; display: block; }
.gi-row-sub .grow { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.gi-row:hover, .gi-desc:hover, .gi-add-member:hover, .gi-member:hover { background: var(--hover); }
.gi-thumbs {
  display: flex;
  gap: 6px;
  padding: 0 18px 12px;
  overflow: hidden;
}
.gi-thumb {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--input);
  flex-shrink: 0;
}
.gi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gi-thumb-file { color: var(--muted); font-size: 22px; }
.gi-sep { height: 8px; background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; }
.gi-members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  color: var(--muted);
  font-size: 14px;
}
#gi-search-wrap { padding: 0 18px 8px; }
.gi-add-ico {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #042a22;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.gi-add-ico svg { width: 20px; height: 20px; }
.gi-member .avatar { width: 40px; height: 40px; font-size: 15px; }
.gi-member-name { font-weight: 600; }
.gi-admin {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0, 168, 132, 0.12);
  border: 1px solid rgba(0, 168, 132, 0.28);
  border-radius: 4px;
  padding: 2px 7px;
}
.gi-phone { color: var(--muted); font-size: 15px; margin-top: 4px; }
.gi-about { margin-top: 8px; font-size: 13px; max-width: 300px; }
.gi-empty { padding: 4px 18px 20px; }
#gi-edit { color: var(--muted); }
#gi-edit svg { width: 18px; height: 18px; }
button.gi-member {
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
}
button.gi-member:disabled { opacity: 1; cursor: default; }
#peer-avatar.is-clickable,
#chat-head-info.is-clickable { cursor: pointer; }
#chat-head-info.is-clickable:hover #peer-name { color: var(--accent); }


