*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Screen-reader only — visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Visible focus rings for keyboard navigation */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(88,101,242,0.18);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

input:focus-visible {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(88,101,242,0.18);
}

:root {
  --bg:       #f5f5f7;
  --surface:  #ffffff;
  --border:   #e2e2e6;
  --text:     #1a1a1a;
  --text-mid: #666666;
  --accent:   #5865f2;
  --accent-h: #4752c4;
  --own-bg:   #eaecff;
  --own-text: #3450c4;
}

[data-theme="dark"] {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --border:   #2a2a2a;
  --text:     #e0e0e0;
  --text-mid: #888888;
  --accent:   #5865f2;
  --accent-h: #4752c4;
  --own-bg:   #1e2a4a;
  --own-text: #93c5fd;
}

html, body {
  height: 100%;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  overflow: hidden;
}

/* home page: scrollable */
body.home-page {
  overflow: auto;
  background: #ececf4;
}

[data-theme="dark"] body.home-page {
  background: #07070f;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;   /* fallback for old browsers */
  height: 100dvh;  /* shrinks when mobile keyboard opens — keeps composer visible */
  max-width: 760px;
  margin: 0 auto;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.room-label {
  font-size: 12px;
  color: var(--text-mid);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.my-id {
  font-size: 11px;
  color: var(--text-mid);
  font-family: monospace;
  white-space: nowrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  font-family: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.15s;
  position: relative;
  overflow: hidden;
}

button:active  { transform: scale(0.97) !important; }
button:disabled { opacity: 0.4; cursor: default; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mid);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 10px rgba(88,101,242,0.15);
}

/* Gradient accent button */
.btn-accent {
  background: linear-gradient(135deg, #5865f2 0%, #7c3aed 100%);
  color: #fff;
}

/* Shimmer sweep on hover */
.btn-accent::after {
  content: '';
  position: absolute;
  top: 0; left: -80%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-15deg);
  transition: left 0.5s ease;
  pointer-events: none;
}

.btn-accent:hover:not(:disabled)::after { left: 140%; }

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(88,101,242,0.45);
}

/* Full-width primary button — security pulse */
.btn-full {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  letter-spacing: 0.02em;
  animation: securityPulse 2.8s ease-in-out infinite;
}

.btn-full:hover:not(:disabled) {
  animation: none;
  box-shadow: 0 6px 28px rgba(88,101,242,0.55) !important;
}

@keyframes securityPulse {
  0%,100% { box-shadow: 0 0 0 0   rgba(88,101,242,0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(88,101,242,0);   }
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* pin messages to bottom like WhatsApp */
  gap: 4px;
  scroll-behavior: smooth;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(88,101,242,0.09) 1px, transparent 1px);
  background-size: 22px 22px;
}

[data-theme="dark"] .messages {
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-mid);
  text-align: center;
}

.empty-state .icon { font-size: 36px; opacity: 0.35; }
.empty-state p { font-size: 14px; line-height: 1.6; }
.empty-state code {
  font-family: monospace;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-mid);
}

.msg-system {
  align-self: center;
  max-width: calc(100% - 24px);
  font-size: 11px;
  color: var(--text-mid);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 12px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
  word-break: break-word;
  overflow-wrap: break-word;
}

.msg {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg + .msg { margin-top: 2px; }
.msg + .msg.own,
.msg + .msg.them { margin-top: 8px; }

.msg.own { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }

/* Sender name sits above the bubble, outside it — no overflow possible */
.msg-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 0 6px;
  opacity: 0.8;
}

.msg-bubble {
  padding: 8px 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  min-width: 52px; /* ensure time always fits */
}

.msg.own .msg-bubble {
  background: var(--own-bg);
  color: var(--own-text);
  border-color: transparent;
  border-radius: 18px 4px 18px 18px;
}

/* Timestamp — time only, inside bubble bottom-right */
.msg-time {
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-size: 10px;
  opacity: 0.5;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.composer input:focus {
  border-color: var(--accent);
}

.composer input::placeholder { color: var(--text-mid); }

.composer button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.composer button:hover:not(:disabled) {
  background: var(--accent-h);
  transform: scale(1.05);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Handshake screen ────────────────────────────────────────────────────── */
.handshake-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}

.hs-state {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  text-align: center;
}

.hs-state p { font-size: 14px; color: var(--text-mid); }

.hs-step {
  width: 100%;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
}

.hs-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.hs-step > div { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.hs-label { font-size: 14px; color: var(--text-mid); margin: 0; }

.hs-row {
  display: flex;
  gap: 8px;
}

.hs-row input {
  flex: 1;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  outline: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hs-row input:focus { border-color: var(--accent); }
.hs-row input[readonly] { color: var(--text-mid); cursor: default; }
.hs-row input::placeholder { color: var(--text-mid); font-family: system-ui, sans-serif; }

.hs-passphrase-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
}

.hs-passphrase-box code {
  flex: 1;
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  word-break: break-all;
}

.hs-lock-icon {
  font-size: 36px;
}

.hs-state h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.hs-error {
  font-size: 12px;
  color: #f87171;
  text-align: center;
}

.hs-expiry {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-mid);
}

.hs-expiry select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.hs-waiting {
  font-size: 13px;
  color: var(--text-mid);
  font-style: italic;
  animation: pulse 2s ease-in-out infinite;
}

.hs-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Matrix canvas ───────────────────────────────────────────────────────── */
#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
  opacity: 0.28;
  filter: blur(1px);
}

/* ── Home page ───────────────────────────────────────────────────────────── */
.home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 16px;
  background: transparent;
  position: relative;
  z-index: 1;
}

.home-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(10, 10, 20, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(88,101,242,0.18);
  border-radius: 18px;
  padding: 40px 32px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 28px 56px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

.home-card .logo {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  letter-spacing: -0.5px;
  text-shadow: 0 0 30px rgba(88,101,242,0.4);
}

.home-tagline {
  font-size: 14px;
  color: var(--text-mid);
  text-align: center;
  line-height: 1.7;
}

.home-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-mid);
  font-size: 12px;
}

.home-divider::before,
.home-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.home-join {
  display: flex;
  gap: 8px;
}

.home-join input {
  flex: 1;
  padding: 10px 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  min-width: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.home-join input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,101,242,0.12);
}

.home-join input::placeholder { color: var(--text-mid); }

.home-error {
  font-size: 12px;
  color: #f87171;
  text-align: center;
}

.home-error.hidden { display: none; }

/* ── Logo as link in chat ────────────────────────────────────────────────── */
a.logo {
  color: var(--accent);
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
}

a.logo:hover { color: var(--accent-h); }

/* ── Peer status bar ─────────────────────────────────────────────────────── */
.peer-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mid);
  flex-shrink: 0;
}

.peer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-mid);
  transition: background 0.3s;
}

.peer-dot.active       { background: #22c55e; }
.peer-dot.idle         { background: #eab308; }
.peer-dot.away         { background: #6b7280; }
.peer-dot.connecting   { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.peer-dot.disconnected { background: #ef4444; }

/* ── Chat footer ─────────────────────────────────────────────────────────── */
.chat-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-mid);
  flex-shrink: 0;
  flex-wrap: wrap;
}


/* ── Live demo ───────────────────────────────────────────────────────────── */
.demo-section {
  position: relative;
  z-index: 1;
  padding: 56px 16px 64px;
  text-align: center;
}

.demo-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.demo-heading {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.demo-sub {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 36px;
}

/* Stage: two devices + connector */
.demo-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 620px;
  margin: 0 auto;
}

/* Device frame */
.demo-device {
  width: 172px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(88,101,242,0.06);
}

.demo-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.demo-bar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.demo-bar-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.demo-screen {
  height: 252px;
  padding: 12px 11px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.demo-label {
  padding: 5px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mid);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* Channel connector */
.demo-channels {
  flex: 1;
  min-width: 60px;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 0 6px;
}

.demo-ch {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
}

.demo-ch::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  transform: translateY(-50%);
  background: var(--accent);
  opacity: 0.4;
}

.demo-ch-dashed::before {
  background: none;
  border-top: 1px dashed #22c55e;
  opacity: 0.5;
}

.demo-ch-tag {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 600;
  color: var(--text-mid);
  white-space: nowrap;
  background: var(--bg);
  padding: 0 3px;
  letter-spacing: 0.02em;
}

[data-theme="light"] .demo-ch-tag { background: #ececf4; }

/* Animated packets */
.demo-pkt {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  left: 0;
}

.demo-pkt-link { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.demo-pkt-pass { background: #22c55e;       box-shadow: 0 0 6px #22c55e; }

@keyframes pktLTR {
  0%   { left: 0%;              opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { left: calc(100% - 9px); opacity: 0; }
}

@keyframes pktRTL {
  0%   { left: calc(100% - 9px); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { left: 0%;               opacity: 0; }
}

.pkt-ltr { animation: pktLTR 1.6s ease-in-out forwards; }
.pkt-rtl { animation: pktRTL 1.6s ease-in-out forwards; }

/* Caption + progress dots */
.demo-footer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.demo-caption {
  font-size: 13px;
  color: var(--text-mid);
  font-style: italic;
  min-height: 18px;
}

.demo-dots {
  display: flex;
  gap: 4px;
}

.demo-dot-pip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
  display: inline-block;
}

.demo-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.demo-play-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
}

.demo-play-btn:hover { background: var(--accent-h); transform: scale(1.1); }

.demo-dot-pip.active {
  background: var(--accent);
  transform: scale(1.4);
}

/* ── Mini screen elements ─────────────────────────────────────────────────── */

/* Home screen */
.ms-home { display: flex; flex-direction: column; gap: 7px; }
.ms-logo { font-size: 14px; font-weight: 800; color: var(--accent); text-align: center; }
.ms-tagline { font-size: 9px; color: var(--text-mid); text-align: center; line-height: 1.5; }
.ms-btn {
  background: linear-gradient(135deg, #5865f2, #7c3aed);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 6px;
  border-radius: 5px;
  text-align: center;
  animation: securityPulse 2.5s ease-in-out infinite;
}
.ms-btn-click { animation: none; opacity: 0.7; transform: scale(0.97); }
.ms-divider { font-size: 8px; color: var(--text-mid); text-align: center; padding-top: 4px; border-top: 1px solid var(--border); }
.ms-input-row { display: flex; gap: 4px; }
.ms-ghost-input { flex: 1; height: 20px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; }
.ms-ghost-input.ms-focus { border-color: var(--accent); }
.ms-sm-btn { font-size: 9px; font-weight: 600; background: linear-gradient(135deg, #5865f2, #7c3aed); color: #fff; padding: 0 7px; border-radius: 4px; display: flex; align-items: center; }

/* Offering steps */
.ms-steps { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.ms-step { display: flex; gap: 6px; align-items: flex-start; opacity: 1; }
.ms-dim { opacity: 0.28; }
.ms-step-hl .ms-n { box-shadow: 0 0 0 2px var(--accent); }
.ms-n {
  flex-shrink: 0;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.ms-sc { flex: 1; min-width: 0; }
.ms-lb { font-size: 8px; color: var(--text-mid); margin-bottom: 3px; }
.ms-link {
  font-family: monospace;
  font-size: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 5px;
  color: var(--text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-link em { color: var(--accent); font-style: normal; }
.ms-phrase {
  font-family: monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 3px 5px;
  letter-spacing: 0.02em;
}
.ms-waiting { font-size: 9px; color: var(--text-mid); font-style: italic; text-align: center; animation: pulse 2s ease-in-out infinite; }

/* Centered state screens */
.ms-center { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: 1; justify-content: center; text-align: center; }
.ms-lock { font-size: 22px; }
.ms-wt { font-size: 10px; color: var(--text-mid); }
.ms-h2 { font-size: 12px; font-weight: 700; color: var(--text); }
.ms-sub { font-size: 9px; color: var(--text-mid); }
.ms-pp {
  width: 100%;
  font-family: monospace;
  font-size: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 6px;
  min-height: 22px;
  color: var(--text);
  text-align: left;
}
.ms-pp-typed { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.ms-cur { animation: blink 1s step-end infinite; color: var(--accent); }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
.ms-unlock {
  font-size: 10px;
  font-weight: 600;
  background: linear-gradient(135deg, #5865f2, #7c3aed);
  color: #fff;
  padding: 5px 14px;
  border-radius: 5px;
}

/* Connected state */
.ms-conn-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: #22c55e;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 20px;
  padding: 5px 12px;
}
.ms-conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  animation: pulse 1.4s ease-in-out infinite;
}
.ms-enc { font-size: 9px; color: var(--text-mid); }

/* Chat screen */
.ms-chat { display: flex; flex-direction: column; gap: 6px; height: 100%; }
.ms-chat-top {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; color: var(--text-mid);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.ms-msgs { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.ms-msg {
  max-width: 82%;
  padding: 4px 7px;
  font-size: 9px;
  line-height: 1.4;
  border-radius: 8px;
  animation: msgPop 0.25s ease forwards;
}
@keyframes msgPop {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ms-own  { align-self: flex-end;   background: var(--own-bg);  color: var(--own-text); border-radius: 8px 2px 8px 8px; }
.ms-them { align-self: flex-start; background: var(--border);  color: var(--text);     border-radius: 2px 8px 8px 8px; }
.ms-composer { display: flex; gap: 4px; margin-top: auto; }
.ms-send { font-size: 8px; font-weight: 600; background: var(--accent); color: #fff; padding: 0 6px; border-radius: 3px; display: flex; align-items: center; }

/* Mobile: tighten device width */
@media (max-width: 540px) {
  .demo-device { width: 130px; }
  .demo-screen { height: 210px; padding: 9px 8px; }
  .demo-channels { min-width: 40px; max-width: 70px; gap: 14px; padding: 0 3px; }
  .demo-ch-tag { display: none; }
  .demo-heading { font-size: 17px; }
}

/* ── How it works (home page) ────────────────────────────────────────────── */
.how-anchor {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text-mid);
  text-decoration: none;
  margin-top: -4px;
  transition: color 0.15s;
}
.how-anchor:hover { color: var(--accent); }

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-mid);
}

.install-banner span { flex: 1; }

.install-banner .btn-accent {
  padding: 6px 14px;
  font-size: 12px;
  white-space: nowrap;
}

.install-dismiss {
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-mid);
}

.install-ios {
  text-align: center;
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.how-section {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

.how-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 16px;
  opacity: 0.75;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.how-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.how-card {
  background: var(--surface);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

[data-theme="light"] .how-card {
  background: rgba(255, 255, 255, 0.85);
}

.how-num-badge {
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.how-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.how-card p {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.65;
  margin: 0;
}

.how-card p strong { color: var(--text); }

/* ── Security credibility strip ─────────────────────────────────────────── */
.sec-strip {
  position: relative;
  z-index: 1;
  background: #080810;
  border-top: 1px solid rgba(88,101,242,0.25);
  border-bottom: 1px solid rgba(88,101,242,0.25);
  padding: 52px 24px;
  overflow: hidden;
}

.sec-ticker {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  overflow: hidden;
  pointer-events: none;
}

.sec-ticker-row {
  display: flex;
  white-space: nowrap;
  animation: sec-scroll-left 35s linear infinite;
}

.sec-ticker-row--rev {
  animation: sec-scroll-right 45s linear infinite;
}

.sec-ticker-track {
  font-family: 'Courier New', monospace;
  font-size: 33px;
  font-weight: 700;
  color: #00ff41;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.18;
  flex-shrink: 0;
}

@keyframes sec-scroll-left {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@keyframes sec-scroll-right {
  from { transform: translateX(-50%); }
  to   { transform: translateX(0); }
}

.sec-strip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 50% 0%, rgba(88,101,242,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.sec-strip-inner {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.sec-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #818cf8;
}

.sec-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.sec-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  line-height: 1.7;
  max-width: 480px;
}

.sec-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.sec-spec {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(88,101,242,0.1);
  border: 1px solid rgba(88,101,242,0.22);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 100px;
}

.sec-spec-val {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #a5b4fc;
  white-space: nowrap;
}

.sec-spec-label {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Use cases section ───────────────────────────────────────────────────── */
.usecases-section {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

.usecases-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.usecase-card {
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

[data-theme="light"] .usecase-card {
  background: rgba(255,255,255,0.85);
}

.usecase-card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.usecase-card p {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 400px) {
  .usecases-grid { grid-template-columns: 1fr; }
}

/* ── Handshake tooltips ──────────────────────────────────────────────────── */
.hs-tip {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}

.hs-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  opacity: 0.65;
  font-style: normal;
  transition: opacity 0.15s;
}

.hs-tip-icon:hover,
.hs-tip-icon:focus { opacity: 1; outline: none; }

.hs-tip-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
  padding: 8px 12px;
  border-radius: 8px;
  width: 230px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  white-space: normal;
}

.hs-tip:hover .hs-tip-text,
.hs-tip-icon:focus + .hs-tip-text {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 540px) {
  .hs-tip-text {
    left: 0;
    transform: translateY(4px);
    width: 200px;
  }
  .hs-tip:hover .hs-tip-text,
  .hs-tip-icon:focus + .hs-tip-text {
    transform: translateY(0);
  }

  /* On narrow phones, push the QR button to its own row */
  #hs-offering .hs-row {
    flex-wrap: wrap;
  }
  .hs-qr-btn {
    width: 100%;
    text-align: center;
  }
}

/* Prevent iOS Safari from zooming into focused inputs.
   Safari auto-zooms any input with font-size < 16px, causing
   a jarring jump. Targeting touch devices covers iPhones of any width. */
@media (hover: none) and (pointer: coarse) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ── History banner ──────────────────────────────────────────────────────── */
.history-banner {
  align-self: center;
  max-width: calc(100% - 24px);
  font-size: 12px;
  color: var(--text-mid);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px 14px;
  margin-bottom: 6px;
  text-align: center;
  flex-shrink: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Session code ────────────────────────────────────────────────────────── */
.session-lock {
  position: relative;
  font-family: monospace;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.85;
  cursor: help;
  white-space: nowrap;
}

.session-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: sans-serif;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  text-align: center;
  white-space: normal;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 100;
  pointer-events: none;
}

.session-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}

.session-lock:hover .session-tip,
.session-lock:focus-within .session-tip {
  display: block;
}

.peer-status-sep {
  color: var(--text-mid);
}

/* ── QR code panel ───────────────────────────────────────────────────────── */
.hs-qr-btn {
  flex-shrink: 0;
  font-size: 12px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
}

.hs-qr-wrap {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hs-qr-img {
  width: 192px;
  height: 192px;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}

.hs-qr-img svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hs-qr-hint {
  font-size: 12px;
  color: var(--text-mid);
  text-align: center;
  margin: 0;
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
}

#theme-toggle:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

/* home page theme toggle — fixed top-right */
.home-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

/* ── Cookie consent banner (Consent Mode v2) ─────────────────────────────── */
.consent-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.consent-text {
  flex: 1 1 320px;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-mid);
}

.consent-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

/* ── No-JavaScript fallback ───────────────────────────────────────────────── */
/* Btwinus is entirely JS-driven (crypto, WebRTC, UI). Without JS the chat
   cannot function, so we tell the user plainly instead of showing a dead page. */
.noscript-banner {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 10000;
  margin: 0;
  padding: 14px 20px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: #fff;
  background: linear-gradient(135deg, #5865f2 0%, #7c3aed 100%);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

.noscript-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
}

.noscript-screen h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.noscript-screen p {
  max-width: 460px;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-mid);
}

.consent-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.consent-btn {
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}

/* GDPR: decline must be as easy as accept — same visual weight */
.consent-decline {
  background: transparent;
  color: var(--text-mid);
}

.consent-decline:hover {
  border-color: var(--accent);
  color: var(--text);
}

.consent-accept {
  background: linear-gradient(135deg, #5865f2 0%, #7c3aed 100%);
  color: #fff;
  border-color: transparent;
}

@media (max-width: 520px) {
  .consent-bar { flex-direction: column; align-items: stretch; }
  .consent-actions { width: 100%; }
  .consent-btn { flex: 1; }
}

/* language picker — pill of 3 flags, fixed top-left on home */
.lang-picker {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lang-picker button {
  background: transparent;
  border: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms ease, background 120ms ease, transform 120ms ease;
}

.lang-picker button:hover { opacity: 0.9; }

.lang-picker button.active {
  background: var(--accent, #5865f2);
  opacity: 1;
  box-shadow: 0 0 10px rgba(88, 101, 242, 0.35);
}

.lang-picker .flag {
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  /* keep emoji rendering crisp on win/linux */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.home-lang-picker {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
}

[data-theme="light"] .lang-picker {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(88, 101, 242, 0.18);
}

/* ── Light mode overrides ────────────────────────────────────────────────── */
[data-theme="light"] .home-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(88, 101, 242, 0.15);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255,255,255,0.9) inset;
}

[data-theme="light"] .home-join input {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .hs-row input {
  background: var(--surface);
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 18px 6px;
  font-size: 12px;
  color: var(--text-mid);
  flex-shrink: 0;
  min-height: 24px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-mid);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.5; }
  30%            { transform: translateY(-4px); opacity: 1;   }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .my-id { display: none; }
  .msg { max-width: 88%; }
  .top-bar { padding: 10px 12px; }
}
