:root {
  --bg-0: #111014;
  --bg-1: #16151a;
  --bg-2: #1c1b21;
  --bg-3: #25242b;
  --bg-4: #2f2e36;
  --bg-5: #3a3942;
  --line: #2c2b33;
  --text: #ecebf1;
  --text-2: #b6b4c0;
  --text-3: #85838f;
  --accent: #e8794a;
  --accent-hi: #f28d61;
  --accent-soft: rgba(232, 121, 74, 0.14);
  --good: #3fb27f;
  --warn: #f0b232;
  --bad: #e5484d;
  --bad-soft: rgba(229, 72, 77, 0.12);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-2);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#app { height: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.55; }
a { color: #7cb7ff; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; height: 100%; color: var(--text-3); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 8px;
  background: var(--bg-4); color: var(--text); font-weight: 600; font-size: 14px;
  transition: background 0.12s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-5); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #1a0f0a; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #f05c61; }
.btn.danger-outline { background: transparent; box-shadow: inset 0 0 0 1px rgba(229, 72, 77, 0.5); color: #ff8a8d; }
.btn.danger-outline:hover:not(:disabled) { background: var(--bad-soft); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  color: var(--text-2); transition: background 0.12s, color 0.12s;
}
.icon-btn:hover:not(:disabled) { background: var(--bg-4); color: var(--text); }
.icon-btn.on { color: var(--text); background: var(--bg-4); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 6px; }
.icon-btn.round { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-3); }
.icon-btn.round:hover { background: var(--bg-5); }
.icon-btn.danger:hover:not(:disabled) { color: #ff8a8d; }
.icon-btn.good:hover:not(:disabled) { color: var(--good); }

.link { color: #7cb7ff; font-weight: 500; }
.link:hover { text-decoration: underline; }
.link.danger { color: #ff8a8d; }

.input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--bg-0); border: 1px solid var(--line); color: var(--text);
  transition: border-color 0.12s;
}
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 44px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { color: var(--text-3); font-size: 12.5px; }
.hint.right { align-self: flex-end; }
.form-error { color: #ff8a8d; font-size: 14px; min-height: 0; margin: 4px 0 10px; }
.form-error:empty { display: none; }
.form-msg { font-size: 14px; margin: 6px 0 10px; }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--good); }
.form-msg.bad { color: #ff8a8d; }

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; margin: 4px 0 14px; border-radius: 8px;
  background: var(--accent-soft); color: var(--text-2); font-size: 13px;
}
.callout .icon { color: var(--accent); margin-top: 2px; }
.callout b { color: var(--text); }

.count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800;
}

/* ---------- auth ---------- */
.auth-screen {
  height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(232, 121, 74, 0.16), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(110, 86, 207, 0.12), transparent 60%),
    var(--bg-1);
}
.auth-card {
  width: 100%; max-width: 420px; padding: 32px 28px; border-radius: 16px;
  background: var(--bg-2); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.auth-card h1 { font-size: 24px; margin: 22px 0 6px; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--text-2); font-size: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; }

/* ---------- layout ---------- */
.shell { display: flex; height: 100%; }
.sidebar { width: 268px; flex: none; display: flex; flex-direction: column; background: var(--bg-1); border-right: 1px solid var(--line); }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-row { flex: 1; min-height: 0; display: flex; position: relative; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-panel { width: 280px; flex: none; background: var(--bg-1); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.scrim { display: none; }
.side-panel { position: relative; }
.side-close { display: none; position: absolute; top: 8px; right: 8px; z-index: 2; background: rgba(0, 0, 0, 0.35); color: #fff; }
.mobile-only { display: none; }
.conn-banner { padding: 6px 12px; background: var(--warn); color: #241a00; font-size: 13px; font-weight: 700; text-align: center; }

/* sidebar */
.side-head { height: 56px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.side-nav { padding: 10px 8px 4px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 600;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--bg-4); color: var(--text); }
.nav-label { flex: 1; text-align: left; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.side-section { margin-top: 14px; }
.side-title {
  display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 10px; height: 28px;
  font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3);
}
.side-empty { padding: 4px 10px 8px; color: var(--text-3); font-size: 13px; }
.conv-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px;
  color: var(--text-2); text-align: left; margin-bottom: 2px;
}
.conv-item:hover { background: var(--bg-3); color: var(--text); }
.conv-item.active { background: var(--bg-4); color: var(--text); }
.conv-item.unread { color: var(--text); }
.conv-item.unread .conv-name { font-weight: 700; }
.conv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-name { display: flex; align-items: center; gap: 5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-panel { flex: none; display: flex; align-items: center; gap: 4px; padding: 8px; background: var(--bg-0); }
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px; text-align: left; }
.me-btn:hover { background: var(--bg-3); }
.me-text { min-width: 0; display: flex; flex-direction: column; }
.me-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* avatars */
.avatar {
  position: relative; flex: none; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar-initial { color: #fff; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.group-avatar { background: linear-gradient(135deg, #6e56cf, #3e8ed0); border-radius: 30%; }
.presence {
  position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; min-width: 10px; min-height: 10px;
  border-radius: 50%; border: 3px solid var(--bg-1); background: var(--text-3);
}
.presence-online, .presence-dot.presence-online { background: var(--good); }
.presence-away, .presence-dot.presence-away { background: var(--warn); }
.presence-dnd, .presence-dot.presence-dnd { background: var(--bad); }
.presence-offline, .presence-invisible, .presence-dot.presence-invisible { background: #6b6975; }
.presence-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 5px; }

.badge-trust { color: var(--good); display: inline-flex; }
.badge-warn { color: var(--warn); display: inline-flex; }

/* main header */
.main-head {
  height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.head-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.head-title h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-title > .icon { color: var(--text-3); }
.head-actions { margin-left: auto; display: flex; gap: 4px; }
.e2e-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: rgba(63, 178, 127, 0.12); color: #6fd2a5; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.warn-banner {
  display: flex; align-items: center; gap: 10px; margin: 10px 16px 0; padding: 10px 12px; border-radius: 8px;
  background: rgba(240, 178, 50, 0.12); color: #f6d089; font-size: 13.5px;
}
.warn-banner .icon { flex: none; }
.warn-banner span { flex: 1; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-left: 12px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 5px 12px; border-radius: 6px; color: var(--text-2); font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tab:hover { background: var(--bg-3); color: var(--text); }
.tab.active { background: var(--bg-4); color: var(--text); }
.tab-add { background: var(--good); color: #062417; }
.tab-add:hover { background: #4cc28e; color: #062417; }
.tab-add.active { background: transparent; color: #6fd2a5; }

/* friends */
.friends-body { flex: 1; overflow-y: auto; padding: 18px 24px; }
.list-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; border-bottom: 1px solid var(--line); }
.friend-row:hover { background: var(--bg-3); }
.friend-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.friend-text { min-width: 0; display: flex; flex-direction: column; }
.friend-name { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.friend-username { color: var(--text-3); font-weight: 500; font-size: 13px; }
.friend-sub { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-actions { display: flex; gap: 8px; }
.empty { display: grid; place-items: center; text-align: center; gap: 14px; padding: 60px 20px; color: var(--text-2); }
.empty-art { width: 84px; height: 84px; border-radius: 50%; background: var(--bg-3); display: grid; place-items: center; color: var(--text-3); }
.add-friend { max-width: 560px; }
.add-friend h2 { font-size: 18px; margin-bottom: 4px; }
.add-friend > .muted { margin-bottom: 14px; }
.add-row { display: flex; gap: 8px; padding: 6px; border-radius: 10px; background: var(--bg-0); border: 1px solid var(--line); }
.add-row .input { border: 0; background: transparent; }
.add-row .input:focus { border: 0; }
.add-row:focus-within { border-color: var(--accent); }
.add-friend .small { margin-top: 18px; }

/* messages */
.banner-slot:empty { display: none; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0 8px; overscroll-behavior: contain; }
.msg-loading { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); font-size: 13px; min-height: 30px; }
.intro { padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.intro h2 { font-size: 26px; margin-top: 6px; }
.day-divider { display: flex; align-items: center; margin: 16px 20px 6px; color: var(--text-3); font-size: 12px; font-weight: 600; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-divider span { padding: 0 10px; }
.msg { position: relative; display: flex; gap: 14px; padding: 2px 20px; }
.msg:hover { background: rgba(255, 255, 255, 0.025); }
.msg-first { margin-top: 12px; }
.msg-avatar { flex: none; margin-top: 2px; border-radius: 50%; }
.msg-gutter { width: 40px; flex: none; text-align: right; font-size: 11px; color: transparent; padding-top: 3px; user-select: none; }
.msg:hover .msg-gutter { color: var(--text-3); }
.msg-main { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 6px; }
.msg-meta .badge-trust, .msg-meta .badge-warn { align-self: center; }
.msg-author { font-weight: 700; }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--text-3); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; color: #dcdbe2; }
.msg-text.failed { color: var(--text-3); font-style: italic; display: flex; align-items: center; gap: 4px; }
.edited { font-size: 11px; color: var(--text-3); }
.msg-actions {
  position: absolute; right: 16px; top: -14px; display: none; gap: 2px; padding: 2px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg.is-editing { background: rgba(232, 121, 74, 0.06); }
.edit-box { margin-top: 4px; }
.edit-input { resize: none; overflow-y: auto; }
.edit-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.msg-system { display: flex; align-items: center; gap: 8px; padding: 4px 20px 4px 34px; margin-top: 6px; color: var(--text-3); font-size: 13.5px; }
.msg-system time { font-size: 11px; }

/* composer */
.composer-wrap { flex: none; padding: 0 16px 6px; }
.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 14px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid transparent;
}
.composer:focus-within { border-color: var(--bg-5); }
.composer-input {
  flex: 1; min-height: 24px; max-height: 240px; padding: 6px 0; background: transparent; border: 0; resize: none; outline: none;
  line-height: 1.45;
}
.composer-input::placeholder { color: var(--text-3); }
.send-btn { color: var(--accent); }
.send-btn:hover { color: var(--accent-hi) !important; }
.typing { height: 22px; display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 12.5px; color: var(--text-2); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* side panel */
.side-panel-head { padding: 18px 16px 8px; }
.side-panel-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.member-list { padding: 0 8px; flex: 1; }
.member { display: flex; align-items: center; border-radius: 8px; }
.member:hover { background: var(--bg-3); }
.member.is-offline { opacity: 0.5; }
.member-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; text-align: left; }
.member-text { min-width: 0; display: flex; flex-direction: column; }
.member-name { display: flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owner { color: var(--warn); display: inline-flex; }
.member-remove { opacity: 0; margin-right: 4px; }
.member:hover .member-remove, .member-remove:focus-visible { opacity: 1; }
.side-actions { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }

/* profile card */
.profile-card { --accent: #e8794a; display: flex; flex-direction: column; background: var(--bg-1); }
.profile-banner { height: 96px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000)); flex: none; }
.profile-card.compact .profile-banner { height: 80px; }
.profile-top { padding: 0 16px; margin-top: -48px; }
.profile-top .avatar { border: 6px solid var(--bg-1); box-sizing: content-box; }
.profile-top .presence { border-width: 4px; }
.profile-body { padding: 10px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.profile-names h2 { font-size: 20px; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.profile-status { font-size: 14px; color: var(--text-2); }
.profile-section { padding-top: 12px; border-top: 1px solid var(--line); }
.profile-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 4px; }
.profile-section p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-more { display: flex; gap: 16px; font-size: 13px; }
.security { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--bg-3); }
.security > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.security b { font-size: 13.5px; }
.security small { font-size: 12px; color: var(--text-2); }
.security-trusted { background: rgba(63, 178, 127, 0.1); }
.security-trusted > .icon { color: var(--good); }
.security-changed { background: rgba(240, 178, 50, 0.12); }
.security-changed > .icon { color: var(--warn); }
.security-unverified > .icon { color: var(--text-3); }

/* verify */
.verify { display: flex; flex-direction: column; gap: 14px; }
.verify .warn-banner { margin: 0; }
.code-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px; padding: 16px; border-radius: 10px;
  background: var(--bg-0); font: 600 18px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.06em; text-align: center;
}
.trusted-note { display: flex; align-items: center; gap: 6px; color: var(--good); font-size: 14px; }

/* modals */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 5, 8, 0.7); animation: fade 0.12s ease-out;
}
.modal {
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: pop 0.14s ease-out; overflow: hidden;
}
.modal-wide { max-width: 860px; height: min(640px, calc(100vh - 32px)); }
.modal-profile { max-width: 380px; }
.modal-profile .modal-body { padding: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--bg-1); border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } }

.picker { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px; background: var(--bg-1); }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; width: 100%; text-align: left; }
.pick-row:hover { background: var(--bg-3); }
.pick-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.pick-row .icon { color: var(--good); margin-left: auto; }

/* popover menu */
.popover {
  position: fixed; z-index: 40; width: 240px; padding: 6px; border-radius: 10px;
  background: var(--bg-0); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); animation: pop 0.1s ease-out;
}
.menu-item { width: 100%; display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 7px; text-align: left; }
.menu-item:hover { background: var(--bg-3); }
.menu-item.active { background: var(--bg-4); }
.menu-item > span { display: flex; flex-direction: column; }
.menu-item b { font-weight: 600; font-size: 14px; }
.menu-item small { color: var(--text-3); font-size: 12px; }
.menu-item .icon { margin-top: 2px; color: var(--text-2); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* settings */
.settings { display: flex; gap: 20px; height: 100%; }
.modal-wide .modal-body { padding-top: 4px; }
.settings-nav { width: 190px; flex: none; display: flex; flex-direction: column; gap: 2px; }
.settings-tab { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; text-align: left; color: var(--text-2); font-weight: 600; }
.settings-tab:hover { background: var(--bg-3); color: var(--text); }
.settings-tab.active { background: var(--bg-4); color: var(--text); }
.settings-tab.danger { color: #ff8a8d; }
.settings-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 0 4px 12px; }
.settings-pane h3 { font-size: 18px; margin-bottom: 6px; }
.settings-pane > div > .muted.small { margin-bottom: 16px; }
.sub-head { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin: 22px 0 6px; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.settings-actions.left { justify-content: flex-start; margin: 4px 0 16px; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--text-2); }
.avatar-edit { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.avatar-ring { padding: 4px; border-radius: 50%; background: var(--accent); }
.avatar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); }
.swatch.active { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--text); }
.color-input { width: 38px; height: 32px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.explain { display: flex; flex-direction: column; gap: 12px; margin: 10px 0; }
.explain > div { display: flex; gap: 12px; padding: 12px; border-radius: 10px; background: var(--bg-3); }
.explain .icon { color: var(--accent); margin-top: 2px; }
.explain p { font-size: 14px; color: var(--text-2); }
.explain b { color: var(--text); }
.fingerprint { display: block; padding: 10px 12px; border-radius: 8px; background: var(--bg-0); font: 13px/1.6 ui-monospace, Consolas, monospace; color: var(--text-2); word-spacing: 4px; }
.trusted-list { display: flex; flex-direction: column; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 10px; background: var(--bg-3); margin: 10px 0 12px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.switch-row > span { display: flex; flex-direction: column; }
.switch-row small { color: var(--text-2); }
.invite-list { display: flex; flex-direction: column; gap: 6px; }
.invite { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-3); }
.invite.used { opacity: 0.6; }
.invite-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.invite code { font: 600 14px ui-monospace, Consolas, monospace; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--bg-5); color: var(--text); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); font-size: 14px; animation: pop 0.15s ease-out; transition: opacity 0.3s; }
.toast-error { background: #4a1d20; color: #ffd0d1; }
.toast-success { background: #173a2a; color: #c6f1dc; }
.toast.leaving { opacity: 0; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--bg-5) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--bg-5); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .side-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 15; box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4); }
  .side-close { display: inline-grid; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; width: min(300px, 86vw); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.5); }
  .mobile-only { display: inline-grid; }
  .main-head { padding: 0 8px; }
  .e2e-pill { display: none; }
  .tabs { margin-left: 4px; }
  .friends-body { padding: 14px 12px; }
  .msg { padding: 2px 12px; gap: 10px; }
  .msg-gutter { width: 40px; }
  .composer-wrap { padding: 0 8px calc(6px + env(safe-area-inset-bottom)); }
  .settings { flex-direction: column; gap: 12px; }
  .settings-nav { width: auto; flex-direction: row; overflow-x: auto; }
  .settings-tab { white-space: nowrap; }
  .settings-nav .menu-sep { display: none; }
  .modal-wide { height: calc(100vh - 32px); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .code-grid { grid-template-columns: repeat(3, 1fr); font-size: 16px; }
  .side-panel { width: min(300px, 90vw); }
}
/* Touch screens have no hover, so show edit/delete on your own messages all the time. */
@media (hover: none) {
  .msg-actions { display: flex; position: static; box-shadow: none; background: transparent; border: 0; align-self: flex-start; opacity: 0.7; }
  .member-remove { opacity: 1; }
}
