/* OneChat — Apple-inspired design language.
   System fonts, glassmorphism panels over soft gradient orbs,
   iMessage-style bubbles, light + dark via prefers-color-scheme. */

:root {
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
               'Segoe UI Variable Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --text: #1d1d1f;
  --text-2: rgba(60, 60, 67, .62);
  --text-3: rgba(60, 60, 67, .34);
  --separator: rgba(60, 60, 67, .12);

  --blue: #007aff;
  --blue-deep: #0060df;
  --violet: #6e5cff;
  --green: #34c759;
  --red: #ff3b30;
  --accent-grad: linear-gradient(135deg, #0a84ff, #6e5cff);

  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-input: rgba(255, 255, 255, .68);
  --glass-border: rgba(255, 255, 255, .55);
  --glass-inner: rgba(0, 0, 0, .05);
  --hover-fill: rgba(0, 0, 0, .045);
  --active-fill: rgba(0, 0, 0, .08);

  --bubble-in: rgba(255, 255, 255, .82);
  --bubble-in-text: #1d1d1f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .10), 0 24px 70px rgba(0, 0, 0, .14);

  --orb-1: rgba(10, 132, 255, .22);
  --orb-2: rgba(110, 92, 255, .20);
  --orb-3: rgba(255, 55, 95, .12);
  --orb-4: rgba(90, 200, 250, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0c;
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, .62);
    --text-3: rgba(235, 235, 245, .32);
    --separator: rgba(84, 84, 88, .48);

    --blue: #0a84ff;
    --blue-deep: #0a6ae0;

    --glass: rgba(28, 28, 30, .55);
    --glass-strong: rgba(36, 36, 40, .72);
    --glass-input: rgba(118, 118, 128, .20);
    --glass-border: rgba(255, 255, 255, .12);
    --glass-inner: rgba(255, 255, 255, .06);
    --hover-fill: rgba(255, 255, 255, .06);
    --active-fill: rgba(255, 255, 255, .10);

    --bubble-in: rgba(58, 58, 62, .82);
    --bubble-in-text: #f5f5f7;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5), 0 24px 70px rgba(0, 0, 0, .55);

    --orb-1: rgba(10, 132, 255, .17);
    --orb-2: rgba(110, 92, 255, .16);
    --orb-3: rgba(255, 55, 95, .10);
    --orb-4: rgba(90, 200, 250, .10);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3 { line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); }
kbd {
  font: 500 11px/1 var(--font-body);
  background: var(--glass-input);
  border: 1px solid var(--separator);
  border-radius: 5px;
  padding: 2px 5px;
  color: var(--text-2);
}

/* ---------- ambient gradient orbs (what the glass blurs) ---------- */
.bg-orbs {
  position: fixed; inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 42% at 16% 18%, var(--orb-1), transparent 70%),
    radial-gradient(42% 44% at 84% 12%, var(--orb-2), transparent 70%),
    radial-gradient(36% 40% at 78% 84%, var(--orb-3), transparent 70%),
    radial-gradient(40% 44% at 12% 82%, var(--orb-4), transparent 70%);
  filter: saturate(1.15);
}

/* ---------- glass primitives ---------- */
.glass, .glass-panel, .glass-card, .cmdk, .toast {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  backdrop-filter: blur(28px) saturate(1.8);
  border: 1px solid var(--glass-border);
}
.glass-card {
  background: var(--glass-strong);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}

/* ---------- buttons & inputs ---------- */
.btn {
  font: 590 15px/1.2 var(--font-body);
  border: none;
  background: var(--glass-input);
  color: var(--blue);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: filter .15s, transform .12s, background .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.05); background: var(--active-fill); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 2px 10px rgba(10, 132, 255, .35);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--accent-grad); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--hover-fill); }
.btn.glassy {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--glass-border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn.lg { padding: 14px 28px; font-size: 17px; }
.btn.full { width: 100%; }
.btn.tiny {
  padding: 6px 12px; font-size: 13px; font-weight: 590;
  background: var(--glass-input); color: var(--text);
  border: 1px solid transparent;
}
.btn.tiny:hover { background: var(--active-fill); }
.btn.tiny.toggle.active { background: var(--blue); color: #fff; }
.btn.danger-invert { background: #fff; color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  border: none; background: none; cursor: pointer;
  font-size: 17px; color: var(--text-2); padding: 6px 9px; border-radius: 10px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover-fill); color: var(--text); }

.as-link { border: none; background: none; color: inherit; cursor: pointer; font: inherit; padding: 0; }
.as-link:hover { color: var(--blue); }
.as-link.small { font-size: 13px; color: var(--text-2); }

input, textarea {
  font: 15px/1.4 var(--font-body);
  color: var(--text);
  background: var(--glass-input);
  border: 1px solid var(--separator);
  border-radius: 12px;
  padding: 11px 14px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px rgba(10, 132, 255, .22);
}
.btn:focus-visible, .icon-btn:focus-visible, .as-link:focus-visible, .tab:focus-visible,
.send-btn:focus-visible, .kbd-hint:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- shared bits ---------- */
.view[hidden] { display: none !important; }
.svg-defs { position: absolute; }

.system-line {
  align-self: center;
  font: 400 11.5px/1.4 var(--font-body);
  color: var(--text-2);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px 14px;
  margin: 8px 0;
  text-align: center;
}

.oc-glyph { width: 30px; height: 30px; flex: none; border-radius: 27%; }
.oc-glyph.tiny { width: 18px; height: 18px; }
.oc-glyph.big { width: 64px; height: 64px; filter: drop-shadow(0 8px 20px rgba(10,132,255,.35)); }
.oc-glyph.faint { opacity: .35; filter: none; }

.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 22px; letter-spacing: -.02em;
}
.wordmark.small { font-size: 18px; }
.wordmark.small .oc-glyph { width: 24px; height: 24px; }

.grad-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.badge.verified {
  font: 590 11px/1 var(--font-body);
  color: var(--green);
  background: rgba(52, 199, 89, .14);
  border-radius: 999px;
  padding: 3px 9px;
  vertical-align: 2px;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  color: var(--text);
  padding: 12px 20px; border-radius: 16px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 80; max-width: 90vw;
}

/* ---------- landing ---------- */
#view-landing { min-height: 100%; display: flex; flex-direction: column; }

.landing-nav {
  position: sticky; top: 14px; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  margin: 14px clamp(16px, 4vw, 48px) 0;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.landing-nav nav { display: flex; gap: 10px; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  padding: clamp(48px, 9vh, 110px) clamp(20px, 5vw, 64px);
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.eyebrow {
  font: 590 13px/1 var(--font-body);
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--blue); margin-bottom: 18px;
}
.hero h1 {
  font-weight: 700;
  font-size: clamp(44px, 5.6vw, 76px);
  letter-spacing: -.035em;
  margin-bottom: 22px;
}
.lede { font-size: 19px; color: var(--text-2); max-width: 32em; }
.hero-actions { display: flex; gap: 12px; margin: 28px 0 18px; flex-wrap: wrap; }
.hero-facts { font: 400 12.5px/1.6 var(--font-mono); color: var(--text-3); }

/* live demo card */
.demo-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.demo-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font: 590 14px/1.3 var(--font-body);
  border-bottom: 1px solid var(--separator); padding-bottom: 12px;
}
.demo-live { font: 400 11px/1.3 var(--font-mono); color: var(--green); display: inline-flex; align-items: center; gap: 6px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
.demo-label {
  display: block; font: 590 11px/1 var(--font-body);
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-3);
  margin-bottom: 7px;
}
.demo-bubble {
  background: linear-gradient(160deg, #35a2ff, var(--blue) 70%);
  color: #fff;
  padding: 11px 16px; border-radius: 20px; border-bottom-right-radius: 6px;
  font-size: 15px; width: fit-content; max-width: 100%;
  box-shadow: 0 2px 10px rgba(10, 132, 255, .25);
}
.demo-seal-line {
  display: flex; align-items: center; gap: 8px;
  font: 400 12px/1 var(--font-mono); color: var(--violet);
}
.demo-cipher {
  margin: 0; font: 400 12px/1.7 var(--font-mono); color: var(--text-2);
  background: var(--glass-input);
  border: 1px dashed var(--separator);
  border-radius: 14px; padding: 12px 14px;
  white-space: pre-wrap; word-break: break-all;
  max-height: 128px; overflow: hidden;
}

/* steps */
.steps { padding: clamp(40px, 8vh, 96px) clamp(20px, 5vw, 64px); max-width: 1200px; margin: 0 auto; width: 100%; }
.steps h2, .verify-strip h2 {
  font-weight: 700;
  font-size: clamp(30px, 3.6vw, 44px);
  letter-spacing: -.03em;
}
.steps-list {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(16px, 2.5vw, 28px);
}
.steps-list li { padding: 26px 24px; }
.step-no {
  font: 700 13px/1 var(--font-mono);
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: block; margin-bottom: 12px;
}
.steps-list h3 { font-size: 18px; letter-spacing: -.01em; }
.steps-list p { font-size: 14.5px; color: var(--text-2); margin: 0; }

/* verify strip */
.verify-strip { padding: 0 clamp(20px, 5vw, 64px) clamp(48px, 9vh, 110px); max-width: 1200px; margin: 0 auto; width: 100%; }
.verify-inner {
  display: grid; grid-template-columns: auto 1fr; gap: clamp(28px, 5vw, 72px);
  align-items: center;
  padding: clamp(28px, 5vh, 56px) clamp(24px, 4vw, 56px);
}
.fp-sample {
  font: 500 clamp(16px, 2vw, 22px)/1.8 var(--font-mono);
  background: var(--glass-input);
  border: 1px dashed var(--separator);
  border-radius: 18px; padding: 22px 26px;
  letter-spacing: .06em;
}
.verify-strip p { color: var(--text-2); max-width: 44em; }
.verify-inner .btn { margin-top: 6px; }

.landing-foot {
  padding: 26px clamp(20px, 5vw, 64px);
  font: 400 13px/1 var(--font-body); color: var(--text-3);
  border-top: 1px solid var(--separator);
  text-align: center;
}

/* ---------- auth / unlock ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 26px; padding: 24px;
}
.auth-card { width: min(430px, 100%); padding: 30px; }
.tabs {
  display: flex; gap: 4px;
  background: var(--glass-input);
  border-radius: 999px; padding: 4px; margin-bottom: 24px;
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  font: 590 14px/1 var(--font-body); color: var(--text-2);
  padding: 10px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.tab.active {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { font: 590 13px/1.4 var(--font-body); display: flex; flex-direction: column; gap: 6px; }
.form-hint { font-size: 12.5px; color: var(--text-2); margin: 0; }
.form-hint.center { text-align: center; }
.form-error { color: var(--red); font-size: 13.5px; font-weight: 590; margin: 0; }
.unlock-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.unlock-card h2 { font-weight: 700; letter-spacing: -.02em; }
.unlock-card form { width: 100%; }

/* ---------- fingerprint grid ---------- */
.fp-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 10px;
  font: 500 13.5px/1 var(--font-mono); letter-spacing: .04em;
  background: var(--glass-input);
  border: 1px solid var(--separator);
  border-radius: 14px; padding: 14px 16px;
  color: var(--text);
}
.fp-grid span { text-align: center; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(440px, 100%); padding: 32px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.modal-card h2 { font-weight: 700; margin: 0; }
.modal-card .fp-grid { width: 100%; }

/* ---------- chat layout ---------- */
.chat-layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 320px; flex: none;
  border-right: 1px solid var(--separator);
  border-top: none; border-bottom: none; border-left: none;
  display: flex; flex-direction: column;
}
.sidebar-head {
  padding: 16px 18px 12px;
  display: flex; flex-direction: column; gap: 10px;
  border-bottom: 1px solid var(--separator);
}
.me-chip { display: flex; align-items: center; justify-content: space-between; }
.me-chip .as-link { font-size: 13px; color: var(--text-2); }
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--separator); margin: 0;
}
.search input { font-size: 14px; padding: 8px 12px; border-radius: 10px; }
.kbd-hint {
  flex: none; cursor: pointer;
  font: 590 11px/1 var(--font-body);
  color: var(--text-2);
  background: var(--glass-input);
  border: 1px solid var(--separator);
  border-radius: 7px;
  padding: 6px 8px;
  transition: background .15s, color .15s;
}
.kbd-hint:hover { background: var(--active-fill); color: var(--text); }

.new-group-btn {
  display: flex; align-items: center; justify-content: center;
  margin: 10px 14px 0;
  border: 1px dashed var(--separator); background: none; cursor: pointer;
  font: 590 13px/1 var(--font-body); color: var(--text-2);
  padding: 10px; border-radius: 12px;
  transition: background .15s, color .15s, border-color .15s;
}
.new-group-btn:hover { background: var(--hover-fill); color: var(--blue); border-color: var(--blue); }

.convo-list { overflow-y: auto; flex: 1; padding: 8px; }
.empty-note { font-size: 13.5px; color: var(--text-2); padding: 14px 10px; }
.convo-item {
  display: flex; gap: 12px; align-items: center;
  width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  padding: 11px 12px; border-radius: 14px;
  font: inherit; color: inherit;
  transition: background .12s;
}
.convo-item:hover { background: var(--hover-fill); }
.convo-item.active { background: var(--blue); color: #fff; }
.convo-item.active .convo-preview,
.convo-item.active .convo-time { color: rgba(255, 255, 255, .75); }
.convo-meta { min-width: 0; flex: 1; }
.convo-name { font-weight: 590; font-size: 14.5px; display: flex; justify-content: space-between; gap: 8px; }
.convo-time { font: 400 11px/1.6 var(--font-body); color: var(--text-3); flex: none; }
.convo-preview {
  font-size: 13px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: 590 18px/1 var(--font-body);
}
.avatar.group { background: linear-gradient(135deg, #6e5cff, #ff375f); }
.avatar-wrap { position: relative; flex: none; }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
  border: 2.5px solid var(--bg);
}
.unread-badge {
  flex: none; margin-left: 8px;
  background: var(--red); color: #fff;
  font: 590 11px/1 var(--font-body);
  border-radius: 999px; padding: 3px 7px; min-width: 20px; text-align: center;
}
.peer-sub { display: flex; gap: 10px; align-items: baseline; font-size: 11px; }
.peer-status { color: var(--green); }
.peer-status.typing { color: var(--blue); font-style: italic; }

/* main pane */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-blank {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; color: var(--text-2);
}
.chat-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-pane[hidden] { display: none; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  border: none; border-bottom: 1px solid var(--separator);
  z-index: 5;
}
.back-btn { display: none; }
.peer-id { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.peer-id .avatar { width: 36px; height: 36px; font-size: 15px; }
.peer-name { font-weight: 590; font-size: 15px; }
.peer-fp { font-size: 11px; color: var(--text-3); letter-spacing: .05em; }
.head-actions { display: flex; gap: 8px; }

.key-banner {
  background: var(--red); color: #fff;
  padding: 11px 18px; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.messages {
  flex: 1; overflow-y: auto;
  padding: 22px clamp(14px, 3vw, 36px);
  display: flex; flex-direction: column; gap: 3px;
}
.msg { display: flex; margin-bottom: 5px; }
.msg.me { justify-content: flex-end; }
.msg-sender {
  display: block;
  font: 590 11px/1 var(--font-body);
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 4px;
}
.bubble {
  max-width: min(68%, 560px);
  padding: 9px 14px;
  border-radius: 20px; border-bottom-left-radius: 7px;
  background: var(--bubble-in);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-border);
  color: var(--bubble-in-text);
  font-size: 15px;
  overflow-wrap: break-word; white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.msg.me .bubble {
  background: linear-gradient(160deg, #35a2ff, var(--blue) 75%);
  color: #fff;
  border: none;
  border-radius: 20px; border-bottom-right-radius: 7px;
  box-shadow: 0 2px 10px rgba(10, 132, 255, .28);
}
.msg-time {
  display: block; font: 400 10.5px/1 var(--font-body);
  color: var(--text-3); margin-top: 5px; text-align: right;
}
.msg.me .msg-time { color: rgba(255, 255, 255, .65); }
.msg-cipher {
  display: none;
  font: 400 11.5px/1.6 var(--font-mono);
  word-break: break-all;
  max-height: 5.1em; overflow: hidden;
}
.msg-fail .msg-text { font-style: italic; opacity: .75; }

/* server view: flip every bubble to its stored ciphertext */
.cipher-view .msg-text { display: none; }
.cipher-view .msg-cipher { display: block; }
.cipher-view .bubble {
  background: var(--glass-input) !important;
  color: var(--text-2) !important;
  border: 1px dashed var(--text-3) !important;
  box-shadow: none !important;
}
.cipher-view .msg-time { color: var(--text-3); }

.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px;
  border: none; border-top: 1px solid var(--separator);
  margin: 0;
}
.composer textarea {
  resize: none; max-height: 120px;
  border-radius: 20px;
  padding: 10px 16px;
}
.attach-btn { font-size: 20px; margin-bottom: 3px; }
.send-btn {
  flex: none;
  width: 36px; height: 36px; margin-bottom: 2px;
  border: none; border-radius: 50%;
  background: var(--accent-grad);
  color: #fff; font-size: 18px; font-weight: 700; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(10, 132, 255, .35);
  transition: filter .15s, transform .12s, opacity .15s;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(.92); }
.send-btn:disabled { opacity: .45; cursor: default; }

/* attachments inside bubbles */
.attach-img {
  display: block; max-width: 100%; max-height: 320px;
  min-width: 120px; min-height: 60px;
  background: var(--glass-input);
  border-radius: 14px; margin-bottom: 4px; cursor: zoom-in;
}
.attach-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .16);
  border: 1px dashed var(--glass-border);
  border-radius: 14px; padding: 9px 12px; margin-bottom: 4px;
  cursor: pointer;
  transition: background .15s;
}
.msg:not(.me) .attach-card { background: var(--hover-fill); border-color: var(--text-3); }
.attach-card:hover { background: var(--active-fill); }
.attach-name { font-weight: 590; font-size: 13.5px; overflow-wrap: anywhere; }
.attach-size { font: 400 11px/1 var(--font-mono); color: var(--text-3); }
.msg.me .attach-size { color: rgba(255, 255, 255, .7); }
.attach-icon { font-size: 20px; flex: none; }

/* contact panel */
.contact-panel {
  width: 300px; flex: none;
  border-left: 1px solid var(--separator);
  border-top: none; border-bottom: none; border-right: none;
  padding: 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}
.contact-panel[hidden] { display: none; }
.contact-panel header { display: flex; justify-content: space-between; align-items: center; }
.contact-panel h3 { margin: 0; font-size: 17px; }
.fp-block h4 {
  font: 590 11px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3); margin: 0 0 10px;
}
.verify-row {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 12.5px; color: var(--text-2); margin-top: 12px; cursor: pointer;
}
.verify-row input { width: auto; margin-top: 2px; accent-color: var(--green); }
.peer-members {
  font-size: 11px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 42vw;
}
.member-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.member-list li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.member-list .avatar { width: 26px; height: 26px; font-size: 12px; }
.member-you { color: var(--text-3); font-size: 11.5px; }
.add-member-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-member-row input { font-size: 13px; padding: 8px 11px; border-radius: 10px; }
.btn.tiny.danger { color: var(--red); }
.group-form { text-align: left; width: 100%; }

/* ---------- command palette (⌘K) ---------- */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, .25);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(60px, 16vh, 160px) 20px 20px;
}
.cmdk {
  width: min(600px, 100%);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: min(430px, 70vh);
  animation: cmdk-in .16s ease-out;
}
@keyframes cmdk-in {
  from { opacity: 0; transform: scale(.97) translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--separator);
}
.cmdk-search-icon { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.cmdk-input-row input {
  border: none; background: none; padding: 0;
  font-size: 17px; box-shadow: none;
}
.cmdk-input-row input:focus { border: none; box-shadow: none; }
.cmdk-esc { flex: none; }
.cmdk-list { overflow-y: auto; padding: 8px; flex: 1; }
.cmdk-group {
  font: 590 11px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3);
  padding: 12px 12px 6px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  padding: 10px 12px; border-radius: 12px;
  font: 500 14.5px/1.3 var(--font-body); color: var(--text);
}
.cmdk-item .cmdk-icon {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-input); font-size: 15px;
}
.cmdk-item .cmdk-icon.grad { background: var(--accent-grad); color: #fff; }
.cmdk-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item-sub { font-size: 12px; color: var(--text-3); font-weight: 400; }
.cmdk-item.selected { background: var(--blue); color: #fff; }
.cmdk-item.selected .cmdk-item-sub { color: rgba(255, 255, 255, .7); }
.cmdk-item.selected .cmdk-icon { background: rgba(255, 255, 255, .2); color: #fff; }
.cmdk-empty { padding: 26px 12px; text-align: center; color: var(--text-2); font-size: 14px; }
.cmdk-foot {
  display: flex; gap: 16px; justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid var(--separator);
  font-size: 11.5px; color: var(--text-3);
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- emoji & GIF picker ---------- */
.picker {
  position: absolute; left: 12px; bottom: 74px; z-index: 30;
  width: min(370px, calc(100% - 24px));
  max-height: min(400px, 55vh);
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  animation: cmdk-in .14s ease-out;
}
.picker-tabs {
  display: flex; gap: 4px; flex: none;
  background: var(--glass-input);
  border-radius: 999px; padding: 3px;
}
.picker-tab {
  flex: 1; border: none; background: none; cursor: pointer;
  font: 590 13px/1 var(--font-body); color: var(--text-2);
  padding: 8px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.picker-tab.active { background: var(--glass-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.picker input { flex: none; font-size: 14px; padding: 8px 12px; border-radius: 10px; }
.picker-body { overflow-y: auto; flex: 1; min-height: 140px; }
.emoji-cat-title {
  font: 590 10.5px/1 var(--font-body); text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3);
  padding: 10px 4px 5px;
}
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-cell {
  border: none; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 6px 0;
  border-radius: 9px;
  transition: background .12s, transform .1s;
}
.emoji-cell:hover { background: var(--hover-fill); }
.emoji-cell:active { transform: scale(1.25); }
.gif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 4px; }
.gif-cell {
  border: none; padding: 0; cursor: pointer;
  background: var(--glass-input);
  border-radius: 10px; overflow: hidden;
  min-height: 80px;
}
.gif-cell img { width: 100%; display: block; }
.gif-cell:hover { outline: 2px solid var(--blue); }
.picker-empty { padding: 24px 8px; text-align: center; color: var(--text-2); font-size: 13.5px; }
.picker-note { flex: none; font-size: 10.5px; line-height: 1.45; color: var(--text-3); margin: 0; }

/* ---------- image lightbox ---------- */
.lightbox-backdrop {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(14px, 4vw, 48px);
  animation: cmdk-in .16s ease-out;
}
.lightbox-figure {
  margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: 100%; max-height: 100%;
}
#lightbox-img {
  max-width: min(1100px, 100%);
  max-height: calc(100dvh - 150px);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  background: rgba(255, 255, 255, .06);
}
.lightbox-bar {
  display: flex; align-items: center; gap: 16px;
  max-width: 100%;
  background: rgba(28, 28, 30, .6);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  padding: 8px 10px 8px 18px;
  color: #f5f5f7;
}
.lightbox-meta { display: flex; flex-direction: column; min-width: 0; }
.lightbox-name {
  font: 590 13.5px/1.3 var(--font-body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox-size { font-size: 11px; color: rgba(235, 235, 245, .6); }
.lightbox-download.btn.tiny {
  flex: none;
  background: rgba(255, 255, 255, .16); color: #fff;
}
.lightbox-download.btn.tiny:hover { background: rgba(255, 255, 255, .28); }
.lightbox-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top)); right: 18px;
  width: 38px; height: 38px;
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 50%;
  background: rgba(28, 28, 30, .6);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  color: #f5f5f7; font-size: 20px; line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.lightbox-close:hover { background: rgba(60, 60, 64, .75); }
.lightbox-close:active { transform: scale(.92); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .steps-list { grid-template-columns: 1fr; }
  .verify-inner { grid-template-columns: 1fr; }
  .contact-panel {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 40;
    width: min(340px, 94vw);
    box-shadow: var(--shadow-lg);
    background: var(--glass-strong);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

/* phones: single-pane chat, larger tap targets, safe-area padding */
@media (max-width: 760px) {
  input, textarea { font-size: 16px; }  /* prevents iOS focus zoom */

  /* landing */
  .landing-nav {
    top: calc(10px + env(safe-area-inset-top));
    margin: 10px 12px 0;
    padding: 8px 10px 8px 14px;
    gap: 8px;
  }
  .landing-nav .btn { padding: 8px 13px; font-size: 14px; }
  .wordmark { font-size: 19px; gap: 8px; }
  .wordmark .oc-glyph { width: 25px; height: 25px; }
  .hero { padding-top: 44px; }
  .hero h1 { font-size: clamp(38px, 11.5vw, 52px); }
  .lede { font-size: 17px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .demo-card { padding: 18px; }
  .steps-list li { padding: 20px 18px; }
  .verify-inner { padding: 24px 20px; }

  /* auth */
  .auth-wrap { padding: 16px; gap: 20px; }
  .auth-card { padding: 22px; }

  /* chat: one pane at a time */
  .sidebar { width: 100%; border-right: none; }
  .chat-main { display: none; }
  .chat-layout.conversation-open .sidebar { display: none; }
  .chat-layout.conversation-open .chat-main { display: flex; }
  .back-btn { display: block; }
  .bubble { max-width: 84%; font-size: 16px; }

  .sidebar-head { padding-top: calc(16px + env(safe-area-inset-top)); }
  .convo-list { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .convo-item { padding: 13px 12px; }

  .chat-head {
    flex-wrap: wrap; row-gap: 8px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .head-actions { margin-left: auto; }
  .peer-fp { display: none; }
  .messages { padding: 16px 12px; }
  .composer {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .picker {
    left: 8px; right: 8px; width: auto;
    bottom: calc(68px + env(safe-area-inset-bottom));
    max-height: 46vh;
  }

  /* command palette: sheet-like on small screens */
  .cmdk-backdrop {
    padding: calc(12px + env(safe-area-inset-top)) 10px
             calc(12px + env(safe-area-inset-bottom));
  }
  .cmdk { max-height: min(560px, 78dvh); }
  .cmdk-input-row { padding: 13px 14px; }
  .cmdk-input-row input { font-size: 16px; }

  .modal-card { padding: 24px 20px; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* small phones: the nav can't fit three items — the hero repeats Sign in */
@media (max-width: 480px) {
  .landing-nav nav .btn.ghost { display: none; }
  .landing-nav .btn { white-space: nowrap; }
  .hero { padding-left: 16px; padding-right: 16px; }
  .steps, .verify-strip { padding-left: 16px; padding-right: 16px; }
}

/* touch devices: keyboard chrome is meaningless, palette opens by tap */
@media (hover: none) and (pointer: coarse) {
  .cmdk-esc, .cmdk-foot { display: none; }
  .icon-btn, .btn.tiny { padding: 8px 12px; }
}

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