:root {
  --bg: #07070a;
  --panel: #0d0d12;
  --card: #14141b;
  --line: #1e1e27;
  --line-2: #2a2a36;
  --text: #f1f2f6;
  --muted: #8a8fa3;
  --good: #22c55e;
  --warn: #f5a623;
  --bad: #ef4444;
  --offline: #6b6f7d;
  --accent: #4d7cff;
  --accent-2: #7c5cff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  position: fixed; inset: 0; width: 100%;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
svg { display: block; }

/* LOGO WRAP — shows ? fallback if image fails */
.logo-wrap {
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-wrap::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 55%;
}
.logo-wrap img {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.logo-wrap.sm { width: 30px; height: 30px; border-radius: 9px; }
.logo-wrap.lg { width: 72px; height: 72px; border-radius: 20px; font-size: 30px; }
.logo-wrap.xl { width: 88px; height: 88px; border-radius: 22px; opacity: 0.55; font-size: 36px; }
.logo-wrap.avatar-img { width: 36px; height: 36px; font-size: 14px; }
.logo-wrap.avatar-img.sm { width: 32px; height: 32px; }
.logo-wrap.settings-avatar { width: 96px; height: 96px; border: 4px solid var(--card); font-size: 36px; }
.logo-wrap.peer-avatar { width: 88px; height: 88px; border: 4px solid var(--card); font-size: 34px; }
.logo-wrap.banner-img { width: 100%; height: 100%; border-radius: 0; }
.logo-wrap.banner-img::before { font-size: 40px; }

/* AUTH */
.auth-view {
  position: fixed; inset: 0; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 1200px 800px at 50% -20%, #16162a 0%, var(--bg) 60%);
}
.auth-inner {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 30px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 100px rgba(77,124,255,0.06);
  animation: authIn 0.4s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes authIn { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: none; } }

.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; font-weight: 800; text-align: center; }
h1 span { color: var(--muted); font-weight: 400; }

.tabs { display: flex; gap: 4px; background: #04040a; padding: 4px; border-radius: 12px; margin-bottom: 22px; }
.tab { flex: 1; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; transition: all 0.2s ease; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--line); color: var(--text); }

label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 16px 0 6px; }
input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #06060c; color: var(--text);
  font: inherit; font-size: 14.5px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,124,255,0.15); }
input.invalid { border-color: var(--bad); }
input.valid { border-color: var(--good); }

.msg { margin: 6px 0 0; font-size: 12px; min-height: 17px; color: var(--muted); }
.msg.good { color: var(--good); }
.msg.bad { color: var(--bad); }
.msg.pending { color: var(--warn); }

button[type="submit"]:not(.tab):not(.primary) {
  width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 14.5px;
  transition: all 0.25s ease; box-shadow: 0 4px 20px rgba(77,124,255,0.3);
}
button[type="submit"]:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
button[type="submit"]:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(77,124,255,0.4); }

details { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* APP */
.app { position: fixed; inset: 0; display: grid; grid-template-columns: 300px 1fr; overflow: hidden; }

.sidebar { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); overflow: hidden; min-height: 0; }

.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; flex-shrink: 0; }
.brand-name { flex: 1; font-weight: 700; letter-spacing: -0.01em; }

.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

.sidebar-body { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; overscroll-behavior: contain; }
.section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; padding: 12px 10px 6px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; }

.chat-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 9px; cursor: pointer; color: var(--muted);
  transition: background 0.15s, color 0.15s;
  border: 0; background: transparent; width: 100%; text-align: left; font: inherit;
}
.chat-item:hover { background: var(--line); color: var(--text); }
.chat-item.active { background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.avatar-wrap { position: relative; flex-shrink: 0; }
.status-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--panel); background: var(--offline);
}
.status-dot.lg { width: 16px; height: 16px; border-width: 3px; }
.status-online { background: var(--good); }
.status-idle { background: var(--warn); }
.status-dnd { background: var(--bad); }
.status-offline { background: var(--offline); }

.thought-bubble {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--panel);
  z-index: 2;
}

.chat-item .item-info { flex: 1; min-width: 0; }
.chat-item .item-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .item-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* USER BAR */
.user-bar { display: flex; align-items: center; border-top: 1px solid var(--line); background: #07070c; flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 12px 14px; border: 0; background: transparent;
  cursor: pointer; flex: 1; text-align: left; color: var(--text);
  transition: background 0.15s; min-width: 0;
}
.user-card:hover { background: var(--card); }

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-bar-settings { margin-right: 8px; flex-shrink: 0; }

.badge {
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
  display: inline-grid; place-items: center; line-height: 1;
  box-shadow: 0 0 12px rgba(239,68,68,0.5);
}

/* CHAT */
.chat-area { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; min-height: 0; position: relative; }
.empty-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); padding: 24px; text-align: center; }
.empty-chat h2 { margin: 0; color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.empty-chat p { margin: 0; font-size: 14px; }

.btn-accent {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 13.5px;
  transition: all 0.2s ease; box-shadow: 0 4px 20px rgba(77,124,255,0.3);
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(77,124,255,0.45); }
.btn-accent.full { width: 100%; justify-content: center; padding: 12px; }

.btn-ghost {
  padding: 11px 18px; border-radius: 10px;
  border: 1px solid var(--line-2); background: transparent;
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  transition: all 0.15s ease;
}
.btn-ghost:hover { border-color: var(--bad); color: var(--bad); }
.btn-ghost.full { width: 100%; padding: 12px; }

.chat-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel); flex-shrink: 0;
}
#back-btn { display: none; }
.chat-peer {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  background: transparent; border: 0; padding: 4px; margin: -4px;
  border-radius: 10px; color: inherit; font: inherit; text-align: left;
  transition: background 0.15s; cursor: pointer;
}
.chat-peer:hover { background: var(--line); }
.chat-title-wrap { flex: 1; min-width: 0; }
.chat-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-subtitle { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 20px 16px; display: flex; flex-direction: column; gap: 6px;
  min-height: 0; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.msg-row { display: flex; gap: 8px; align-items: flex-end; animation: msgIn 0.2s ease; max-width: 100%; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-row.own { flex-direction: row-reverse; }

.message {
  max-width: 72%; padding: 9px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.45; word-break: break-word; position: relative;
}
.message.sent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 6px; }
.message.received { background: var(--card); border: 1px solid var(--line); color: var(--text); border-bottom-left-radius: 6px; }
.message.view-once { border: 1px dashed var(--warn); }
.message.view-once::after {
  content: "Burn after reading"; display: block; font-size: 10px;
  color: var(--warn); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.message.hidden-content { opacity: 0.5; font-style: italic; color: var(--muted); background: transparent !important; border: 1px solid var(--line-2) !important; }
.message .edited-tag { font-size: 10px; opacity: 0.6; margin-left: 6px; font-style: italic; }

.msg-menu-btn {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 8px; border: 0; background: transparent; color: var(--muted);
  opacity: 0; transition: opacity 0.15s, background 0.15s, color 0.15s;
  align-self: center; flex-shrink: 0;
}
.msg-row:hover .msg-menu-btn { opacity: 1; }
.msg-menu-btn:hover { background: var(--line); color: var(--text); }

/* EDIT BAR */
.edit-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: rgba(77,124,255,0.08);
  border-top: 1px solid rgba(77,124,255,0.2);
  color: var(--accent); font-size: 12.5px; font-weight: 500;
  flex-shrink: 0;
}
.edit-bar button {
  margin-left: auto; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px; border: 0;
  background: transparent; color: var(--accent); transition: background 0.15s;
}
.edit-bar button:hover { background: rgba(77,124,255,0.15); }

/* COMPOSER */
.composer {
  display: flex; gap: 8px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--panel);
  flex-shrink: 0; align-items: center;
}
.composer input {
  flex: 1; padding: 12px 16px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 14.5px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s; min-width: 0;
}
.composer input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,124,255,0.12); }

#send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: grid; place-items: center; flex-shrink: 0;
  transition: all 0.2s ease; box-shadow: 0 4px 20px rgba(77,124,255,0.35);
}
#send-btn:hover { transform: scale(1.05); box-shadow: 0 6px 26px rgba(77,124,255,0.5); }
#send-btn:active { transform: scale(0.95); }

/* MODAL */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: grid; place-items: center; padding: 24px; z-index: 50;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease; overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; box-shadow: 0 0 100px rgba(77,124,255,0.08), 0 24px 60px rgba(0,0,0,0.8);
  animation: slideUp 0.25s cubic-bezier(.2,.9,.3,1.15);
  position: relative; overscroll-behavior: contain;
}
@keyframes slideUp { from { transform: translateY(24px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-close {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px; border: 0;
  background: rgba(0,0,0,0.5); color: var(--muted);
  transition: all 0.15s ease; flex-shrink: 0;
}
.modal-close:hover { background: var(--line); color: var(--text); }

.modal-box h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.modal-desc, .modal-box > p { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button {
  flex: 1; padding: 11px; border-radius: 9px;
  border: 1px solid var(--line); background: #1a1a22; color: var(--text);
  font-weight: 600; font-size: 13.5px; transition: all 0.15s ease;
}
.modal-actions button:hover { background: #232330; }
.modal-actions button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 20px rgba(77,124,255,0.35);
}

/* SETTINGS SHELL */
.settings-shell {
  display: grid;
  grid-template-columns: 180px 1fr;
  padding: 0; max-width: 680px; height: 560px; max-height: 92vh; overflow: hidden;
}
.settings-nav {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 8px;
  overflow-y: auto;
}
.settings-nav-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 12px; font-weight: 700; font-size: 13px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
}
.settings-nav-item {
  padding: 9px 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 500; text-align: left;
  transition: all 0.15s; cursor: pointer; margin-bottom: 2px;
}
.settings-nav-item:hover { background: var(--line); color: var(--text); }
.settings-nav-item.active { background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.settings-content { padding: 24px 26px; overflow-y: auto; position: relative; }
.settings-tab h2 { margin: 0 0 20px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.settings-section { margin-bottom: 20px; }
.settings-section label { margin-top: 0; }
.hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }
.hint-inline { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

input.readonly { opacity: 0.6; cursor: not-allowed; background: #04040a; }

.banner-wrap { position: relative; width: calc(100% + 52px); height: 130px; margin: -24px -26px 0; background: linear-gradient(135deg, #1a1a3a, #2a1a4a); overflow: hidden; }
.banner-edit {
  position: absolute; bottom: 10px; right: 10px;
  padding: 6px 12px; border-radius: 8px; border: 0;
  background: rgba(0,0,0,0.7); color: #fff;
  font-size: 11.5px; font-weight: 600;
  backdrop-filter: blur(6px); z-index: 2;
}
.banner-edit:hover { background: rgba(0,0,0,0.85); }

.settings-avatar-wrap {
  position: relative; width: 96px; height: 96px;
  margin: -48px auto 16px; z-index: 3;
}
.avatar-edit {
  position: absolute; bottom: 0; right: 0;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--card); background: var(--accent); color: #fff;
  display: grid; place-items: center; transition: transform 0.15s;
}
.avatar-edit:hover { transform: scale(1.1); }

.settings-fields { margin-top: 16px; }
.settings-fields label { margin-top: 14px; }
.settings-fields label:first-child { margin-top: 0; }

.presence-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.presence-picker button {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #06060c; color: var(--muted);
  font-weight: 500; font-size: 13px; transition: all 0.15s ease;
}
.presence-picker button:hover { border-color: var(--line-2); color: var(--text); }
.presence-picker button.active {
  border-color: var(--accent); color: var(--text);
  background: rgba(77,124,255,0.1);
  box-shadow: 0 0 0 3px rgba(77,124,255,0.15);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-online { background: var(--good); }
.dot-idle { background: var(--warn); }
.dot-dnd { background: var(--bad); }
.dot-offline { background: var(--offline); }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 14px 0; padding: 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 14px; font-weight: 500; gap: 12px;
}
.toggle-row > div:first-child { flex: 1; min-width: 0; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line-2); border-radius: 22px; transition: background 0.2s; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.settings-actions { display: flex; gap: 10px; margin-top: 18px; }
.settings-actions > button { flex: 1; }

/* PEER PROFILE */
.peer-box { padding: 0; max-width: 380px; overflow: hidden; }
.peer-box .modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  background: rgba(0,0,0,0.6);
}
.peer-banner { width: 100%; height: 120px; overflow: hidden; background: linear-gradient(135deg, #1a1a3a, #2a1a4a); }
.peer-avatar-wrap { position: relative; width: 88px; height: 88px; margin: -44px auto 0; z-index: 3; }
.peer-body { padding: 12px 26px 26px; text-align: center; }
.peer-body h2 { margin: 0 0 4px; font-size: 20px; }
.peer-username { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.peer-presence { margin: 0; font-size: 12.5px; font-weight: 600; }
.peer-custom {
  margin: 14px 0 0; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; color: var(--text);
  font-style: italic;
}
.peer-custom.hidden { display: none; }

/* REQUESTS */
.request-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.request-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line);
}
.request-item .logo-wrap { width: 34px; height: 34px; font-size: 14px; }
.request-item .req-name { flex: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-item button { padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; border: 0; }
.btn-accept { background: var(--good); color: #fff; }
.btn-decline { background: transparent; color: var(--muted); border: 1px solid var(--line-2) !important; }

/* PHRASE */
.phrase-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.phrase-grid code {
  background: #06060c; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 4px; text-align: center;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12.5px; letter-spacing: 0.05em; color: var(--text); user-select: all;
}
.checkline { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-size: 13px; color: var(--muted); cursor: pointer; }
.checkline input { width: auto; margin-top: 3px; accent-color: var(--accent); }

/* MSG MENU */
.msg-menu {
  position: fixed; z-index: 60;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 4px; box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: flex; flex-direction: column; min-width: 130px;
  animation: menuIn 0.15s ease;
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.msg-menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; text-align: left;
  transition: background 0.15s;
}
.msg-menu button:hover { background: var(--line); }
.msg-menu button.danger { color: var(--bad); }
.msg-menu button.danger:hover { background: rgba(239,68,68,0.12); }

/* TOASTS */
.toast-wrap {
  position: fixed; top: max(20px, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: calc(100% - 40px); max-width: 400px;
}
.toast {
  background: var(--card); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 16px; border-radius: 11px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  animation: toastIn 0.25s ease; pointer-events: auto;
}
.toast.error { border-color: rgba(239,68,68,0.5); }
.toast.success { border-color: rgba(34,197,94,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* MOBILE */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .chat-area { display: none; }
  .app.in-chat .sidebar { display: none; }
  .app.in-chat .chat-area { display: flex; }
  #back-btn { display: grid; }

  .auth-view { padding: 16px; align-items: flex-start; padding-top: max(32px, env(safe-area-inset-top)); }
  .auth-inner { padding: 26px 22px; border-radius: 18px; }
  .message { max-width: 82%; }
  .msg-menu-btn { opacity: 1; }

  .modal { padding: 0; align-items: stretch; }
  .modal-box {
    max-width: none; border-radius: 0; max-height: none;
    min-height: 100dvh; height: 100dvh;
    padding: 20px; padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .settings-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    max-width: none; height: 100dvh;
  }
  .settings-nav {
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 12px; padding-top: max(12px, env(safe-area-inset-top));
    flex-direction: row; overflow-x: auto; gap: 4px;
  }
  .settings-nav-header { padding: 0 6px 0 0; border-right: 1px solid var(--line); margin-right: 4px; flex-shrink: 0; }
  .settings-nav-header span { display: none; }
  .settings-nav-item { flex-shrink: 0; white-space: nowrap; }
  .settings-content { padding: 20px; }

  .banner-wrap { width: calc(100% + 40px); margin: -20px -20px 0; height: 110px; }
  .presence-picker { grid-template-columns: 1fr; }

  .peer-box {
    max-width: none; border-radius: 0;
    min-height: 100dvh; height: auto;
  }
  .peer-box .modal-close {
    top: max(12px, env(safe-area-inset-top)); right: 12px;
  }
}
