/**
 * OS — views.css
 * Page-level styles: landing, auth, app shell views
 * (chats, conversation, media, audio, settings), media viewer.
 */

/* ============================== Landing ============================== */
.landing {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 18px) 16px 40px;
}
.hero-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.hero-mark .word { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.hero h1 {
  font-size: 34px;
  line-height: 1.13;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { color: var(--muted); font-size: 15.5px; line-height: 1.55; max-width: 42ch; }
.hero-actions { display: flex; gap: 10px; margin: 22px 0 10px; }
.hero-actions .btn { flex: 1; }
.feat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.feat { padding: 15px 14px; border-radius: var(--radius-lg); }
.feat svg { width: 21px; height: 21px; color: var(--accent); margin-bottom: 10px; }
.feat b { display: block; font-size: 13.5px; font-weight: 750; margin-bottom: 3px; letter-spacing: -0.01em; }
.feat span { font-size: 12px; color: var(--muted); line-height: 1.45; display: block; }
.editions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.ed {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 14px;
  display: flex; align-items: center; gap: 11px;
  transition: transform 0.12s ease;
}
.ed:active { transform: scale(0.98); }
.ed > span:nth-child(2) { flex: 1; min-width: 0; }
.ed > span:nth-child(2) b { display: block; font-size: 13.5px; white-space: nowrap; }
.ed > span:nth-child(2) > span { font-size: 11.5px; color: var(--muted); display: block; }
.ed .sw { width: 34px; height: 34px; border-radius: 11px; flex: none; border: 1px solid var(--line); }
.ed .sw.light { background: linear-gradient(160deg, #FFFFFF, #DfE3EA); }
.ed .sw.dark { background: linear-gradient(160deg, #232329, #060608); }
.ed b { display: block; font-size: 13.5px; }
.ed span { font-size: 11.5px; color: var(--muted); }
.ed .go { margin-left: auto; color: var(--faint); }
.fineprint { color: var(--faint); font-size: 11.5px; line-height: 1.6; margin-top: 26px; padding: 0 4px; }

/* ============================== Auth ============================== */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}
.auth-card { width: 100%; max-width: 400px; padding: 24px 20px 20px; }
.auth-card h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin: 16px 0 4px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-alt { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.auth-alt a { color: var(--accent); font-weight: 700; }
.demo-link { text-align: center; margin-top: 10px; }
.demo-link a { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.form-error {
  background: var(--bad-soft); color: var(--bad);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  padding: 10px 12px; margin: 0;
}

/* ============================== App shell ============================== */
.app-main {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px) 12px
           calc(var(--dock-h) - 16px + env(safe-area-inset-bottom));
  max-width: 620px;
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.22s ease both; }

/* ============================== Chats ============================== */
.chat-list { display: flex; flex-direction: column; gap: 2px; }
.typing { display: inline-flex; gap: 3px; align-items: center; height: 12px; }
.typing i { width: 5px; height: 5px; border-radius: 99px; background: var(--muted); animation: tp 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tp { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* Conversation overlay */
.conv {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--bg);
  transform: translateX(102%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0.25, 1);
  visibility: hidden;
}
.conv.open { transform: translateX(0); visibility: visible; }
.conv-head {
  display: flex; align-items: center; gap: 6px;
  padding: env(safe-area-inset-top) 8px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.conv-head .who { flex: 1; min-width: 0; }
.conv-head .who b { display: block; font-size: 14.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-head .who span { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.conv-head .who span .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); display: inline-block; }
.conv-head .who span .dot.wait { background: var(--warn); }
.conv-head .who span .dot.bad { background: var(--bad); }
/* live presence in the header: peer typing / sending / recording */
.conv-head .who span.live { color: var(--accent); font-weight: 600; }
.tdots { display: inline-flex; align-items: flex-end; gap: 3px; margin-left: 1px; }
.tdots b { width: 4px; height: 4px; border-radius: 99px; background: currentColor; animation: tdot-bounce 1.2s infinite ease-in-out; }
.tdots b:nth-child(2) { animation-delay: 0.15s; }
.tdots b:nth-child(3) { animation-delay: 0.3s; }
@keyframes tdot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tdots b { animation: none; opacity: 0.8; }
}
/* WhatsApp-style round photo avatar in the conversation header */
.conv-head .ava { width: 44px; height: 44px; border-radius: 999px; font-size: 15px; }
.conv-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.day-sep { text-align: center; font-size: 11px; font-weight: 750; color: var(--faint); margin: 14px 0 8px; letter-spacing: 0.04em; }
.sysmsg { text-align: center; font-size: 11px; color: var(--faint); margin: 6px 12%; line-height: 1.5; }
.sysmsg b { color: var(--muted); }
.msg { max-width: 82%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.peer { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 9px 12px;
  border-radius: 17px;
  font-size: 14.5px;
  line-height: 1.42;
  background: var(--bubble-peer);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 6px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg.mine .bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-fg);
  border: 0;
  border-bottom-right-radius: 6px;
}
/* v2.8.22: links inside message bubbles — new tab on the web, default
 * browser outside the app in the APK shell (target=_blank anchors). */
.bubble a.os-link {
  color: inherit;
  font-weight: 620;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2.5px;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
.bubble a.os-link:active { opacity: 0.72; }
.msg .stamp { font-size: 10px; color: var(--faint); margin: 4px 6px 0; display: flex; align-items: center; gap: 3px; }
.msg .stamp svg { width: 12px; height: 12px; }
.bubble.media-b { padding: 4px; border-radius: 17px; background: var(--card); }
.bubble.media-b img, .bubble.media-b video { outline: none; -webkit-tap-highlight-color: transparent; }
.bubble.media-b img { border-radius: 14px; width: 218px; height: auto; display: block; }
.bubble.media-b video { border-radius: 14px; width: 218px; display: block; }
.bubble.media-b audio { border-radius: 14px; width: 218px; display: block; outline: none; }

/* Voice-note bubble */
.vb { display: flex; align-items: center; gap: 9px; min-width: 200px; padding: 8px 12px 8px 8px; }
.vb .play {
  width: 34px; height: 34px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bubble-mine); color: var(--accent-fg);
}
.msg.peer .vb .play { background: var(--accent); }
.vb .play svg { width: 15px; height: 15px; }
.vb canvas { flex: 1; height: 26px; min-width: 0; }
.vb .vd { font-size: 10.5px; font-variant-numeric: tabular-nums; color: inherit; opacity: 0.75; flex: none; }

/* Custom file-attachment bubble (one-shot transfer) */
.fileb { display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 250px; padding: 10px 12px; cursor: pointer; }
.fileb .file-ic {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bubble-mine); color: var(--accent-fg);
}
.fileb.mine .file-ic { background: rgba(255, 255, 255, 0.22); color: inherit; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-meta .file-name { font-size: 13.5px; font-weight: 650; line-height: 1.25; word-break: break-word; }
.file-meta .file-sub { font-size: 10.5px; opacity: 0.72; line-height: 1.3; }
.fileb .file-dl {
  width: 32px; height: 32px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid currentColor; opacity: 0.85; transition: opacity 0.12s ease, transform 0.12s ease;
}
.fileb .file-dl:hover { opacity: 1; transform: translateY(-1px); }
.fileb .file-dl:disabled { opacity: 0.4; }
.fileb .file-dl svg { width: 15px; height: 15px; }

/* Composer */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line);
  background: var(--field); border-radius: 20px;
  padding: 10px 14px; font-size: 15px; line-height: 1.35;
  max-height: 110px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  background: var(--accent); color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.4; }
.send-btn svg { width: 18px; height: 18px; }
.mic-btn.rec { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--bad-soft); } 50% { box-shadow: 0 0 0 9px var(--bad-soft); } }
.rec-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(74px + env(safe-area-inset-bottom));
}

/* Composer side buttons (attach / mic) */
.comp-btn {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--field); color: var(--fg-muted, var(--fg));
  border: 1px solid var(--line);
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}
.comp-btn:active { transform: scale(0.9); }
.comp-btn:disabled { opacity: 0.4; }
.comp-btn svg { width: 18px; height: 18px; }

/* Upload-in-progress bubble */
.bubble.pend-b { min-width: 190px; padding: 10px 12px; }
.bubble.pend-b .up-label { font-size: 12px; font-weight: 600; opacity: 0.85; margin-bottom: 7px; }
.up-track { height: 4px; border-radius: 999px; background: var(--pill-line); overflow: hidden; }
.up-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.2s ease; }

/* Recording hint (positioning lives with the composer rules above) */
.rec-hint { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; white-space: nowrap; }
.rec-hint b { font-size: 12px; }
.rec-hint .rec-time { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-hint .rec-tip { font-size: 11px; opacity: 0.7; }
.rec-hint::before { content: ''; width: 8px; height: 8px; border-radius: 99px; background: var(--bad); animation: recblink 1.1s infinite; }
@keyframes recblink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Attach sheet grid */
.att-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.att-grid button { border-radius: var(--radius-md); overflow: hidden; position: relative; }
.att-grid img, .att-grid video { width: 100%; aspect-ratio: 1; object-fit: cover; }
.att-grid .tag { position: absolute; left: 6px; bottom: 6px; font-size: 10px; font-weight: 800; background: rgba(0,0,0,.55); color: #fff; padding: 3px 7px; border-radius: 99px; }

/* ============================== Media view ============================== */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--pill); border-radius: 12px;
  border: 1px solid var(--pill-line);
}
.seg button {
  flex: 1; padding: 8px 10px; border-radius: 9px;
  font-size: 12.5px; font-weight: 750; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid button { position: relative; border-radius: 6px; overflow: hidden; aspect-ratio: 1; }
.media-grid img, .media-grid video { width: 100%; height: 100%; object-fit: cover; }
.media-grid .kind {
  position: absolute; right: 6px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 800; color: #fff;
  background: rgba(0, 0, 0, 0.55); padding: 3px 6px; border-radius: 7px;
  backdrop-filter: blur(4px);
}
.media-grid .kind svg { width: 10px; height: 10px; }
.media-grid .vault-file {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; padding: 8px;
  background: var(--card); text-align: center;
}
.media-grid .vault-file-ic { color: var(--accent); }
.media-grid .vault-file-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.media-grid .vault-file-meta b { font-size: 10.5px; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-grid .vault-file-meta span { font-size: 9px; opacity: 0.6; }

/* Viewer */
.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 3, 5, 0.96);
  display: none; flex-direction: column;
  opacity: 0; transition: opacity 0.2s ease;
}
.viewer.open { display: flex; opacity: 1; }
.viewer-top {
  display: flex; align-items: center; gap: 10px;
  padding: env(safe-area-inset-top) 10px 10px;
  color: #fff;
}
.viewer-top .who { flex: 1; min-width: 0; }
.viewer-top .who b { display: block; font-size: 14px; }
.viewer-top .who span { font-size: 11.5px; color: rgba(255,255,255,0.6); }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-height: 0; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; border-radius: 10px; }
.viewer-doc { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #cbd3e1; padding: 24px; text-align: center; }
.viewer-doc p { max-width: 300px; font-size: 12.5px; line-height: 1.5; opacity: 0.85; }
.viewer-cap {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px; display: flex; align-items: center; gap: 10px;
}
.viewer-cap .cap-text { flex: 1; line-height: 1.45; }
.viewer .icon-btn { color: #fff; }

/* ============================== Audio view ============================== */
.rec-card { display: flex; flex-direction: column; align-items: center; padding: 20px 16px 18px; gap: 12px; }
.rec-btn {
  width: 74px; height: 74px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px -8px var(--accent);
  transition: transform 0.12s ease;
}
.rec-btn:active { transform: scale(0.94); }
.rec-btn.rec { background: var(--bad); animation: pulse 1.2s infinite; }
.rec-btn svg { width: 30px; height: 30px; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 800; letter-spacing: 0.02em; }
.rec-state { font-size: 12px; color: var(--muted); font-weight: 650; }

/* Audio row player */
.audio-row { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: var(--radius-md); width: 100%; text-align: left; }
.audio-row + .audio-row { margin-top: 4px; }
.audio-row:active { background: var(--pill); }
.audio-row .play {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.audio-row .play svg { width: 17px; height: 17px; }
.audio-row.playing .play { background: var(--accent); color: var(--accent-fg); }
.audio-row .aw { flex: 1; min-width: 0; }
.audio-row .aw b { display: block; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-row .aw span { font-size: 11px; color: var(--faint); font-weight: 600; }
.audio-row canvas { width: 100%; height: 22px; display: block; margin-top: 5px; }
.audio-row .dur { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }

/* ============================== Settings ============================== */
.set-profile { display: flex; align-items: center; gap: 14px; padding: 16px; }
.set-profile .who b { font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 7px; }
.set-profile .who span { font-size: 12.5px; color: var(--muted); }
.ava-edit {
  position: relative; flex: none;
  width: 64px; height: 64px; padding: 0;
  border-radius: 20px; cursor: pointer;
}
.ava-edit .ava { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; }
.ava-cam {
  position: absolute; right: -5px; bottom: -5px;
  width: 24px; height: 24px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
  border: 2.5px solid var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
}
.ava-cam svg { width: 12px; height: 12px; }
.prof-actions { display: flex; gap: 8px; margin: 12px 0 12px; padding: 0 16px; }
.prof-actions .btn { flex: none; }
.set-group { padding: 6px 12px; }
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; width: 100%; text-align: left;
  border-radius: var(--radius-md);
}
.set-row + .set-row { border-top: 1px solid var(--line-soft); }
.set-row .ic {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.set-row .ic svg { width: 17px; height: 17px; }
.set-row .tx { flex: 1; min-width: 0; }
.set-row .tx b { display: block; font-size: 14px; font-weight: 700; }
.set-row .tx span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.set-row .val { font-size: 12.5px; color: var(--faint); font-weight: 650; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--pill); border: 1px solid var(--pill-line);
  transition: background 0.18s ease;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 999px; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s cubic-bezier(0.32, 0.72, 0.25, 1);
}
.switch input:checked + i { background: var(--ok); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(18px); }
.dot-pick { display: flex; gap: 10px; }
.dot-pick button {
  width: 28px; height: 28px; border-radius: 999px;
  border: 2px solid transparent; transition: transform 0.12s ease, border 0.12s ease;
}
.dot-pick button[aria-pressed="true"] { border-color: var(--fg); transform: scale(1.08); }
.key-chip {
  font-family: var(--mono); font-size: 11px;
  background: var(--pill); border: 1px solid var(--pill-line);
  padding: 5px 9px; border-radius: 8px; color: var(--muted);
  display: inline-block; letter-spacing: 0.04em;
}
.about-mark { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 16px 18px; text-align: center; }
.about-mark .word { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.about-mark p { font-size: 12px; color: var(--faint); max-width: 30ch; line-height: 1.55; }

/* ============================== New component styles (v2.1) ============================== */

/* Conversation header chips */
.chip.e2e { flex: none; }
.chip.e2e .cdot {
  width: 7px; height: 7px; border-radius: 99px;
  background: var(--warn); transition: background 0.2s ease;
}
.chip.e2e.on .cdot { background: var(--ok); }
.chip.e2e.bad .cdot { background: var(--bad); }
.icon-btn.end-btn.armed { color: var(--bad); background: var(--bad-soft); }
.sysmsg.warn { color: var(--warn); }
.sysmsg.note {
  background: var(--pill); border: 1px solid var(--pill-line);
  border-radius: 12px; padding: 8px 12px; margin: 8px 6%;
}
/* media whose vault file is gone (e.g. seen from an old transcript) */
.media-gone {
  padding: 16px 18px; font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--pill-line); border-radius: 14px;
  text-align: center; min-width: 140px;
}

/* More-options sheet (three-dot menu in the conversation header) */
.menu-list { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 2px; }
.menu-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 8px; border-radius: 14px;
  font-size: 14.5px; font-weight: 700; color: var(--fg);
  text-align: left;
  transition: background 0.12s ease;
}
.menu-row:active { background: var(--pill); }
.menu-row .ic {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--pill); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.menu-row .ic svg { width: 19px; height: 19px; }
.menu-row .tx { flex: 1; min-width: 0; }
.menu-row .tx b { display: block; font-size: 14.5px; font-weight: 750; }
.menu-row .sub { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 1px; line-height: 1.4; }
.menu-row.danger { color: var(--bad); }
.menu-row.danger .ic { background: var(--bad-soft); color: var(--bad); }

/* Security code sheet */
.seccode {
  font-family: var(--mono);
  font-size: 17px; font-weight: 700; letter-spacing: 0.08em;
  text-align: center;
  background: var(--pill); border: 1px solid var(--pill-line);
  border-radius: var(--radius-md);
  padding: 14px 12px; margin: 4px 0 12px;
  word-spacing: 0.35em; user-select: all;
}

/* Real search results in the New-chat sheet */
.search-line { color: var(--muted); font-size: 13px; padding: 6px 4px; margin: 0; }
.found-row { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-md); margin-top: 6px; }
.found-row:active { background: var(--pill); }
.found-row .tx b { font-size: 14px; }

/* Media view toolbar + uploads */
.media-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.media-bar .seg { flex: 1; }
.add-media { flex: none; }
/* v2.8.24 — narrow screens: icon-only Add media so the tabs keep their room
 * (the kept meter used to sit here and squeeze everything; with it gone the
 * button itself must still fit beside five tabs on a phone) */
@media (max-width: 620px) {
  .add-media span { display: none; }
  .add-media { padding-left: 11px; padding-right: 11px; }
}
.media-note {
  margin: 2px 2px 12px;
  font-size: 12px; line-height: 1.5;
  color: var(--muted);
}
.up-cell {
  border-radius: 6px; overflow: hidden; aspect-ratio: 1;
  background: var(--card); border: 1px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; padding: 8px;
}
.up-cell .up-ic { color: var(--accent); }
.up-cell .up-name {
  font-size: 10.5px; color: var(--muted); font-weight: 650;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.up-cell .up-track { width: 72%; height: 4px; border-radius: 99px; background: var(--pill); overflow: hidden; }
.up-cell .up-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width 0.2s ease; }

/* Audio row delete */
.audio-row .row-del { width: 32px; height: 32px; color: var(--faint); }
.audio-row .row-del svg { width: 15px; height: 15px; }
.audio-row .row-del.armed, .audio-row .row-del:active { color: var(--bad); }

/* Viewer delete armed state */
.viewer .icon-btn.del.armed { color: #fff; background: var(--bad); }

/* Roster active row (desktop affordance, also fine on mobile) */
.chat-row.active { background: var(--pill); }

/* ============================== Desktop layout (≥900px) ============================== */
@media (min-width: 900px) {
  /* Dock becomes a floating left rail (CoreX-style vertical pill) */
  .dock {
    left: 14px; right: auto; bottom: 50%;
    transform: translateY(50%);
    flex-direction: column;
    gap: 4px;
    padding: 10px 8px;
    border-radius: 26px;
  }
  .dock-btn { flex: none; width: 64px; gap: 4px; padding: 10px 2px 9px; font-size: 10.5px; }
  .dock-btn .n { top: 4px; right: calc(50% - 24px); }

  /* Topbar leaves room for the rail */
  .topbar { padding-left: 96px; }

  /* Main content area */
  .app-main {
    margin-left: 96px;
    max-width: 1100px;
    padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 20px) 22px 60px;
  }
  .app-main > .view[data-view="chats"] { max-width: 640px; }
  .app-main > .view[data-view="media"] { max-width: none; }
  .app-main > .view[data-view="audio"] { max-width: 720px; }
  .app-main > .view[data-view="settings"] { max-width: 720px; }

  /* Conversation: slide-over panel on the right (two-pane feel) */
  .conv {
    left: auto; top: 0; bottom: 0; right: 0;
    width: min(560px, 48vw);
    border-left: 1px solid var(--line);
    box-shadow: -40px 0 90px -50px rgba(0, 0, 0, 0.55);
    transform: translateX(105%);
  }
  .conv.open { transform: translateX(0); }
  .conv-head { padding-top: 0; gap: 10px; }
  .conv-msgs { padding: 18px 18px 12px; }
  .msg { max-width: 74%; }
  .composer { padding: 10px 14px 12px; }

  /* Media grid gets room to breathe */
  .media-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }

  /* Landing opens up */
  .landing { max-width: 960px; padding-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 44px); }
  .hero h1 { font-size: 48px; max-width: 20ch; }
  .hero .lede { font-size: 17px; max-width: 56ch; }
  .hero-actions { max-width: 440px; }
  .feat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }

  /* Sheets become centered dialogs */
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: 480px; border-radius: 24px;
    border-bottom: 1px solid var(--line);
    transform: translate(-50%, -46%) scale(0.98);
    opacity: 0;
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0.25, 1), opacity 0.24s ease;
  }
  .sheet-layer.open .sheet { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .grabber { display: none; }

  .toast { bottom: 34px; }
}

@media (min-width: 1360px) {
  .media-grid { grid-template-columns: repeat(6, 1fr); }
  .app-main { max-width: 1240px; }
}

/* ============================== Calls (v2.8.5) ============================== */
/* Immersive overlay — dark in both themes (FaceTime-style), above the
   sheet layer (80) and below toasts (90) so call notices stay visible.
   Modes (classes on .call-layer):
     .voice / .video          call type — drives bg, PiP, controls
     .incoming / .outgoing    ring phase
     .ringing                 ripple animation around the avatar
     .answered                callee picked up (pre-media-connection)
     .has-remote              remote video frames are flowing (JS watcher)
     .swapped                 tap-to-swap: self view full-bleed, remote PiP
     .closing                 graceful exit animation (+ .call-ended chip) */
.call-layer {
  position: fixed; inset: 0; z-index: 85;
  display: flex; flex-direction: column; align-items: center;
  /* SOLID base — WebView compositing quirk: translucent gradient layers on
   * a fixed element with backdrop-filter children could drop the layer's
   * own background, showing the page through the middle of a live call.
   * The decorative gradients now live on the .call-bg CHILD, which always
   * paints above this solid floor. */
  background: #06080C;
  color: #F2F4F7;
  opacity: 0; transition: opacity 0.24s ease;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow: hidden;
}
.call-layer.show { opacity: 1; }
/* graceful close: fade + gentle zoom, with an "ended" chip */
/* the fade waits ~0.6s so the "Call ended" chip is actually readable first */
.call-layer.closing { opacity: 0; transform: scale(1.04); transition: opacity 0.4s ease 0.6s, transform 0.42s ease 0.6s; }
.call-ended {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 22px; border-radius: 999px;
  background: rgba(12, 14, 18, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 14.5px; font-weight: 700; letter-spacing: 0.01em;
  color: #F2F4F7; white-space: nowrap;
  animation: callended 0.32s ease both;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
@keyframes callended {
  from { opacity: 0; transform: translate(-50%, -42%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* backdrop: decorative gradients + optional full-bleed local camera */
.call-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(10, 124, 255, 0.20), transparent 55%),
    linear-gradient(180deg, rgba(7, 9, 13, 0.94), rgba(5, 6, 9, 0.985));
}
.call-bgvideo {
  display: none; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
  background: #060709;
}
.call-layer.video.outgoing .call-bgvideo,
.call-layer.video.answered:not(.has-remote) .call-bgvideo { display: block; }
.call-layer.video.has-remote .call-bgvideo { display: none; }
.call-bg::after {   /* dim + vignette so overlays stay readable */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5, 6, 9, 0.55), rgba(5, 6, 9, 0.28) 40%, rgba(5, 6, 9, 0.62));
}
/* video mode gets a cooler tint, voice a warmer neutral */
.call-layer.video .call-bg { background:
    radial-gradient(120% 70% at 50% -10%, rgba(10, 124, 255, 0.30), transparent 55%),
    linear-gradient(180deg, rgba(6, 9, 14, 0.92), rgba(4, 6, 10, 0.985)); }

/* remote video (full-bleed) — SOLID backdrop under the frames: the element
 * is gated by opacity (0 until frames flow), so it can never show the page
 * through itself, and a stalled stream degrades to dark, not transparent */
.call-videowrap { position: absolute; inset: 0; }
.call-remote {
  width: 100%; height: 100%; object-fit: cover;
  background: #060709; opacity: 0;
  transition: opacity 0.5s ease;
}
.call-layer.has-remote .call-remote { opacity: 1; }
/* pre-frames placeholder: avatar + status, only once media is negotiated */
.call-remote-fb {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
.call-layer.video.answered:not(.has-remote) .call-remote-fb { opacity: 1; }
/* v2.8.12 — peer camera off: keep the card up over the frozen/black video */
.call-layer.video.has-remote.cam-off .call-remote-fb { opacity: 1; }
.call-layer.video.has-remote.cam-off .call-remote { opacity: 0.3; }
.call-remote-fb .call-remote-fb-txt {
  font-size: 13.5px; font-weight: 600; color: rgba(242, 244, 247, 0.72);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(22, 26, 34, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* self view (PiP) — bigger than v2.8.4, tap to swap with remote.
 * Revealed ONLY once a real stream is attached (.local-live, set by JS):
 * a dead <video> element paints Android WebView's play-button poster. */
.call-local {
  position: absolute; right: 14px;
  top: calc(64px + env(safe-area-inset-top));
  width: 112px; height: 150px; object-fit: cover;
  border-radius: 16px; background: #0A0C10;
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.8);
  transform: scaleX(-1);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 3; cursor: pointer;
}
.call-layer.video.local-live .call-local { opacity: 1; pointer-events: auto; }
/* v2.8.12 — own camera off: dim the frozen PiP so it can't read as live */
.call-layer.video.local-live.self-off .call-local { opacity: 0.25; }
/* tap-to-swap: remote becomes the small view, self view fills the screen */
.call-layer.video.swapped .call-remote {
  position: absolute; width: 112px; height: 150px;
  right: 14px; left: auto; top: calc(64px + env(safe-area-inset-top));
  border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.8);
  object-fit: cover; z-index: 3;
}
.call-layer.video.swapped .call-local {
  width: 100%; height: 100%; right: 0; top: 0;
  border-radius: 0; border: none; z-index: 1;
}

/* centered stage: avatar + ripple + name/status (voice mode and ringing) */
.call-stage {
  flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px;
  padding-top: 6vh;
  position: relative; z-index: 2;
  transition: opacity 0.45s ease;
}
/* v2.8.7 overlap fix: the stage must yield as soon as the call is ANSWERED
 * (the placeholder card inside the video wrap takes over) — not only once
 * remote frames flow. Gating it on .has-remote alone stacked TWO avatar +
 * status cards over the dimmed self-view during "Connecting video…"
 * (the reported double-avatar overlap, worst on the starter side).
 * Voice calls keep their stage: they never gain a video wrap. */
.call-layer.video.answered .call-stage { opacity: 0; pointer-events: none; }
.call-ripple { position: relative; width: 116px; height: 116px; }
.call-ripple::before, .call-ripple::after {
  content: ''; position: absolute; inset: 0; border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  opacity: 0; pointer-events: none;
}
.call-layer.ringing .call-ripple::before { animation: callripple 2.2s ease-out infinite; }
.call-layer.ringing .call-ripple::after  { animation: callripple 2.2s ease-out 1.1s infinite; }
@keyframes callripple {
  0%   { transform: scale(1); opacity: 0.55; }
  70%  { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}
.call-ava {
  width: 108px; height: 108px; border-radius: 999px;
  font-size: 34px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.call-layer.video .call-ava { box-shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.9), 0 0 0 4px rgba(10, 124, 255, 0.16); }
/* type badge pinned on the avatar (video calls) */
.call-ava-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 34px; height: 34px; border-radius: 999px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #339DFF, #0A7CFF);
  border: 2px solid rgba(7, 9, 13, 0.9);
  color: #fff; box-shadow: 0 6px 18px -6px rgba(10, 124, 255, 0.8);
}
.call-info { text-align: center; padding: 0 22px; }
.call-name { font-size: 23px; font-weight: 800; letter-spacing: -0.01em; }
.call-status { font-size: 13.5px; color: rgba(242, 244, 247, 0.66); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* top strip: encryption chip + (video: name + timer) */
.call-chip {
  position: absolute; top: calc(14px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: rgba(242, 244, 247, 0.78);
  background: rgba(24, 28, 36, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 7px 14px; border-radius: 999px;
  z-index: 4; white-space: nowrap;
}
.call-chip svg { opacity: 0.85; }
.call-top {
  position: absolute; top: calc(52px + env(safe-area-inset-top));
  left: 0; right: 0; text-align: center;
  opacity: 0; transition: opacity 0.45s ease; z-index: 4; pointer-events: none;
}
.call-layer.video.has-remote .call-top,
.call-layer.video.answered:not(.has-remote) .call-top { opacity: 1; }
.call-top-name { font-size: 15px; font-weight: 700; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.65); }
.call-top-status { font-size: 12.5px; color: rgba(242, 244, 247, 0.68); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* controls — pill bar, end button always red and larger */
.call-controls {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: auto 0 0; padding: 26px 0 calc(30px + env(safe-area-inset-bottom));
  position: relative; z-index: 4;
}
.call-btn {
  width: 58px; height: 58px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(40, 46, 56, 0.82); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 26px -12px rgba(0, 0, 0, 0.7);
  transition: transform 0.12s ease, background 0.15s ease;
}
.call-btn:active { transform: scale(0.92); }
.call-btn.end { background: #E5484D; border-color: transparent; width: 66px; height: 66px; }
.call-btn.accept { background: #30D158; border-color: transparent; width: 66px; height: 66px; }
.call-btn.off { background: rgba(255, 255, 255, 0.88); color: #0D0F12; }
/* speaker active — brand blue, same visual language as accept/end */
.call-btn.on { background: #0A7CFF; border-color: transparent; color: #fff; }

/* desktop: keep it a centered card instead of full-bleed */
@media (min-width: 900px) {
  .call-local { width: 160px; height: 214px; right: 24px; }
  .call-layer.video.swapped .call-remote { width: 160px; height: 214px; right: 24px; }
  .call-ava { width: 128px; height: 128px; font-size: 40px; }
  .call-ripple { width: 136px; height: 136px; }
}

/* ============================== Groups + verified badge (v2.8.0) ============================== */

/* name + verified rosette row — used in the 1:1 header, roster rows,
 * search results, group member list and group sender labels */
.name-row {
  display: inline-flex; align-items: center; gap: 5px;
  min-width: 0; max-width: 100%; font-size: inherit; color: inherit;
  white-space: nowrap;
}
.name-row b { overflow: hidden; text-overflow: ellipsis; }
.badge-slot { display: inline-flex; align-items: center; flex: none; }
.vbadge-svg { flex: none; display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18)); }

/* groups roster */
.grp-top { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.grp-top .search-row.grow { flex: 1; }
.grp-new { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: auto; }
.gtag {
  flex: none; font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft, rgba(90, 123, 255, 0.14));
  border-radius: 6px; padding: 1.5px 5px;
}

/* square-ish avatars for groups (distinct from the round 1:1 avatars) */
.ava.gsq { border-radius: 13px; }
.conv-head .ava.gsq { border-radius: 12px; }

/* group peer sender label */
.sender {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  margin: 0 6px 2px;
}
.sender .sender-time { font-weight: 600; color: var(--faint); }

/* chosen-handle chips in the create / add-member sheets */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-row:empty { display: none; }
.chip .chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 2px; padding: 0;
  border: 0; border-radius: 99px; background: rgba(127, 127, 127, 0.18);
  color: inherit; cursor: pointer;
}
.chip .chip-x:active { background: rgba(127, 127, 127, 0.34); }

/* non-interactive member rows inside the group sheet */
.menu-row.static { cursor: default; }
.menu-row.static:active { background: transparent; }
.menu-row.static .ic { background: transparent; padding: 0; }

/* ================= v2.8.1 — public groups (discover + join + link) ==== */

/* "Public groups" separator above discovery results */
.disc-sep {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 2px 6px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint);
}
.disc-sep::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

/* discovery rows behave like roster rows but are not clickable as a whole */
.disc-row { cursor: default; }
.disc-row:active { background: transparent; }
.disc-row .meta { flex: 1; min-width: 0; }

/* compact self-serve Join button on each discovery row */
.join-btn {
  flex: none;
  padding: 5px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 99px;
  background: var(--card);
  color: var(--fg);
  font: inherit; font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.join-btn:active { background: var(--pill); }
.join-btn:disabled { opacity: 0.55; cursor: default; }

/* ================= v2.8.2 — profiles: About + full photo viewer ==== */

/* tappable avatar affordance (1:1 header button, group member rows) */
.ava-tap { cursor: zoom-in; }
button.ava-tap { background: none; border: 0; padding: 0; display: inline-flex; }

/* profile card inside a sheet */
.prof-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; text-align: center; }
.prof-ava-btn { background: none; border: 0; padding: 0; border-radius: 26px; cursor: zoom-in; }
.prof-ava-btn .ava.prof-ava { width: 96px; height: 96px; border-radius: 26px; font-size: 30px; }
.prof-name { font-size: 16.5px; }
.prof-name b { font-weight: 800; letter-spacing: -0.01em; }
.prof-about {
  font-size: 13.5px; line-height: 1.5; color: var(--fg);
  max-width: 40ch; overflow-wrap: break-word; margin: 2px 0 0;
  white-space: pre-wrap;
}
.prof-about.dim { color: var(--faint); }

/* About editor in Settings */
.about-card { padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.about-lbl { font-size: 12px; color: var(--muted); }
.about-ta { resize: vertical; min-height: 74px; line-height: 1.45; }
.about-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.about-cnt { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* About line under a member row's role bits */
.menu-row .sub.about-line { color: var(--fg); opacity: 0.78; white-space: pre-wrap; overflow-wrap: break-word; }

/* full-screen profile photo viewer */
.pviewer {
  position: fixed; inset: 0; z-index: 96;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px;
  background: rgba(2, 3, 5, 0.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity 0.2s ease;
  cursor: zoom-out;
}
.pviewer.open { opacity: 1; }
.pviewer .ava.pva { width: min(72vw, 300px); height: min(72vw, 300px); border-radius: 28%; font-size: 64px; }
.pviewer .ava.pva img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.pviewer-name { color: #fff; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.pviewer-sub { color: rgba(255, 255, 255, 0.66); font-size: 12.5px; margin-top: -8px; }
.pviewer-hint {
  position: absolute; bottom: calc(24px + env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, 0.45); font-size: 11.5px; font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .pviewer { transition: none; }
}

/* ============================== Context menus (v2.8.5) ==============================
 * Branded right-click / long-press menus (ui.js openMenu). One layer,
 * one clamped card, spring-in scale — native-menu look, app identity. */
.ctm-layer { position: fixed; inset: 0; z-index: 93; }
.ctm-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 14, 0.05); }
.ctm {
  position: absolute; min-width: 216px; max-width: 252px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 15px; padding: 6px;
  box-shadow: 0 6px 16px rgba(10, 14, 22, 0.14), 0 24px 56px -12px rgba(10, 14, 22, 0.35);
  opacity: 0; transform: scale(0.88) translateY(-5px);
  transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  will-change: transform, opacity;
}
.ctm-layer.open .ctm { opacity: 1; transform: none; }
.ctm-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10.5px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--fg);
  font: inherit; font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  text-align: left; cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
}
.ctm-item svg { color: var(--muted); flex: none; }
.ctm-item:active { background: var(--accent-soft); transform: scale(0.985); }
.ctm-item.danger { color: var(--bad); }
.ctm-item.danger svg { color: var(--bad); }
.ctm-item.danger:active { background: var(--bad-soft); }
.ctm-sep { height: 1px; margin: 5px 9px; background: var(--line-soft); }
@media (prefers-reduced-motion: reduce) {
  .ctm { transition: opacity 0.1s ease; transform: none; }
  .ctm-item:active { transform: none; }
}

/* ---------------- seen receipts (v2.8.11) ----------------
 * Own bubbles carry a delivery tick next to the timestamp: single check =
 * sent, double check = seen (peer read the thread past that message).
 * Seen ticks pick up the accent color, WhatsApp-style. */
.msg .stamp .stamp-time { white-space: nowrap; }
.msg .stamp .tick { flex: none; opacity: 0.9; }
.msg .stamp .tick svg { width: 11px; height: 11px; }
.msg .stamp.seen { color: var(--faint); }
.msg .stamp.seen .tick { color: var(--accent); }
.msg .sender .sender-time + .tick { display: none; }

/* ================= v2.8.13 ================= */

/* Settings — About card collapsed by default; opens on Edit tap */
.about-card { padding: 4px 14px; }
.about-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: 0;
  padding: 10px 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.about-head .ic {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.about-head .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.about-head .tx b { font-size: 13.5px; }
.about-prev {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.about-edit-hint {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
}
.about-card.open .about-edit-hint { display: none; }
.about-edit { display: none; padding: 2px 0 12px; }
.about-card.open .about-edit { display: block; }

/* Groups — group photo row in the members/settings sheet (any member) */
.grp-photo-row { align-items: center; }
.grp-photo-acts { display: flex; align-items: center; gap: 6px; flex: none; }

/* Groups — header avatar button affordance */
.gsq-tap { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 14px; }

/* ===================== v2.8.23 — conversation suite ===================== */

/* quoted reply drawn inside a bubble */
.quote-b {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.14);
  border-radius: 8px;
  padding: 5px 9px;
  margin: 0 0 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  max-width: 100%;
  overflow: hidden;
}
.quote-b .quote-name {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote-b .quote-prev {
  display: block;
  font-size: 12.5px;
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* forwarded tag */
.fwd-tag {
  font-size: 10.5px;
  font-style: italic;
  font-weight: 600;
  opacity: 0.65;
  margin-bottom: 3px;
}

/* media caption under photo/video/audio/file */
.cap-t {
  font-size: 14px;
  line-height: 1.35;
  margin-top: 6px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.cap-t a.os-link { color: inherit; font-weight: 620; text-decoration: underline; }

/* reaction pills under a bubble */
.rx-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: -8px 2px 2px;
  position: relative;
  z-index: 1;
}
.rx-pill {
  border: 1px solid var(--pill-line, rgba(127,127,127,0.35));
  background: var(--card, rgba(127,127,127,0.12));
  color: inherit;
  font-size: 11.5px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 99px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.rx-pill.mine {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* unsend tombstone */
.gone-row { opacity: 0.9; }
.gone-b {
  align-self: center;
  max-width: 78%;
  font-size: 12px;
  font-style: italic;
  opacity: 0.65;
  border: 1px dashed var(--pill-line, rgba(127,127,127,0.4));
  border-radius: 12px;
  padding: 5px 12px;
  text-align: center;
}
.msg.mine .gone-b { align-self: flex-end; }

/* "New messages" divider */
.new-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.new-sep::before,
.new-sep::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--accent);
  opacity: 0.5;
}

/* reply bar above the composer */
.reply-bar { padding: 0 10px 6px; }
.reply-quote {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.14);
  border-radius: 10px;
  padding: 7px 10px;
}
.rq-tx { flex: 1; min-width: 0; }
.rq-name {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rq-prev {
  display: block;
  font-size: 12.5px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rq-x {
  flex: none;
  border: 0;
  background: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  padding: 4px;
  border-radius: 99px;
}
.rq-x:hover { opacity: 1; }

/* search results inside the sheet */
.search-res { margin-top: 10px; max-height: 46vh; overflow-y: auto; }
.search-hit { width: 100%; text-align: left; }
.search-hit .tx { min-width: 0; }
.hit-time { display: block; font-size: 11px; font-weight: 700; color: var(--accent); }
.hit-snippet { display: block; font-size: 13px; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* flash highlight when jumping to a message */
.msg.flash .bubble { animation: os-flash 1.5s ease 1; }
@keyframes os-flash {
  0%, 55% { box-shadow: 0 0 0 3px var(--accent-soft, rgba(120, 170, 255, 0.4)); }
  100% { box-shadow: none; }
}

/* context-menu emoji row (reactions) */
.ctm-emoji {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
}
.ctm-emoji-btn {
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  padding: 5px 6px;
  border-radius: 10px;
  cursor: pointer;
}
.ctm-emoji-btn:hover { background: var(--accent-soft, rgba(120,170,255,0.15)); transform: scale(1.15); }

/* group member management actions */
.grp-mact { display: flex; flex-direction: column; gap: 5px; flex: none; align-items: stretch; }

/* v2.8.25 — change-password sheet form */
.pw-form { display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.pw-err { min-height: 18px; font-size: 12.5px; color: var(--bad, #e0524f); line-height: 1.4; }

/* vault: kept chip (v2.8.24 — the kept meter bar was removed from the toolbar) */
.kept-chip {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.55);
  border-radius: 99px;
  padding: 3px 7px;
  pointer-events: none;
}
/* grid cells need positioning for the chip */
.media-grid > button { position: relative; }

/* viewer keep button */
.keep-btn { color: var(--fg, inherit); }
.keep-btn.on { color: var(--accent); }
.keep-btn.on svg { stroke-width: 2.2; }
