/* Quick Private Chat — app styles (v9) */
:root {
  --bg: #f5f6fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e3e7ef;
  --border-strong: #cfd6e3;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --primary-text: #ffffff;
  --accent: #0ea5e9;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warning: #b45309;
  --warning-soft: #fdf3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --own-bubble: linear-gradient(135deg, #4f46e5, #6d5cf6);
  --other-bubble: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
  --radius: 14px;
  --radius-lg: 20px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-soft: #111832;
  --surface: #141b31;
  --surface-2: #19213b;
  --text: #e8ecf6;
  --text-2: #c3cbdc;
  --muted: #8e99b3;
  --border: #253050;
  --border-strong: #33406a;
  --primary: #7c83ff;
  --primary-2: #8b91ff;
  --primary-soft: #222a52;
  --accent: #38bdf8;
  --success: #34d399;
  --success-soft: #12332a;
  --warning: #fbbf24;
  --warning-soft: #3a2d10;
  --danger: #f87171;
  --danger-soft: #3b1a1f;
  --own-bubble: linear-gradient(135deg, #5b5ff0, #7c5cf6);
  --other-bubble: #1b2440;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }

/* ---------- Screens ---------- */
#app { min-height: 100%; }
.screen { display: none; }
.screen.active { display: flex; }
#entry-screen { flex-direction: column; min-height: 100vh; }
#chat-screen { height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 650; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .05s, box-shadow .15s, border-color .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 16px rgba(79, 70, 229, .25); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-primary:disabled { opacity: .6; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { border-color: var(--primary); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-success { background: var(--success); color: #fff; }
[data-theme="dark"] .btn-success, [data-theme="dark"] .btn-danger { color: #0b1020; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn-danger-soft:hover { border-color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 11px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.active { background: var(--primary-soft); color: var(--primary); }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 13.5px; font-weight: 600; transition: border-color .15s, color .15s;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.chip-danger:hover { border-color: var(--danger); color: var(--danger); }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--primary); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------- Brand / topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px clamp(16px, 4vw, 40px); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--primary)); color: #fff; font-size: 17px; box-shadow: 0 6px 16px rgba(79, 70, 229, .3); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; }
.brand-text small { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.brand-small .brand-mark { width: 32px; height: 32px; font-size: 14px; border-radius: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Entry ---------- */
.entry-main {
  flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 40px;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 5vw, 64px); align-items: start;
}
.entry-intro { padding-top: 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: 12.5px; font-weight: 700; }
.entry-intro h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: -0.02em; margin: 16px 0 14px; }
.lead { font-size: 17px; color: var(--text-2); margin: 0 0 26px; max-width: 34em; }
.feature-list { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 14px; }
.feature-list li { display: flex; gap: 14px; align-items: flex-start; }
.feature-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.feature-list strong { display: block; font-size: 15px; }
.feature-list span { color: var(--muted); font-size: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; margin: 0; }
.notice i { color: var(--accent); margin-top: 3px; }

.entry-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: clamp(18px, 3vw, 28px); display: grid; gap: 16px;
}
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field-label small { font-weight: 500; color: var(--muted); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > i { position: absolute; left: 14px; color: var(--muted); font-size: 14px; pointer-events: none; }
.input-wrap input, textarea#report-text {
  width: 100%; min-height: 46px; padding: 10px 14px 10px 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea#report-text { padding: 12px 14px; resize: vertical; min-height: 110px; }
.input-wrap input:focus, textarea#report-text:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
.code-input input { text-transform: uppercase; letter-spacing: .18em; font-weight: 700; font-size: 17px; }
.code-input input::placeholder { letter-spacing: .18em; font-weight: 600; opacity: .55; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--bg-soft); border-radius: 13px; }
.tab-btn { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 650; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; gap: 14px; }
.tab-panel.active { display: grid; }

.size-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.size-opt { min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; font-size: 16px; }
.size-opt.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.my-code { display: grid; gap: 6px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border-strong); text-align: center; }
.my-code strong { font-size: 20px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.my-code-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.add-friend { border: 1px solid var(--border); border-radius: var(--radius); }
.add-friend summary { list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.add-friend summary::-webkit-details-marker { display: none; }
.add-friend summary::after { content: "\f078"; font-family: "Font Awesome 6 Free", "FontAwesome"; font-weight: 900; margin-left: auto; font-size: 11px; color: var(--muted); transition: transform .2s; }
.add-friend[open] summary::after { transform: rotate(180deg); }
.add-friend-body { display: grid; gap: 12px; padding: 0 14px 14px; }
.friend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }
.friend-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.friend-item .who { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.friend-item .who strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-item .who span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-note { text-align: center; color: var(--muted); font-size: 13.5px; padding: 14px 8px; }

.checks { display: grid; gap: 10px; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 16px; }
.checks-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--success); font-weight: 600; }
.checks-body { display: grid; gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.check-soft { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.check-soft strong { color: var(--text-2); }
.status-msg { min-height: 0; font-size: 14px; font-weight: 600; }
.status-msg:empty { display: none; }
.status-msg[data-type="error"] { color: var(--danger); }
.status-msg[data-type="warning"] { color: var(--warning); }
.status-msg[data-type="success"] { color: var(--success); }
.status-msg[data-type="info"] { color: var(--muted); }

.entry-footer { border-top: 1px solid var(--border); padding: 22px clamp(16px, 4vw, 40px) 30px; text-align: center; color: var(--muted); font-size: 13px; display: grid; gap: 8px; }
.entry-footer p { margin: 0; }
.footer-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- Avatars ---------- */
.avatar {
  --hue: 240; display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto;
  border-radius: 50%; background: hsl(var(--hue) 70% 92%); color: hsl(var(--hue) 55% 35%);
  font-weight: 750; font-size: 14.5px; text-transform: uppercase; user-select: none;
}
[data-theme="dark"] .avatar { background: hsl(var(--hue) 40% 25%); color: hsl(var(--hue) 80% 82%); }
.avatar-sm { width: 30px; height: 30px; font-size: 12.5px; }
.avatar-xl { width: 84px; height: 84px; font-size: 32px; }

/* ---------- Chat layout ---------- */
.sidebar {
  width: 290px; flex: 0 0 290px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px; overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.room-card { padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 8px; }
.room-code-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
#display-room-code { font-size: 26px; letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.capacity { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.room-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.room-card-actions .chip-btn { justify-content: center; padding: 0 8px; font-size: 13px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.count-pill { padding: 1px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--text-2); font-size: 12px; letter-spacing: 0; }
.people { flex: 1; min-height: 0; }
.member-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.member:hover { background: var(--surface-2); }
.member .avatar-wrap { position: relative; }
.presence { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--muted); }
.presence.status-online { background: var(--success); }
.presence.status-away { background: #f59e0b; }
.member .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.member .who strong { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .who span { font-size: 12px; color: var(--muted); }
.member .tag-call { color: var(--success); font-size: 12px; }
.add-friend-btn-small { width: 30px; height: 30px; border-radius: 9px; border: 0; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 12px; }
.add-friend-btn-small:disabled { background: var(--success-soft); color: var(--success); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sidebar-scrim { display: none; }
.mobile-only { display: none !important; }

.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); position: relative; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 62px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.chat-title h2 { margin: 0; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-status { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; color: var(--muted); }
.conn-dot { display: inline-block; vertical-align: 1px; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; margin-right: 2px; }
.conn-status.connected .conn-dot { background: var(--success); }
.conn-status.offline .conn-dot { background: var(--danger); }
.header-actions { display: flex; align-items: center; gap: 2px; }

.search-bar { display: none; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-bar.visible { display: flex; }
.search-bar > i { color: var(--muted); }
.search-bar input { flex: 1; border: 0; outline: none; background: transparent; min-height: 36px; }
.search-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- Messages ---------- */
.messages-wrap { flex: 1; min-height: 0; position: relative; }
.messages-container { position: absolute; inset: 0; overflow-y: auto; padding: 20px clamp(12px, 3vw, 28px) 12px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: auto; }
.empty-chat { margin: auto; text-align: center; color: var(--muted); max-width: 320px; padding: 20px; }
.empty-chat .empty-ico { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 26px; }
.empty-chat > span { display: block; }
.empty-chat strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty-chat .chip-btn { margin-top: 12px; }

.system-msg { align-self: center; max-width: 86%; margin: 8px 0; padding: 5px 12px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: 12.5px; text-align: center; }
.system-msg .msg-time { opacity: .75; }
.system-msg.warn { background: var(--warning-soft); color: var(--warning); }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: min(78%, 620px); margin-top: 10px; }
.msg-row.grouped { margin-top: 2px; }
.msg-row.own { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar { width: 30px; height: 30px; font-size: 12.5px; }
.msg-row.grouped .avatar { visibility: hidden; }
.msg-row.own .avatar { display: none; }
.message-bubble { position: relative; padding: 8px 12px 6px; border-radius: 18px; background: var(--other-bubble); border: 1px solid var(--border); box-shadow: var(--shadow-sm); min-width: 64px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-row.own .message-bubble { background: var(--own-bubble); color: #fff; border-color: transparent; }
.msg-row:not(.own) .message-bubble { border-bottom-left-radius: 6px; }
.msg-row.own .message-bubble { border-bottom-right-radius: 6px; }
.msg-row.grouped:not(.own) .message-bubble { border-top-left-radius: 6px; }
.msg-row.grouped.own .message-bubble { border-top-right-radius: 6px; }
.msg-sender { display: block; font-size: 12.5px; font-weight: 700; color: var(--primary); margin-bottom: 1px; }
.msg-row.grouped .msg-sender, .msg-row.own .msg-sender { display: none; }
.msg-text { white-space: pre-wrap; font-size: 15px; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: 11px; color: var(--muted); }
.msg-row.own .msg-meta { color: rgba(255, 255, 255, .78); }
.msg-ticks.delivered { color: #a5f3fc; }
.message-bubble.search-hit { box-shadow: 0 0 0 2px #f59e0b; }
.message-bubble.search-dim { opacity: .35; }
.message-bubble mark { background: #fde68a; color: #111; border-radius: 3px; padding: 0 1px; }

.scroll-to-bottom { position: absolute; right: 18px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); color: var(--text-2); display: grid; place-items: center; }
.unread-badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }

.typing-indicator { padding: 0 clamp(16px, 3vw, 32px); font-size: 12.5px; color: var(--muted); min-height: 0; }
.typing-indicator:not(:empty) { padding-bottom: 4px; min-height: 22px; }
.typing-dots span { animation: blink 1.2s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Composer ---------- */
.composer { position: relative; padding: 10px clamp(12px, 3vw, 24px) calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer-box { display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
#message-input { flex: 1; min-height: 40px; max-height: 140px; resize: none; border: 0; outline: none; background: transparent; padding: 9px 4px; line-height: 1.45; font-size: 15px; }
.send-btn { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; transition: opacity .15s, transform .1s; }
.send-btn:disabled { opacity: .35; }
.send-btn:not(:disabled):active { transform: scale(.94); }

.emoji-picker { position: absolute; left: clamp(12px, 3vw, 24px); bottom: calc(100% - 4px); width: min(360px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 8px; z-index: 30; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.emoji-tab-btn { flex: 0 0 auto; width: 36px; height: 34px; border-radius: 9px; border: 0; background: transparent; font-size: 17px; }
.emoji-tab-btn.active { background: var(--primary-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 210px; overflow-y: auto; padding-top: 6px; }
.emoji-grid button { height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: 21px; }
.emoji-grid button:hover { background: var(--bg-soft); }
.emoji-grid .empty-note { grid-column: 1 / -1; }

/* ---------- Calls ---------- */
.call-stage { background: #0b1020; padding: 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.tile-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.call-stage.voice .tile-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.tile { position: relative; border-radius: 16px; overflow: hidden; background: #151d36; aspect-ratio: 16 / 10; max-height: 34vh; display: grid; place-items: center; }
.call-stage.voice .tile { aspect-ratio: auto; height: 120px; }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile[data-peer-id="me"] video { transform: scaleX(-1); }
.tile .avatar { width: 64px; height: 64px; font-size: 24px; }
.call-stage.voice .tile .avatar { width: 56px; height: 56px; font-size: 21px; }
.tile.has-video .avatar { display: none; }
.tile.cam-off video { visibility: hidden; }
.tile.cam-off .avatar { display: grid; position: absolute; }
.tile-label { position: absolute; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12.5px; font-weight: 600; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-label .fa-microphone-slash { color: #fca5a5; }
.tile.connecting::after { content: "Connecting…"; position: absolute; top: 8px; right: 10px; color: rgba(255, 255, 255, .7); font-size: 11.5px; }
.call-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.call-label { color: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 600; margin-right: 6px; }
.call-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 17px; display: grid; place-items: center; transition: background .15s; }
.call-btn:hover { background: rgba(255, 255, 255, .2); }
.call-btn[aria-pressed="true"] { background: #fff; color: #0b1020; }
.call-end { background: var(--danger); width: 56px; }
.call-end:hover { background: #ef4444; }
.ringing { animation: ring 1.4s ease-in-out infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 50% { box-shadow: 0 0 0 16px rgba(22, 163, 74, 0); } }

/* ---------- Overlays ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .45); backdrop-filter: blur(4px); animation: fade .15s ease; }
.modal-card { width: min(100%, 460px); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; animation: pop .18s ease; }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.modal-card p { margin: 0 0 12px; color: var(--text-2); font-size: 14.5px; }
.modal-center { text-align: center; }
.modal-center h2 { justify-content: center; margin-top: 14px; }
.modal-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); font-size: 22px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-center .modal-actions { justify-content: center; }
.modal-center .modal-actions .btn { flex: 1; }
.modal-actions-stack { flex-direction: column; }
.bullets { margin: 0 0 6px; padding-left: 20px; color: var(--text-2); font-size: 14px; display: grid; gap: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.context-menu { position: fixed; z-index: 120; display: none; min-width: 150px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); }
.context-menu.visible { display: block; }
.context-menu button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 14px; }
.context-menu button:hover { background: var(--bg-soft); }

.toasts { position: fixed; z-index: 150; left: 50%; top: 16px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; background: #0f172a; color: #fff; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
[data-theme="dark"] .toast { background: #e8ecf6; color: #0b1020; }
.toast i { opacity: .85; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: all .2s; }

.cookie-banner { position: fixed; z-index: 90; left: 16px; right: 16px; bottom: 16px; max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; color: var(--text-2); }
.cookie-banner p { margin: 0; flex: 1; }
.cookie-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .entry-main { grid-template-columns: 1fr; gap: 24px; }
  .entry-intro { padding-top: 0; order: 2; }
  .entry-card { order: 1; }
  .entry-intro h1 { font-size: 26px; margin-top: 12px; }
  .lead { font-size: 15.5px; }
}

@media (max-width: 840px) {
  .mobile-only { display: inline-grid !important; }
  .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.active { transform: none; }
  .sidebar.active + .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .4); }
  .chat-header { padding: 8px 10px; gap: 6px; }
  .msg-row { max-width: 88%; }
  #btn-join-call .join-count { display: none; }
  #btn-join-call { padding: 0 10px; }
  .tile { max-height: 26vh; }
  .call-stage .tile-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  body { font-size: 14.5px; }
  .topbar { padding: 12px 14px; }
  .brand-text small { display: none; }
  #btn-install span { display: none; }
  .entry-main { padding: 4px 12px 28px; }
  .entry-card { padding: 16px; border-radius: 18px; }
  .header-actions .icon-btn { width: 36px; height: 36px; }
  .cookie-banner { flex-direction: column; align-items: stretch; }
  .cookie-actions .btn { flex: 1; }
  .call-btn { width: 44px; height: 44px; }
  .call-label { display: none; }
}

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

.direct-details { display: grid; gap: 12px; text-align: left; margin: 14px 0 4px; }
body.in-chat .cookie-banner { display: none; }
