﻿:root { --bg: #090a0f; --panel: #11131c; --card: #181b28; --hover: #212536; --accent: #10b981; --grad: linear-gradient(135deg, #10b981 0%, #06b6d4 100%); --text: #f1f5f9; --muted: #64748b; --border: #1e2230; }
body.light { --bg: #f1f5f9; --panel: #ffffff; --card: #e2e8f0; --hover: #cbd5e1; --text: #0f172a; --muted: #64748b; --border: #cbd5e1; }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { background: var(--bg); color: var(--text); height: 100dvh; overflow: hidden; }

#auth-screen { position: fixed; inset: 0; background: radial-gradient(circle at 20% 20%, #132229 0%, #090a0f 60%); display: flex; justify-content: center; align-items: center; padding: 20px; z-index: 50; }
.auth-box { width: 100%; max-width: 370px; background: #11131c; padding: 32px 26px; border-radius: 22px; border: 1px solid #1e2230; color: #f1f5f9; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; color: #051b14; margin: 0 auto 14px; }
.auth-box h2 { text-align: center; font-size: 22px; font-weight: 700; }
.auth-sub { text-align: center; color: #64748b; font-size: 13px; margin: 4px 0 20px; }
.tabs { display: flex; background: #090a0f; padding: 4px; border-radius: 12px; border: 1px solid #1e2230; margin-bottom: 18px; }
.tab { flex: 1; text-align: center; padding: 9px; font-size: 13px; font-weight: 600; color: #64748b; cursor: pointer; border-radius: 9px; }
.tab.active { background: #181b28; color: #f1f5f9; }
input { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; margin-bottom: 12px; outline: none; }
.auth-box input { background: #090a0f; border-color: #1e2230; color: #f1f5f9; }
input:focus { border-color: var(--accent); }
.btn-main { width: 100%; padding: 13px; border-radius: 12px; border: none; background: var(--grad); color: #041d15; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-danger { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid #f43f5e; background: rgba(244,63,94,0.12); color: #f43f5e; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; }
#auth-error { color: #f43f5e; font-size: 13px; text-align: center; min-height: 18px; margin-bottom: 8px; }

#app-screen { display: none; height: 100dvh; width: 100%; }
.sidebar { width: 310px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sb-top { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.profile-chip { display: flex; align-items: center; gap: 10px; }
.ava { width: 42px; height: 42px; border-radius: 50%; background: var(--grad); color: #041d15; font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; text-transform: uppercase; }
.ava.alt { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-tools { padding: 12px; border-bottom: 1px solid var(--border); }
.search-trigger { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--muted); padding: 10px 14px; border-radius: 11px; text-align: left; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; }
#chat-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; cursor: pointer; border: 1px solid transparent; }
.chat-row:hover { background: var(--hover); }
.chat-row.active { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.35); }

.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { background: var(--panel); padding: 13px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; min-height: 68px; }
.back-btn { display: none; background: var(--card); border: 1px solid var(--border); color: var(--text); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; }
.ghost-btn { background: var(--card); border: 1px solid var(--border); color: var(--muted); padding: 7px 11px; border-radius: 10px; font-size: 12px; cursor: pointer; }
#chat-box { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.empty-state { margin: auto; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 280px; }
.msg { max-width: 70%; padding: 11px 15px; border-radius: 16px 16px 16px 4px; background: var(--card); border: 1px solid var(--border); align-self: flex-start; word-wrap: break-word; }
.msg.mine { background: #132a24; border-color: rgba(16, 185, 129, 0.35); align-self: flex-end; border-radius: 16px 16px 4px 16px; }
body.light .msg.mine { background: #d1fae5; color: #064e3b; }
.msg .time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 4px; }
#block-banner { background: var(--panel); padding: 14px; text-align: center; color: #f43f5e; font-size: 13.5px; font-weight: 600; border-top: 1px solid var(--border); display: none; }
#input-area { background: var(--panel); padding: 12px 18px; display: none; gap: 10px; border-top: 1px solid var(--border); align-items: center; }
#msg-input { margin-bottom: 0; border-radius: 14px; background: var(--bg); }
#send-btn { background: var(--grad); border: none; color: #041d15; width: 44px; height: 44px; border-radius: 13px; font-size: 17px; font-weight: 800; cursor: pointer; flex-shrink: 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(5px); display: none; justify-content: center; align-items: flex-start; padding-top: 60px; z-index: 40; }
.modal-card { width: 92%; max-width: 390px; background: var(--panel); border-radius: 20px; padding: 20px; border: 1px solid var(--border); }
.user-row { padding: 10px 12px; border-radius: 12px; background: var(--card); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; border: 1px solid var(--border); }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; background: var(--card); border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--border); }
.bl-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; background: var(--card); border-radius: 10px; margin-bottom: 6px; border: 1px solid var(--border); font-size: 13px; }
.ava-hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 16px; }
.ava-ring { width: 78px; height: 78px; border-radius: 50%; padding: 3px; background: var(--grad); cursor: pointer; position: relative; transition: 0.2s; }
.ava-ring:hover { transform: scale(1.04); box-shadow: 0 0 20px rgba(16,185,129,0.4); }
.ava-inner { width: 100%; height: 100%; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; overflow: hidden; position: relative; }
.ava-inner img { width: 100%; height: 100%; object-fit: cover; }
.ava-cam { position: absolute; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; font-size: 20px; opacity: 0; transition: 0.2s; }
.ava-ring:hover .ava-cam { opacity: 1; }
.ava-remove { font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; margin-top: 8px; }
.ava-remove:hover { color: #f43f5e; }
@media (max-width: 768px) { .sidebar { width: 100%; } .chat-area { display: none; width: 100%; } body.in-chat .sidebar { display: none; } body.in-chat .chat-area { display: flex; } .back-btn { display: inline-block; } .msg { max-width: 84%; } }
.ticks { font-size: 11px; margin-left: 5px; font-weight: 700; color: var(--muted); }
.ticks.read { color: #06b6d4; }
body.light .ticks.read { color: #059669; }
.attach-btn { background: var(--card); border: 1px solid var(--border); color: var(--muted); width: 44px; height: 44px; border-radius: 13px; font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: 0.15s; }
.attach-btn:hover { color: var(--accent); border-color: var(--accent); }
.chat-img { max-width: 240px; max-height: 280px; border-radius: 12px; display: block; cursor: zoom-in; object-fit: cover; margin-bottom: 4px; }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(8px); display: none; justify-content: center; align-items: center; z-index: 60; cursor: zoom-out; padding: 20px; }
#lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.8); }
.img-caption { font-size: 14.5px; line-height: 1.4; margin-top: 6px; padding: 0 2px; }
.preview-img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 14px; background: var(--bg); margin-bottom: 12px; display: block; }
.preview-bar { display: flex; gap: 8px; align-items: center; }
.msg { position: relative; }
.msg-tools { display: none; gap: 4px; position: absolute; top: -14px; right: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 2px 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); z-index: 5; }
.msg:not(.mine) .msg-tools { right: auto; left: 8px; }
.msg:hover .msg-tools, .msg.selected .msg-tools { display: flex; }
.tool-ico { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 3px 5px; border-radius: 6px; }
.tool-ico:hover { color: var(--text); background: var(--card); }
.reply-quote { background: rgba(0,0,0,0.22); border-left: 3px solid var(--accent); padding: 5px 9px; border-radius: 6px; font-size: 12px; margin-bottom: 6px; opacity: 0.9; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edited-tag { font-size: 10px; opacity: 0.65; margin-right: 4px; font-style: italic; }
#action-banner { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 18px; display: none; justify-content: space-between; align-items: center; font-size: 13px; }
.ab-info { border-left: 3px solid var(--accent); padding-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html { scroll-behavior: smooth; }
#chat-box { scroll-behavior: smooth; }

@keyframes msgPop {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalFade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes cardSpring {
  0% { opacity: 0; transform: translateY(14px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.msg { animation: msgPop 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards; transition: transform 0.18s ease, opacity 0.2s ease, background 0.2s ease; }
.msg.removing { opacity: 0 !important; transform: scale(0.9) !important; }

.msg-tools { display: flex !important; opacity: 0; pointer-events: auto; transform: translateY(4px) scale(0.95); transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1); }
.msg:hover .msg-tools, .msg.selected .msg-tools { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }

.modal[style*="flex"], #lightbox[style*="flex"] { animation: modalFade 0.18s ease forwards; }
.modal[style*="flex"] .modal-card, #lightbox[style*="flex"] img { animation: cardSpring 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

button, .chat-row, .user-row, .tab { transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease; }
button:active, .chat-row:active, .user-row:active { transform: scale(0.97); }
#ptr-indicator { position: fixed; top: -48px; left: 50%; transform: translateX(-50%); width: 38px; height: 38px; border-radius: 50%; background: var(--panel); border: 1px solid var(--border); color: var(--accent); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(0,0,0,0.4); z-index: 70; transition: top 0.2s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s ease; pointer-events: auto; }
#ptr-indicator.spin svg { animation: ptrSpin 0.6s linear infinite; }
@keyframes ptrSpin { 100% { transform: rotate(360deg); } }
.rec-bar { flex: 1; display: none; align-items: center; justify-content: space-between; background: var(--bg); padding: 10px 16px; border-radius: 14px; border: 1px solid rgba(244, 63, 94, 0.4); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #f43f5e; animation: pulseRec 1s infinite; display: inline-block; margin-right: 8px; }
@keyframes pulseRec { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.85); } }
.voice-box { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 2px 0; }
.v-play { width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--accent); color: #041d15; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.msg.mine .v-play { background: var(--grad); }
.v-track { flex: 1; height: 4px; background: rgba(255,255,255,0.18); border-radius: 4px; overflow: hidden; cursor: pointer; position: relative; }
body.light .v-track { background: rgba(0,0,0,0.15); }
.v-fill { width: 0%; height: 100%; background: var(--accent); transition: width 0.1s linear; }
.v-dur { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.circle-overlay { position: fixed; inset: 0; background: rgba(9, 10, 15, 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 65; pointer-events: auto; }
.circle-ring { width: 240px; height: 240px; border-radius: 50%; padding: 4px; background: var(--grad); box-shadow: 0 0 40px rgba(16, 185, 129, 0.45); overflow: hidden; }
.circle-ring video { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; transform: scaleX(-1); background: #000; display: block; }
.msg.circle-msg { background: transparent !important; border: none !important; padding: 2px !important; box-shadow: none !important; }
.video-circle { width: 210px; height: 210px; border-radius: 50%; overflow: hidden; border: 2px solid var(--accent); position: relative; cursor: pointer; background: #000; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.video-circle video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.vc-badge { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.65); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; pointer-events: auto; }
#send-btn { touch-action: none; user-select: none; -webkit-user-select: none; }

.unread-dot { margin-left: auto; background: var(--accent); color: #041d15; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: none; align-items: center; justify-content: center; }
.call-overlay { position: fixed; inset: 0; background: rgba(9, 10, 15, 0.92); backdrop-filter: blur(16px); display: none; flex-direction: column; align-items: center; justify-content: space-between; padding: 48px 20px; z-index: 80; }
.call-videos { position: relative; width: 100%; max-width: 640px; flex: 1; display: flex; align-items: center; justify-content: center; margin: 16px 0; border-radius: 22px; overflow: hidden; background: var(--panel); border: 1px solid var(--border); }
#remote-video { width: 100%; height: 100%; object-fit: cover; display: none; }
#local-video { position: absolute; bottom: 14px; right: 14px; width: 110px; height: 150px; object-fit: cover; border-radius: 14px; border: 2px solid var(--accent); transform: scaleX(-1); display: none; background: #000; z-index: 2; }
.call-ava-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.call-controls { display: flex; gap: 16px; align-items: center; }
.c-btn { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.c-btn.active { background: var(--text); color: var(--bg); }
.c-btn.accept { background: #10b981; border-color: #10b981; color: #041d15; }
.c-btn.hangup { background: #f43f5e; border-color: #f43f5e; color: #fff; }
#call-peer-ava { transition: box-shadow 0.12s ease, transform 0.12s ease; border: 3px solid transparent; }
#call-peer-ava.speaking { border-color: #10b981; box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.25), 0 0 28px rgba(16, 185, 129, 0.65); transform: scale(1.06); }
#voice-state-pill { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; padding: 4px 12px; border-radius: 20px; background: var(--card); color: var(--muted); border: 1px solid var(--border); transition: all 0.15s ease; display: none; }
#voice-state-pill.active { background: rgba(16, 185, 129, 0.16); color: #10b981; border-color: rgba(16, 185, 129, 0.45); }
.sb-tools { display: flex; gap: 8px; }
.new-grp-btn { background: var(--bg); border: 1px solid var(--border); color: var(--muted); width: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.new-grp-btn:hover { color: var(--accent); border-color: var(--accent); }
.sender-label { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.sys-call-pill { align-self: center; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 6px 14px; border-radius: 20px; display: flex; align-items: center; gap: 7px; margin: 4px 0; animation: msgPop 0.24s ease forwards; }
.sys-call-pill.missed { color: #f43f5e; border-color: rgba(244, 63, 94, 0.3); }
.peer-modal-ava { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 12px; cursor: zoom-in; border: 2px solid var(--accent); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; background: var(--card); }
.peer-modal-ava img { width: 100%; height: 100%; object-fit: cover; }
#lightbox { flex-direction: column; justify-content: space-between; padding: 18px; cursor: default; }
.lb-top { width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 2; color: #f1f5f9; }
.lb-actions { display: flex; gap: 8px; }
.lb-btn { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18); color: #fff; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(8px); }
.lb-btn:hover { background: rgba(255,255,255,0.22); }
.lb-stage { position: relative; flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#lightbox-img { max-width: 90vw; max-height: 82vh; border-radius: 14px; object-fit: contain; user-select: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(17,19,28,0.75); border: 1px solid rgba(255,255,255,0.15); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; }
.lb-nav:hover { background: var(--accent); color: #041d15; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.pm-media-head { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; }
.pm-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 210px; overflow-y: auto; }
.pm-media-grid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; border: 1px solid var(--border); transition: transform 0.15s ease; }
.pm-media-grid img:hover { transform: scale(1.03); border-color: var(--accent); }
