:root {
  --bg: #0a0a0b;
  --surface: #131316;
  --surface-2: #1a1a1f;
  --border: #2a2a32;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.5; }
#app { min-height: 100%; display: flex; flex-direction: column; }
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; color: inherit; }
textarea { font-family: inherit; }

/* ── Landing ── */
.landing { max-width: 520px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 24px; min-height: 100vh; justify-content: center; }
.logo-wrap { text-align: center; }
.logo { font-size: 42px; font-weight: 700; letter-spacing: 0.05em; }
.logo-sub { font-size: 20px; color: var(--accent); margin-top: 4px; }
.logo-en { font-size: 13px; color: var(--text-dim); margin-top: 6px; letter-spacing: 0.1em; }
.tagline { text-align: center; color: var(--text-dim); font-size: 14px; line-height: 1.7; }
.features { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 8px; }
.feature { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--surface); border-radius: 10px; border: 1px solid var(--border); }
.feature-icon { font-size: 18px; flex-shrink: 0; }
.feature-text { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

/* ── Buttons ── */
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 600; transition: opacity 0.15s, background 0.15s; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-dim); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 13px; }

/* ── Invite ── */
.invite-box { width: 100%; background: var(--surface); border-radius: 10px; padding: 16px; border: 1px solid var(--border); }
.invite-label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.invite-link-row { display: flex; gap: 8px; align-items: center; }
.invite-url { flex: 1; font-family: monospace; font-size: 12px; padding: 8px 10px; background: var(--bg); border-radius: 6px; border: 1px solid var(--border); word-break: break-all; user-select: all; }
.invite-actions { display: flex; gap: 12px; align-items: center; }

/* ── Security note ── */
.security-note { width: 100%; background: var(--surface); border-radius: 10px; padding: 14px; border: 1px solid var(--border); margin-top: 8px; }
.security-note-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.security-note ul { padding-left: 18px; font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.build-hash { font-size: 11px; color: var(--text-dim); font-family: monospace; }

/* ── Chat ── */
.chat-container { display: flex; flex-direction: column; height: 100vh; max-width: 680px; margin: 0 auto; width: 100%; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-title { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.status-dot.waiting { background: var(--warning); }
.status-dot.connected { background: var(--success); }
.chat-title-text { font-weight: 600; }
.chat-header-right { display: flex; align-items: center; gap: 8px; }
.chat-status { font-size: 12px; color: var(--text-dim); }
.call-btns { display: flex; gap: 4px; }
.btn-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 16px; background: var(--surface-2); transition: background 0.15s; }
.btn-icon:hover { background: var(--border); }
.btn-leave { padding: 4px 10px; font-size: 13px; background: var(--surface-2); border-radius: 6px; border: 1px solid var(--border); }

/* ── Messages ── */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; font-size: 14px; word-wrap: break-word; }
.msg.sent { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.received { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }
.msg.system { align-self: center; background: transparent; color: var(--text-dim); font-size: 12px; padding: 4px; }
.msg.error { align-self: center; color: var(--danger); font-size: 12px; }
.msg.media-loading { color: var(--text-dim); font-style: italic; }
.media-error { color: var(--danger) !important; }

/* Media inside messages */
.msg img.media-img { max-width: 100%; border-radius: 8px; cursor: pointer; display: block; }
.msg video.media-video { max-width: 100%; border-radius: 8px; display: block; }
.msg audio { width: 100%; margin-top: 4px; }
.media-caption { font-size: 12px; margin-bottom: 4px; }

/* ── Input area ── */
.chat-actions { display: flex; gap: 8px; padding: 6px 16px; }
.chat-input-area { padding: 8px 16px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.input-toolbar { display: flex; gap: 4px; margin-bottom: 6px; }
.file-input { display: none; }
.recording-bar { display: none; align-items: center; gap: 8px; padding: 4px 8px; margin-bottom: 6px; background: rgba(239,68,68,0.1); border-radius: 6px; font-size: 12px; }
.recording-bar.active { display: flex; }
.rec-timer { font-family: monospace; color: var(--danger); font-weight: 600; }
.rec-hint { color: var(--text-dim); }
.chat-input { display: flex; gap: 8px; }
.chat-input textarea { flex: 1; resize: none; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; line-height: 1.4; }
.chat-input textarea:focus { outline: none; border-color: var(--accent); }
.chat-input textarea:disabled { opacity: 0.5; }
.btn-send { padding: 0 16px; background: var(--accent); color: #fff; border-radius: 8px; font-weight: 600; display: flex; align-items: center; }
.btn-send:disabled { opacity: 0.3; }

/* ── Call overlay ── */
.call-overlay { display: none; position: fixed; inset: 0; z-index: 999; background: #000; flex-direction: column; }
.call-overlay.active { display: flex; }
.call-remote { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.call-remote video { width: 100%; height: 100%; object-fit: cover; }
.call-audio-indicator { display: none; flex-direction: column; align-items: center; gap: 16px; }
.call-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 36px; }
.call-info { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 13px; color: rgba(255,255,255,0.7); white-space: nowrap; }
.call-local { position: absolute; bottom: 16px; right: 16px; width: 120px; height: 160px; border-radius: 10px; overflow: hidden; border: 2px solid var(--border); background: var(--surface); }
.call-local video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.call-controls { display: flex; justify-content: center; gap: 16px; padding: 20px; background: rgba(0,0,0,0.5); }
.call-btn { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; transition: background 0.15s; }
.call-btn.hangup { background: var(--danger); }
.call-btn.muted { background: var(--warning); }
.call-btn.off { background: var(--text-dim); }

/* ── Incoming call ── */
.incoming-call { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.85); flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.incoming-call.active { display: flex; }
.incoming-call-icon { font-size: 48px; }
.incoming-call-text { font-size: 20px; font-weight: 600; }
.incoming-call-type { font-size: 14px; color: var(--text-dim); }
.incoming-call-actions { display: flex; gap: 24px; margin-top: 16px; }

/* ── Error page ── */
.error-page { max-width: 400px; margin: 80px auto; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.error-title { font-size: 22px; font-weight: 600; }
.error-text { color: var(--text-dim); white-space: pre-wrap; }

@media (max-width: 600px) {
  .msg { max-width: 85%; }
  .call-local { width: 90px; height: 120px; }
}
