* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b0f1a;
  --surface: rgba(18, 25, 45, 0.85);
  --surface2: rgba(25, 35, 60, 0.7);
  --accent: #00e5ff;
  --accent2: #b388ff;
  --text: #e0e6f0;
  --text2: #8899b0;
  --danger: #ff5252;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}
html, body { height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; overflow: hidden; }
body { background: radial-gradient(ellipse at 20% 50%, #0d1b2a 0%, #0b0f1a 70%); }

#app { height: 100dvh; position: relative; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }

/* ---- Brand ---- */
#brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 4px 0 16px; }
#brandLogo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 0 18px rgba(0,229,255,0.35); }
#brandName { font-size: 16px; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
#brandSub { font-size: 10px; color: var(--text2); letter-spacing: 2px; text-transform: uppercase; }

/* ---- Panes: mobile-first single pane, slide nav ---- */
.pane { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
#listPane { background: var(--surface); backdrop-filter: blur(20px); }
#chatPane { background: var(--bg); transform: translateX(100%); transition: transform .25s ease; }
#chatPane.active { transform: translateX(0); }

/* List header */
#listHeader { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-top: max(10px, env(safe-area-inset-top)); }
#identityMini { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* Contacts */
#contacts { flex: 1; overflow-y: auto; padding: 8px; padding-bottom: 80px; }
#contacts::-webkit-scrollbar { width: 4px; }
#contacts::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.contact-group { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; padding: 12px 12px 4px; }
.contact-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s; margin-bottom: 2px; }
.contact-item:active { background: var(--surface2); }
.contact-item.active { background: rgba(0,229,255,0.12); border: 1px solid rgba(0,229,255,0.2); }
.contact-name { font-weight: 500; }
.contact-status { width: 8px; height: 8px; border-radius: 50%; }
.contact-status.online { background: #00e676; box-shadow: 0 0 6px #00e67688; }
.contact-status.offline { background: var(--text2); }
.contact-empty { text-align: center; color: var(--text2); padding: 40px 20px; font-size: 13px; line-height: 1.8; }

/* Contact row: name + time / preview + unread */
.contact-main { flex: 1; min-width: 0; }
.contact-row1, .contact-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contact-row2 { margin-top: 2px; }
.contact-when { font-size: 11px; color: var(--text2); flex: 0 0 auto; }
.contact-preview { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #000; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.warn-dot { font-size: 12px; }

/* Verification: safety number + key-change alert */
.shield { background: none; border: none; font-size: 15px; cursor: pointer; padding: 4px;
  min-width: 32px; min-height: 32px; line-height: 1; }
.shield.warn { animation: pulse 1.4s infinite; }
.safety-number { font-family: 'SF Mono','Fira Code',ui-monospace,monospace; font-size: 16px; line-height: 2;
  letter-spacing: 2px; text-align: center; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  user-select: all; word-spacing: 8px; }
.sn-hint { font-size: 12px; }
.key-alert { background: rgba(255,82,82,0.12); border: 1px solid rgba(255,82,82,0.5); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: 13px; line-height: 1.6; color: var(--text); }
.key-alert button { margin-top: 10px; width: 100%; }

/* Day separators + inline media thumbnails */
.day-sep { text-align: center; margin: 10px 0 4px; }
.day-sep span { font-size: 11px; color: var(--text2); background: var(--surface2);
  padding: 3px 10px; border-radius: 10px; }
.msg-thumb { display: block; margin-top: 8px; max-width: 100%; border-radius: var(--radius-sm); }

/* Scan FAB */
.btn-scan-fab { position: absolute; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  padding: 14px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #000; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,229,255,0.25); }

/* Chat header */
#chatHeader { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface); backdrop-filter: blur(20px); border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-top: max(10px, env(safe-area-inset-top)); }
#chatTitle { flex: 1; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e2ee-badge { font-size: 11px; color: var(--accent); font-weight: 400; margin-left: 8px; }
#callButtons { display: flex; gap: 8px; }
#callButtons.hidden { display: none; }
.btn-back { font-size: 26px; }

/* Messages */
#chatMsgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
#chatMsgs::-webkit-scrollbar { width: 6px; }
#chatMsgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: var(--radius); animation: msgIn .2s ease; word-break: break-word; }
.msg.mine { align-self: flex-end; background: linear-gradient(135deg, rgba(0,229,255,0.2), rgba(179,136,255,0.2)); border: 1px solid rgba(0,229,255,0.15); box-shadow: 0 4px 16px rgba(0,229,255,0.08); }
.msg.theirs { align-self: flex-start; background: var(--surface2); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.06); }
.msg-text { word-break: break-word; }
.msg-media { word-break: break-word; color: var(--accent); }
.msg-time { font-size: 10px; color: var(--text2); margin-top: 4px; text-align: right; }
.btn-decrypt { margin-top: 6px; padding: 6px 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; min-height: 40px; }
.btn-decrypt:active { background: rgba(0,229,255,0.1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Input */
#chatInput { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface); backdrop-filter: blur(20px); border-top: 1px solid rgba(255,255,255,0.06);
  padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#msgInput { flex: 1; padding: 12px 14px; border: 1px solid rgba(255,255,255,0.1); border-radius: 24px; background: rgba(255,255,255,0.05); color: var(--text); font-size: 16px; outline: none; transition: border-color .2s; min-height: 44px; }
#msgInput:focus { border-color: var(--accent); }
#msgInput::placeholder { color: var(--text2); }

/* Buttons — all ≥44px for touch */
.btn-icon { min-width: 44px; min-height: 44px; border: none; border-radius: 50%; background: transparent; color: var(--text2); cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.btn-icon:active { background: var(--surface2); color: var(--text); }
.btn-send { min-width: 44px; min-height: 44px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #000; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-send:active { transform: scale(.95); }
.btn-danger { padding: 10px 16px; border: none; border-radius: var(--radius-sm); background: var(--danger); color: #fff; font-weight: 600; cursor: pointer; font-size: 13px; min-height: 40px; }
.btn-primary { padding: 10px 16px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #000; font-weight: 600; cursor: pointer; font-size: 14px; min-height: 44px; }
.btn-secondary { padding: 10px 16px; border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm); background: transparent; color: var(--text); cursor: pointer; font-size: 14px; min-height: 44px; }

/* Status dot */
.status-online { background: #00e676 !important; box-shadow: 0 0 8px #00e67688; }
.status-reconnecting { background: #ffab00 !important; box-shadow: 0 0 8px #ffab0088; animation: pulse 1s infinite; }
.status-offline { background: #ff5252 !important; }
#statusDot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 10px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ---- Sheets (profile + modal) — bottom sheet on mobile, centered desktop ---- */
/* Above the onboarding/lock overlays (400): a modal is always on top of
   whatever spawned it — the upgrade flow opens one from an onboarding step. */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 500; display: flex; align-items: flex-end; justify-content: center; }
.sheet.hidden { display: none; }
.sheet-card { width: 100%; max-width: 480px; background: var(--surface); backdrop-filter: blur(20px);
  border-radius: 16px 16px 0 0; padding: 12px 20px max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.1); animation: sheetUp .25s ease; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.2); margin: 0 auto 16px; }
.sheet-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.sheet-body { font-size: 14px; color: var(--text2); margin-bottom: 14px; }
.sheet-input { width: 100%; padding: 14px; border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm); background: rgba(255,255,255,0.05); color: var(--text); font-size: 16px; outline: none; min-height: 44px; }
.sheet-input:focus { border-color: var(--accent); }
.sheet-toggles { margin: 10px 0; }
.sheet-toggle { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions button { flex: 1; }

/* Identity (inside profile sheet) */
#identity { text-align: center; padding-bottom: 10px; }
.identity-header { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
#identityName, #identityName2 { font-size: 18px; font-weight: 600; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
#identityQr { display: block; margin: 0 auto 8px; border-radius: var(--radius-sm); background: rgba(0,0,0,0.3); padding: 6px; box-shadow: 0 0 20px rgba(0,229,255,0.12); width: 200px; height: 200px; }
.fingerprint { font-size: 11px; color: var(--text2); font-family: 'SF Mono', 'Fira Code', monospace; margin-bottom: 12px; word-break: break-all; }
.settings-row { display: flex; justify-content: center; gap: 16px; margin-bottom: 14px; }
.setting { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; min-height: 44px; }
.setting input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Call panel */
#callPanel { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#callPanel.hidden { display: none; }
#callVideos { position: relative; width: 100%; max-width: 800px; aspect-ratio: 16/9; }
#remoteVideo { width: 100%; height: 100%; border-radius: var(--radius); object-fit: cover; background: #000; }
#localVideo { position: absolute; bottom: 16px; right: 16px; width: 120px; border-radius: var(--radius-sm); object-fit: cover; border: 2px solid rgba(255,255,255,0.2); background: #000; }
#callControls { display: flex; gap: 16px; margin-top: 20px; align-items: center; }
.call-quality { margin-top: 12px; font-family: 'SF Mono','Fira Code',ui-monospace,monospace; font-size: 12px;
  color: var(--text2); letter-spacing: 2px; min-height: 16px; }
.call-quality.q3 { color: #00e676; } .call-quality.q2 { color: #ffab00; } .call-quality.q1 { color: var(--danger); }

/* Scan overlay */
#scanOverlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 200; display: flex; align-items: center; justify-content: center; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#scanOverlay.hidden { display: none; }
#scanFrame { position: relative; width: 80vw; max-width: 300px; aspect-ratio: 1; }
#scanVideo { width: 100%; height: 100%; border-radius: var(--radius); object-fit: cover; }
#scanFrame::before { content: ''; position: absolute; inset: -8px; border-radius: 18px; background: linear-gradient(135deg, rgba(0,229,255,0.35), rgba(179,136,255,0.35)); z-index: -1; filter: blur(6px); }
#scanGuide { position: absolute; bottom: -36px; left: 0; right: 0; text-align: center; color: var(--text2); font-size: 13px; }
#btnScanClose { position: absolute; top: 8px; right: 8px; }

/* ---- Onboarding / lock screen (full-screen, blocking) ---- */
.ob, .lock-screen { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #12203a 0%, var(--bg) 70%);
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); overflow-y: auto; }
.ob-card, .lock-card { width: 100%; max-width: 420px; text-align: center; }
.ob-icon, .lock-icon { font-size: 52px; line-height: 1; margin-bottom: 18px; }
.ob-title, .lock-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; letter-spacing: -.02em; }
.ob-body, .lock-body { font-size: 15px; color: var(--text2); line-height: 1.6; margin-bottom: 24px; }
.ob-input { width: 100%; padding: 15px; border: 1px solid rgba(255,255,255,0.14); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); color: var(--text); font-size: 16px; outline: none; min-height: 48px; margin-bottom: 20px; text-align: center; }
.ob-input:focus { border-color: var(--accent); }
.ob-code { font-family: 'SF Mono','Fira Code',ui-monospace,monospace; font-size: 17px; letter-spacing: 1px; line-height: 2;
  background: rgba(0,229,255,0.07); border: 1px dashed rgba(0,229,255,0.4); border-radius: var(--radius);
  padding: 18px 12px; margin-bottom: 12px; word-break: break-all; color: var(--accent); user-select: all; }
.ob-copy { width: 100%; margin-bottom: 18px; }
.ob-check { display: flex; align-items: flex-start; gap: 10px; text-align: left; font-size: 13px; color: var(--text2);
  margin-bottom: 20px; line-height: 1.5; cursor: pointer; }
.ob-check input { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; accent-color: var(--accent); }
.ob-actions { display: flex; flex-direction: column; gap: 10px; }
.ob-actions button { width: 100%; }
.ob-actions .btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.lock-btn { width: 100%; margin-bottom: 14px; }
.lock-link { background: none; border: none; color: var(--text2); font-size: 14px; cursor: pointer;
  text-decoration: underline; min-height: 44px; }
.lock-link:active { color: var(--text); }

/* Privacy scrim while backgrounded — content hidden from the app-switcher snapshot */
body.scrim #app { filter: blur(18px); pointer-events: none; }

/* Toast */
#toast { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); right: 24px; padding: 12px 20px; border-radius: var(--radius-sm); background: var(--surface); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); color: var(--text); font-size: 13px; box-shadow: var(--shadow); transform: translateY(100px); opacity: 0; transition: transform .3s ease, opacity .3s ease; z-index: 300; max-width: calc(100vw - 48px); }
#toast.show { transform: translateY(0); opacity: 1; }

/* ---- Desktop: side-by-side panes, sheets centered ---- */
@media (min-width: 721px) {
  #app { display: flex; flex-direction: row; padding: 0; }
  .pane { position: relative; inset: auto; height: 100dvh; }
  #listPane { width: 320px; min-width: 320px; border-right: 1px solid rgba(255,255,255,0.06); }
  #chatPane { flex: 1; transform: none; }
  #chatPane.active { transform: none; }
  .btn-back { display: none; }
  .sheet { align-items: center; }
  .sheet-card { max-width: 420px; border-radius: 16px; }
  #identityQr { width: 180px; height: 180px; }
}

/* Contact removal + settings */
.sheet-remove { width: 100%; margin-top: 10px; }
.settings-row .setting { flex: 1; }
.sheet-icon { font-size: 40px; text-align: center; margin-bottom: 8px; line-height: 1; }
.q-bars { letter-spacing: 2px; }
.q-path { font-size: 11px; opacity: .85; }
.q-path.degraded { color: #ffab00; }

/* Avatars — hue derived from the key hash, stable without storage */
.avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; margin-right: 12px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
  color: #fff; background: linear-gradient(135deg, hsl(var(--h) 65% 45%), hsl(calc(var(--h) + 35) 60% 38%));
  text-shadow: 0 1px 2px rgba(0,0,0,.3); user-select: none; }

/* Message grouping: only the last bubble of a run gets a tail + timestamp */
.msg.grouped { margin-bottom: -4px; }
.msg.mine.run-start { border-top-right-radius: var(--radius); }
.msg.mine:not(.run-end) { border-bottom-right-radius: 6px; }
.msg.mine.run-end { border-bottom-right-radius: 4px; }
.msg.theirs:not(.run-end) { border-bottom-left-radius: 6px; }
.msg.theirs.run-end { border-bottom-left-radius: 4px; }
.msg:not(.run-start) { margin-top: -4px; }
.lock-danger { color: var(--danger); opacity: .8; }
#btnReset { width: 100%; margin-top: 6px; }

/* ---- Search ---- */
#searchBar { padding: 8px 12px 0; }
.search-input { width: 100%; min-height: 44px; padding: 10px 14px; font-size: 16px;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 22px; background: rgba(255,255,255,0.05);
  color: var(--text); outline: none; transition: border-color .2s; -webkit-appearance: none; appearance: none; }
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text2); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center/12px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center/12px no-repeat; }

/* ---- Pin / mute markers + archived section ---- */
.contact-flags { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; font-size: 11px; line-height: 1; }
.contact-item.pinned { background: rgba(255,255,255,0.03); }
.contact-item.muted .contact-preview { opacity: .65; }
.archive-toggle { display: block; width: 100%; text-align: left; border: none; background: none;
  font: inherit; font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px;
  padding: 12px; min-height: 44px; cursor: pointer; }
.archive-toggle:active { color: var(--text); }
.contact-item.archived { opacity: .72; }

/* ---- Long-press action sheet ---- */
.action-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.action-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 12px 14px; border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04); color: var(--text); font-size: 15px; text-align: left; cursor: pointer; }
.action-btn:active { background: var(--surface2); }
.action-btn.danger { color: var(--danger); border-color: rgba(255,82,82,0.35); }
.action-cancel { width: 100%; }

/* ---- Full-screen incoming call ---- */
#incomingCall { position: fixed; inset: 0; z-index: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  background: radial-gradient(ellipse at 50% 0%, #16273f 0%, var(--bg) 70%);
  padding: max(48px, calc(env(safe-area-inset-top) + 32px)) 24px max(32px, calc(env(safe-area-inset-bottom) + 20px)); }
#incomingCall.hidden { display: none; }
.inc-top { display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; margin-top: auto; }
.inc-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--text2); }
.inc-avatar { flex: 0 0 auto; width: 128px; height: 128px; margin: 6px 0 4px; font-size: 52px;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.05), 0 12px 40px rgba(0,0,0,.5); animation: incPulse 2s ease-in-out infinite; }
@keyframes incPulse { 0%, 100% { box-shadow: 0 0 0 6px rgba(255,255,255,0.05), 0 12px 40px rgba(0,0,0,.5); }
                      50% { box-shadow: 0 0 0 18px rgba(255,255,255,0.02), 0 12px 40px rgba(0,0,0,.5); } }
.inc-name { font-size: 28px; font-weight: 700; letter-spacing: -.02em; word-break: break-word; }
.inc-kind { font-size: 16px; color: var(--text2); }
.inc-e2ee { font-size: 12px; color: var(--accent); opacity: .8; }
.inc-actions { display: flex; gap: 28px; justify-content: center; width: 100%;
  max-width: 420px; margin-top: auto; padding-top: 40px; }
.inc-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px;
  border: none; background: none; color: var(--text); font-size: 13px; cursor: pointer;
  min-height: 44px; padding: 4px; }
.inc-glyph { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 30px; }
.inc-accept .inc-glyph { background: #00c853; box-shadow: 0 6px 24px rgba(0,200,83,.4); }
.inc-decline .inc-glyph { background: var(--danger); box-shadow: 0 6px 24px rgba(255,82,82,.35); }
.inc-btn:active .inc-glyph { transform: scale(.94); }
.inc-cap { color: var(--text2); }
@media (min-height: 700px) { .inc-actions { padding-bottom: 24px; } }

/* ---- Call history entries (local-only, tappable to call back) ---- */
.msg.call-entry { align-self: center; max-width: 88%; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.07); color: var(--text2); font-size: 12.5px; cursor: pointer;
  margin: 4px 0; }
.msg.call-entry:active { background: rgba(255,255,255,0.08); }
.msg.call-entry.missed { color: var(--danger); border-color: rgba(255,82,82,0.35); background: rgba(255,82,82,0.08); }
.call-glyph { font-size: 14px; line-height: 1; }
.call-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-when { font-size: 10px; opacity: .7; flex: 0 0 auto; }

/* ---- Blur-up media placeholder ---- */
/* The tiny preview is generated locally from the decrypted bytes and stored on
   the message; the full image fades in over it once decoded. */
.thumb-wrap { position: relative; margin-top: 8px; border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(255,255,255,0.04); }
.msg-blur { display: block; width: 100%; filter: blur(10px); transform: scale(1.1); }
.thumb-wrap .msg-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  margin: 0; opacity: 0; transition: opacity .3s ease; }
.thumb-wrap .msg-thumb.loaded { opacity: 1; }
.thumb-wrap.locked::after { content: '🔒'; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; font-size: 26px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
@media (prefers-reduced-motion: reduce) {
  .thumb-wrap .msg-thumb { transition: none; }
  .inc-avatar { animation: none; }
}
/* ---- Receipts, typing, replies, reactions ---- */

/* Ticks: ⋯ pending, ✓ delivered, ✓✓ read. Own messages only. They sit inside the
   run's timestamp when there is one, so grouped runs need their own thin row. */
.ticks { font-size: 10px; margin-left: 5px; color: var(--text2); letter-spacing: -1px; }
.ticks.read { color: var(--accent); }
.ticks.pending { opacity: .6; }
.msg-ticks { font-size: 10px; text-align: right; margin-top: 2px; line-height: 1; }
.shield.rr { font-size: 12px; letter-spacing: -2px; color: var(--accent); opacity: .9; }
.shield.rr.off { color: var(--text2); opacity: .45; text-decoration: line-through; }

/* Quoted reply — inside the bubble above the text, and in the composer bar */
.msg-quote { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; padding: 5px 9px;
  border-left: 3px solid var(--accent); border-radius: 4px; background: rgba(255,255,255,0.06);
  cursor: pointer; min-width: 0; }
.quote-who { font-size: 11px; font-weight: 600; color: var(--accent); }
.quote-text { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.flash { animation: quoteFlash 1.2s ease; }
@keyframes quoteFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 2px var(--accent); } }

.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--surface); border-top: 1px solid rgba(255,255,255,0.06); }
.reply-bar.hidden { display: none; }
.reply-bar .msg-quote { flex: 1; margin-bottom: 0; cursor: default; }

/* Reactions: chips under the bubble, plus the long-press picker */
.rx-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rx-chip { padding: 1px 7px; border-radius: 10px; font-size: 12px; line-height: 18px; cursor: pointer;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); color: var(--text); }
.rx-chip.mine { background: rgba(0,229,255,0.16); border-color: rgba(0,229,255,0.4); }
.rx-picker { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.rx-pick { flex: 1; min-height: 48px; font-size: 24px; border: none; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); cursor: pointer; }
.rx-pick:active { background: rgba(0,229,255,0.15); transform: scale(.92); }
.rx-target { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Typing indicator — three dots, not a message bubble */
.typing-ind { align-self: flex-start; display: flex; gap: 4px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface2); border: 1px solid rgba(255,255,255,0.06); width: fit-content; }
.typing-ind span { width: 6px; height: 6px; border-radius: 50%; background: var(--text2);
  animation: typingDot 1.2s infinite ease-in-out; }
.typing-ind span:nth-child(2) { animation-delay: .18s; }
.typing-ind span:nth-child(3) { animation-delay: .36s; }
@keyframes typingDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
