*{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#fafafa;--surface:#fff;--surface2:#f0f0f0;--border:#dbdbdb;
  --text:#262626;--muted:#8e8e8e;--accent:#0095f6;
  --grad:linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888);
  --font:'DM Sans',sans-serif;
}
html,body{height:100%;height:100dvh;overflow:hidden;background:var(--bg);color:var(--text);font-family:var(--font)}
input,textarea,button{font-family:var(--font)}
#app-shell{width:100%;max-width:480px;margin:0 auto;height:100vh;height:100dvh;display:flex;flex-direction:column;background:var(--surface);position:relative;box-shadow:0 0 40px rgba(0,0,0,.08)}
.screen{display:none;width:100%;height:100%;position:absolute;top:0;left:0}
.screen.active{display:flex}
/* AUTH */
.auth-wrap{width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:var(--bg);overflow-y:auto}
.auth-box{width:100%;max-width:360px;padding:20px}
.auth-logo-text{font-family:'Dancing Script',cursive;font-size:52px;font-weight:700;background:linear-gradient(45deg,#405de6,#5851db,#833ab4,#c13584,#e1306c,#fd1d1d);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;text-align:center;margin-bottom:8px}
.auth-logo{text-align:center;margin-bottom:4px;display:flex;flex-direction:column;align-items:center;gap:0px}
.auth-card{background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:28px 32px 20px;margin-bottom:10px}
.auth-card input{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:6px;font-size:13px;background:#fafafa;margin-bottom:8px;outline:none;color:var(--text);transition:.2s;display:block}
.auth-card input:focus{border-color:#aaa;background:#fff}
.btn-main{width:100%;padding:9px;background:var(--accent);color:#fff;border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;margin-top:8px;transition:.2s}
.btn-main:hover{opacity:.85}
.auth-desc{text-align:center;font-size:16px;font-weight:600;margin-bottom:16px;font-family:'Playfair Display',serif;line-height:1.4}
.auth-switch{background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:14px;text-align:center;font-size:13px;color:var(--muted)}
.auth-switch span{color:var(--accent);font-weight:600;cursor:pointer}
.auth-error{color:#ed4956;font-size:12px;text-align:center;margin-top:6px;min-height:16px}
/* APP */
.app-wrap{width:100%;height:100%;display:flex;flex-direction:column}
.top-nav{background:var(--surface);border-bottom:1px solid var(--border);padding:0 16px;height:54px;display:flex;align-items:center;justify-content:center;flex-shrink:0;z-index:10}
.logo-wrap{display:flex;align-items:center;gap:4px}
.logo{font-family:'Dancing Script',cursive;font-size:28px;font-weight:700;background:linear-gradient(90deg,#c13584,#833ab4,#405de6);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
/* Profile avatar photo */
.pp-avatar{width:100%;height:100%;border-radius:50%;object-fit:cover;display:block;border:3px solid #fff}
.pp-clickable{cursor:pointer}
.pp-edit-overlay{position:absolute;inset:0;border-radius:50%;background:rgba(0,0,0,.42);display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .2s;pointer-events:none}
.pp-clickable:hover .pp-edit-overlay{opacity:1}
.content-area{flex:1;overflow:hidden;position:relative}
.tab-panel{display:none;width:100%;height:100%;overflow-y:auto}
.tab-panel.active{display:block}
.bottom-nav{background:var(--surface);border-top:1px solid var(--border);display:flex;flex-direction:column;flex-shrink:0}
.bottom-nav::after{content:'';height:env(safe-area-inset-bottom);background:var(--surface)}
.bottom-nav .nav-row{display:flex;height:52px;width:100%}
.nav-item{flex:1;display:flex;align-items:center;justify-content:center;cursor:pointer;position:relative}
.nav-item svg{color:var(--text)}
.nav-item.active::after{content:'';position:absolute;top:6px;width:4px;height:4px;border-radius:50%;background:var(--text)}
.nav-add-post{flex:1.2}
.add-post-btn{width:44px;height:44px;border-radius:50%;background:var(--grad);display:flex;align-items:center;justify-content:center;box-shadow:0 2px 12px rgba(0,0,0,.18);transition:transform .15s,box-shadow .15s}
.add-post-btn svg{color:#fff;stroke:#fff}
.nav-add-post:active .add-post-btn{transform:scale(.92);box-shadow:0 1px 6px rgba(0,0,0,.12)}
/* FEED */
.feed-container{max-width:480px;margin:0 auto;padding-bottom:16px}
.stories-row{display:flex;gap:14px;padding:14px 16px 10px;overflow-x:auto;border-bottom:1px solid var(--border)}
.stories-row::-webkit-scrollbar{display:none}
.story-item{display:flex;flex-direction:column;align-items:center;gap:5px;cursor:pointer;flex-shrink:0}
.story-ring{width:58px;height:58px;border-radius:50%;background:var(--grad);padding:2px}
.story-inner{width:100%;height:100%;border-radius:50%;background:var(--surface);border:2.5px solid var(--surface);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600}
.story-name{font-size:11px;text-align:center;max-width:66px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.post-card{background:var(--surface);border-bottom:1px solid var(--border)}
.post-header{display:flex;align-items:center;gap:10px;padding:10px 14px}
.post-avatar{width:34px;height:34px;border-radius:50%;background:var(--grad);padding:2px;cursor:pointer;flex-shrink:0}
.av-inner{width:100%;height:100%;border-radius:50%;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;border:2px solid #fff}
.post-user{font-size:13px;font-weight:600;cursor:pointer;flex:1}
.post-image{width:100%;max-height:600px;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:80px;overflow:hidden}
.post-image img{width:100%;height:100%;max-height:600px;object-fit:contain;display:block;background:var(--surface2)}
.post-actions{display:flex;align-items:center;gap:14px;padding:10px 14px 6px}
.post-actions svg{cursor:pointer;color:var(--text)}
.post-actions .save{margin-left:auto}
.liked svg{color:#ed4956!important}
.post-likes{padding:0 14px 4px;font-size:13px;font-weight:600}
.post-caption{padding:0 14px 8px;font-size:13px;line-height:1.5}
.post-caption strong{font-weight:600;cursor:pointer;margin-right:4px}
.post-time{padding:0 14px 10px;font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.3px}
/* SEARCH */
.search-container{padding:12px 16px}
.search-bar{display:flex;align-items:center;gap:8px;background:var(--surface2);border-radius:10px;padding:8px 12px}
.search-bar input{background:none;border:none;outline:none;font-size:14px;flex:1;color:var(--text)}
.search-placeholder{padding:40px;text-align:center;color:var(--muted);font-size:14px}
.user-result{display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid var(--border);cursor:pointer;transition:.1s}
.user-result:hover{background:var(--surface2)}
.u-av{width:46px;height:46px;border-radius:50%;background:var(--grad);padding:2px;flex-shrink:0}
.u-av-inner{width:100%;height:100%;border-radius:50%;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:600;border:2px solid #fff}
.u-info p:first-child{font-size:14px;font-weight:600}
.u-info p:last-child{font-size:12px;color:var(--muted)}
/* CHAT */
.chat-list-view{display:flex;flex-direction:column;height:100%}
.chat-list-header{padding:14px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
.chat-list-header h2{font-size:18px;font-weight:700}
.chat-thread{display:flex;align-items:center;gap:12px;padding:12px 16px;cursor:pointer;transition:.1s}
.chat-thread:hover{background:var(--surface2)}
.t-av{width:50px;height:50px;border-radius:50%;background:var(--grad);padding:2px;flex-shrink:0}
.t-av-inner{width:100%;height:100%;border-radius:50%;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:600;border:2px solid #fff}
.t-info{flex:1;min-width:0}
.t-name{font-size:14px;font-weight:600}
.t-preview{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.t-time{font-size:11px;color:var(--muted);flex-shrink:0}
.chat-window-panel{display:none;flex-direction:column;height:100%}
.chat-window-panel.open{display:flex}
.chat-win-header{padding:12px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:12px;flex-shrink:0;background:var(--surface)}
.back-btn{background:none;border:none;cursor:pointer;color:var(--text);display:flex;padding:0}
.cw-av{width:34px;height:34px;border-radius:50%;background:var(--grad);padding:2px;flex-shrink:0}
.cw-av-inner{width:100%;height:100%;border-radius:50%;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;border:2px solid #fff}
.cw-name{font-size:15px;font-weight:600;flex:1}
.chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:8px}
.msg-row{display:flex;align-items:center;gap:4px;padding-bottom:4px}
.msg-row.mine{flex-direction:row-reverse}
.msg-bubble-wrap{display:flex;flex-direction:column;max-width:68%}
.msg-row.mine .msg-bubble-wrap{align-items:flex-end}
.msg-row.other .msg-bubble-wrap{align-items:flex-start}
.msg-bubble{padding:9px 14px;border-radius:20px;font-size:14px;line-height:1.4;word-break:break-word;cursor:pointer;-webkit-user-select:none;user-select:none}
.msg-row.mine .msg-bubble{background:var(--accent);color:#fff;border-bottom-right-radius:4px}
.msg-row.other .msg-bubble{background:var(--surface2);color:var(--text);border-bottom-left-radius:4px}
.msg-time{display:none}
/* Standalone timestamp row — always rendered AFTER the reactions wrap */
.msg-time-row{font-size:11px;color:var(--muted);padding:2px 18px 4px;display:flex;align-items:center;gap:4px}
.msg-time-row.mine{justify-content:flex-end}
.msg-time-row.other{justify-content:flex-start}
.msg-dots-btn{background:none;border:none;cursor:pointer;color:var(--muted);display:none;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;padding:0;flex-shrink:0;transition:.1s}
.msg-dots-btn.visible{display:flex}
.msg-dots-btn:hover{background:var(--surface2);color:var(--text)}
.msg-reactions-wrap{display:flex;gap:4px;padding:0 14px 0;flex-wrap:wrap;position:relative;z-index:1;margin-top:-12px}
.msg-reactions-wrap:empty{margin-top:0;padding:0;height:0}
.msg-reactions-wrap.mine{justify-content:flex-end;padding-right:18px}
.msg-reactions-wrap.other{justify-content:flex-start;padding-left:18px}
.msg-reaction{background:var(--surface);border:1px solid var(--border);border-radius:20px;padding:3px 8px;font-size:15px;cursor:pointer;transition:.1s;line-height:1.4;box-shadow:0 1px 4px rgba(0,0,0,.12)}
.msg-reaction:hover{background:var(--surface2);transform:scale(1.15)}
.chat-input-row{padding:10px 12px;border-top:1px solid var(--border);display:flex;align-items:center;gap:10px;flex-shrink:0;background:var(--surface)}
.chat-input-row input{flex:1;border:1px solid var(--border);border-radius:22px;padding:9px 16px;font-size:14px;outline:none;background:var(--surface2);color:var(--text);transition:.2s}
.chat-input-row input:focus{border-color:var(--accent);background:#fff}
.send-btn{background:var(--accent);border:none;border-radius:50%;width:36px;height:36px;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0}
.new-chat-search{padding:10px 16px;border-bottom:1px solid var(--border)}
.new-chat-search input{width:100%;border:1px solid var(--border);border-radius:10px;padding:8px 12px;font-size:13px;outline:none;background:var(--surface2);color:var(--text)}
/* PROFILE */
.profile-container{max-width:480px;margin:0 auto}
.profile-header{padding:20px 16px 0}
.profile-top{display:flex;align-items:center;gap:20px;margin-bottom:16px}
.profile-pic{width:82px;height:82px;border-radius:50%;background:var(--grad);padding:3px;flex-shrink:0}
.pp-inner{width:100%;height:100%;border-radius:50%;background:var(--surface2);display:flex;align-items:center;justify-content:center;font-size:26px;font-weight:700;border:3px solid #fff}
.profile-stats{display:flex;flex:1;justify-content:space-around}
.stat-item{text-align:center}
.s-num{font-size:17px;font-weight:700}
.s-label{font-size:12px}
.p-name{font-size:14px;font-weight:600;margin-bottom:3px}
.p-bio,.p-web{font-size:13px;line-height:1.5}
.p-web{color:var(--accent);font-weight:600}
.profile-btns{display:flex;gap:6px;margin-top:14px;margin-bottom:12px}
.profile-btns button{flex:1;padding:7px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:1.5px solid var(--border);background:var(--surface2);color:var(--text);transition:.2s}
.profile-btns button:hover{background:var(--border)}
.btn-follow{background:var(--accent)!important;color:#fff!important;border-color:var(--accent)!important}
.profile-tabs{display:flex;border-top:1px solid var(--border);border-bottom:1px solid var(--border)}
.pt{flex:1;padding:10px;text-align:center;border-top:2px solid transparent;font-size:13px;font-weight:600;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:5px}
.pt.active{border-top-color:var(--text);color:var(--text)}
.profile-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:2px}
.profile-grid-item{aspect-ratio:1;background:var(--surface2);overflow:hidden;cursor:pointer}
.profile-grid-item img{width:100%;height:100%;object-fit:cover;display:block;transition:.2s}
.profile-grid-item:hover img{transform:scale(1.05)}
.emoji-post{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:40px}
.empty-posts{grid-column:1/-1;padding:40px;text-align:center;color:var(--muted);font-size:14px}
.back-link{display:flex;align-items:center;gap:6px;padding:12px 16px 0;font-size:14px;font-weight:600;cursor:pointer}
.back-link:hover{opacity:.6}
/* MODALS */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.65);z-index:200;display:none;align-items:center;justify-content:center}
.modal-overlay.open{display:flex}
.modal-box{background:var(--surface);border-radius:12px;width:90%;max-width:420px;overflow:hidden;max-height:90vh;overflow-y:auto}
.modal-header{padding:14px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:var(--surface)}
.modal-header h3{font-size:15px;font-weight:600}
.close-btn{background:none;border:none;font-size:26px;cursor:pointer;color:var(--text);line-height:1}
.upload-area{padding:20px}
.upload-drop{border:2px dashed var(--border);border-radius:12px;padding:32px 20px;cursor:pointer;text-align:center;transition:.2s;position:relative}
.upload-drop:hover{border-color:var(--accent);background:#f5faff}
.upload-drop input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.upload-area textarea{width:100%;border:1px solid var(--border);border-radius:8px;padding:10px;font-size:13px;resize:none;color:var(--text);outline:none;height:80px;margin-top:12px;display:block}
.upload-area textarea:focus{border-color:var(--accent)}
.btn-post{width:100%;padding:10px;background:var(--accent);color:#fff;border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;margin-top:10px}
.edit-form{padding:16px}
.edit-form label{font-size:12px;font-weight:600;color:var(--muted);display:block;margin-bottom:4px;text-transform:uppercase;letter-spacing:.5px}
.edit-form input,.edit-form textarea{width:100%;border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:13px;outline:none;color:var(--text);background:var(--bg);margin-bottom:14px;display:block;transition:.2s}
.edit-form input:focus,.edit-form textarea:focus{border-color:var(--accent);background:#fff}
.edit-form textarea{resize:none;height:72px}
.btn-save{width:100%;padding:10px;background:var(--accent);color:#fff;border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer}
.toast{position:fixed;bottom:72px;left:50%;transform:translateX(-50%);background:#262626;color:#fff;padding:10px 20px;border-radius:20px;font-size:13px;z-index:500;opacity:0;transition:.3s;pointer-events:none;white-space:nowrap}
.toast.show{opacity:1}
.loader{text-align:center;padding:30px;color:var(--muted);font-size:13px}
/* SPINNER */
.spinner{width:32px;height:32px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin 0.8s linear infinite;margin:0 auto}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes ss-pulse{0%,100%{opacity:1}50%{opacity:.45}}
@keyframes fadeInOverlay{from{opacity:0}to{opacity:1}}
@keyframes slideUpSheet{from{transform:translateY(100%)}to{transform:translateY(0)}}
.loader{text-align:center;padding:40px 20px}
/* PULL TO REFRESH */
.ptr-indicator{position:fixed;top:54px;left:50%;transform:translateX(-50%);background:var(--surface);border:1px solid var(--border);border-radius:20px;padding:8px 16px;font-size:13px;color:var(--muted);display:flex;align-items:center;gap:8px;z-index:50;opacity:0;transition:opacity .2s;pointer-events:none;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.ptr-indicator.visible{opacity:1}
.ptr-spinner{width:16px;height:16px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}

.pass-wrap{position:relative;margin-bottom:8px}
.pass-wrap input{width:100%;margin-bottom:0;padding-right:42px}
.pass-wrap .eye-btn{position:absolute;right:12px;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--muted);display:flex;align-items:center;justify-content:center;padding:0;transition:.2s}
.pass-wrap .eye-btn:hover{color:var(--text)}

/* ── STORY VIEWER ────────────────────────────────────── */
/* Progress bars */
.sv-bars{position:absolute;top:0;left:0;right:0;display:flex;gap:3px;padding:10px 10px 6px;z-index:10}
.sv-bar-bg{flex:1;height:3px;background:rgba(255,255,255,.35);border-radius:2px;overflow:hidden}
.sv-bar-fill{height:100%;background:#fff;border-radius:2px;transition:none}
/* Header */
.sv-header{position:absolute;top:22px;left:0;right:0;display:flex;align-items:center;padding:0 12px;z-index:10;gap:8px}
/* Media area */
.sv-media{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#000}
/* Footer */
.sv-footer{position:absolute;bottom:0;left:0;right:0;display:flex;align-items:center;gap:10px;padding:12px 12px calc(12px + env(safe-area-inset-bottom));z-index:10;background:linear-gradient(to top,rgba(0,0,0,.6) 0%,transparent 100%)}
.sv-reply-wrap{flex:1;display:flex;align-items:center;gap:8px}
.sv-reply-wrap input::placeholder{color:rgba(255,255,255,.6)}

/* ── STORY RING pulse for new stories ────────────────── */
@keyframes story-ring-glow{0%,100%{box-shadow:0 0 0 0 rgba(193,53,132,.5)}50%{box-shadow:0 0 0 5px rgba(193,53,132,0)}}
.story-ring{animation:story-ring-glow 2s ease-in-out infinite}
.story-ring[style*="background:var(--border)"]{animation:none}

/* ── Real-time messaging status ──────────────────────────────── */

/* Chat header: online status subtitle */
.cw-status{
  font-size:11px;
  color:var(--muted);
  line-height:1.2;
  transition:color .3s;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.cw-status.cw-online{
  color:#22c55e;
  font-weight:600;
}

/* Thread list: online dot on avatar */
.t-av{position:relative}
.thread-online-dot{
  position:absolute;
  bottom:1px;right:1px;
  width:11px;height:11px;
  border-radius:50%;
  background:#22c55e;
  border:2px solid var(--surface);
  animation:pulse-online 2s ease-in-out infinite;
}
@keyframes pulse-online{
  0%,100%{box-shadow:0 0 0 0 rgba(34,197,94,.5)}
  50%{box-shadow:0 0 0 4px rgba(34,197,94,0)}
}

/* Message tick (✓ / ✓✓ grey / ✓✓ blue) — lives inside .msg-time-row */
.msg-tick{
  display:inline-flex;
  align-items:center;
  flex-shrink:0;
  margin-left:2px;
  transition:opacity .2s;
}
.msg-tick svg{
  transition:stroke .35s cubic-bezier(.4,0,.2,1);
  display:block;
}
/* animate tick state changes */
@keyframes tick-pop{
  0%  {transform:scale(1)}
  40% {transform:scale(1.4)}
  100%{transform:scale(1)}
}
.msg-tick.tick-delivered svg,
.msg-tick.tick-seen svg{
  animation:tick-pop .3s ease;
}

/* Typing / recording activity indicator row */
.activity-row{
  display:flex;
  align-items:center;
  padding:4px 0;
  animation:fadeInOverlay .2s ease;
}

/* Typing bubble — animated three dots */
.typing-bubble{
  background:var(--surface2);
  border-radius:20px;
  padding:10px 16px;
  display:flex;
  align-items:center;
  gap:5px;
  border-bottom-left-radius:4px;
}
.t-dot{
  width:7px;height:7px;
  border-radius:50%;
  background:var(--muted);
  display:inline-block;
  animation:typing-bounce 1.4s infinite ease-in-out both;
}
.t-dot:nth-child(1){animation-delay:-0.32s}
.t-dot:nth-child(2){animation-delay:-0.16s}
.t-dot:nth-child(3){animation-delay:0s}
@keyframes typing-bounce{
  0%,80%,100%{transform:scale(0.7);opacity:.5}
  40%{transform:scale(1);opacity:1}
}

/* Recording bubble */
.recording-bubble{
  background:#fdecea;
  border:1px solid #ed495640;
  border-radius:20px;
  border-bottom-left-radius:4px;
  padding:9px 14px;
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  color:#ed4956;
  font-weight:600;
}
.rec-pulse{
  width:9px;height:9px;
  border-radius:50%;
  background:#ed4956;
  flex-shrink:0;
  animation:rec-blink .9s ease-in-out infinite;
}
@keyframes rec-blink{
  0%,100%{opacity:1;transform:scale(1)}
  50%{opacity:.3;transform:scale(.75)}
}

/* ── CALLING SYSTEM ────────────────────────────────────────── */

/* Call icon buttons in chat header */
.call-icon-btn{
  background:none;border:none;cursor:pointer;
  color:var(--text);display:flex;align-items:center;justify-content:center;
  width:36px;height:36px;border-radius:50%;transition:.15s;flex-shrink:0;
}
.call-icon-btn:hover{background:var(--surface2)}

/* Base overlay */
.call-overlay{
  position:fixed;inset:0;z-index:800;
  background:linear-gradient(160deg,#1a1a2e 0%,#16213e 50%,#0f3460 100%);
  display:none;flex-direction:column;align-items:center;justify-content:center;
  animation:fadeInOverlay .3s ease;
}
.call-overlay.open{display:flex}

/* Overlay card (incoming / outgoing) */
.call-overlay-card{
  display:flex;flex-direction:column;align-items:center;gap:12px;
  width:100%;max-width:400px;padding:40px 24px;
}

/* Avatar in overlay */
.call-overlay-av{
  width:90px;height:90px;border-radius:50%;
  background:linear-gradient(135deg,#405de6,#833ab4,#c13584);
  display:flex;align-items:center;justify-content:center;
  font-size:28px;font-weight:700;color:#fff;
  box-shadow:0 0 0 8px rgba(255,255,255,.08),0 0 0 16px rgba(255,255,255,.04);
  animation:call-ring-pulse 2s ease-in-out infinite;
}
@keyframes call-ring-pulse{
  0%,100%{box-shadow:0 0 0 8px rgba(255,255,255,.08),0 0 0 16px rgba(255,255,255,.04)}
  50%{box-shadow:0 0 0 12px rgba(255,255,255,.12),0 0 0 24px rgba(255,255,255,.06)}
}

.call-overlay-name{
  font-size:24px;font-weight:700;color:#fff;text-align:center;
  max-width:280px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.call-overlay-type{
  font-size:14px;color:rgba(255,255,255,.6);text-align:center;margin-top:-4px;
}
.call-overlay-status{
  font-size:14px;color:rgba(255,255,255,.7);text-align:center;
  animation:ss-pulse 1.8s ease-in-out infinite;
}

/* Accept / Decline buttons */
.call-btn-row{
  display:flex;justify-content:space-around;width:100%;
  margin-top:24px;gap:40px;
}
.call-action-btn{
  width:66px;height:66px;border-radius:50%;border:none;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:transform .15s,box-shadow .15s;
}
.call-action-btn:active{transform:scale(.9)}
.call-action-btn.accept{
  background:linear-gradient(135deg,#22c55e,#16a34a);
  box-shadow:0 4px 20px rgba(34,197,94,.45);
  color:#fff;
}
.call-action-btn.decline{
  background:linear-gradient(135deg,#ef4444,#dc2626);
  box-shadow:0 4px 20px rgba(239,68,68,.45);
  color:#fff;
}

/* Active call overlay */
.call-overlay.call-active{
  justify-content:space-between;padding:env(safe-area-inset-top,20px) 0 env(safe-area-inset-bottom,20px);
}
.call-active-info{
  display:flex;flex-direction:column;align-items:center;gap:8px;
  padding-top:max(env(safe-area-inset-top),40px);
  width:100%;
}
.call-controls{
  display:flex;justify-content:center;align-items:center;gap:16px;
  padding-bottom:max(env(safe-area-inset-bottom),30px);
  width:100%;flex-wrap:wrap;
}
.call-ctrl-btn{
  width:58px;height:58px;border-radius:50%;border:none;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.15);color:#fff;
  transition:background .15s,transform .15s;
  backdrop-filter:blur(8px);
}
.call-ctrl-btn:hover{background:rgba(255,255,255,.25)}
.call-ctrl-btn:active{transform:scale(.9)}
.call-ctrl-btn.active{background:rgba(255,255,255,.85);color:#1a1a2e}
.call-ctrl-btn.end-call{
  background:linear-gradient(135deg,#ef4444,#dc2626);
  box-shadow:0 4px 20px rgba(239,68,68,.45);
  width:66px;height:66px;
}
/* ════════════════════════════════════════════════════════════════
   MEDIA SHARING STYLES
   ════════════════════════════════════════════════════════════════ */

/* Attachment button */
.attach-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.attach-btn:hover { background: var(--surface2); color: var(--accent); }

/* Drag-over state on chat messages */
.chat-messages.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

/* ── Upload progress bubble ───────────────────────────────────── */
.media-upload-bubble {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 200px; max-width: 260px;
}
.media-upload-icon { font-size: 26px; flex-shrink: 0; }
.media-upload-info { flex: 1; min-width: 0; }
.media-upload-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-upload-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.media-upload-bar-wrap {
  height: 4px; border-radius: 4px;
  background: var(--border);
  margin-top: 8px; overflow: hidden;
}
.media-upload-bar {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #00d4ff);
  width: 0%; transition: width .2s;
}
.media-upload-footer {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
}
.media-cancel-btn, .media-retry-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted);
  padding: 0 4px; line-height: 1;
}
.media-cancel-btn:hover { color: #ed4956; }
.media-retry-btn:hover  { color: var(--accent); }

/* ── Media message bubbles ────────────────────────────────────── */
.msg-bubble-media {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 14px !important;
  overflow: hidden;
  max-width: 260px;
}

/* Image bubble */
.media-bubble-image {
  position: relative; cursor: pointer;
  border-radius: 14px; overflow: hidden;
  max-width: 240px;
}
.media-thumb {
  display: block; width: 100%; max-width: 240px;
  min-height: 80px; object-fit: cover;
  border-radius: 14px;
  background: var(--surface2);
}
.media-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 8px; border-radius: 14px;
  transition: background .2s;
}
.media-bubble-image:hover .media-overlay,
.media-bubble-video:hover .media-overlay { background: rgba(0,0,0,.25); }
.media-dl-btn {
  background: rgba(0,0,0,.5); color: #fff;
  border: none; border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px;
  opacity: 0; transition: opacity .2s;
}
.media-bubble-image:hover .media-dl-btn,
.media-bubble-video:hover .media-dl-btn { opacity: 1; }

/* Video bubble */
.media-bubble-video {
  position: relative; cursor: pointer;
  border-radius: 14px; overflow: hidden;
  max-width: 240px; min-height: 120px;
  background: #000;
}
.media-video-placeholder {
  width: 240px; height: 140px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; background: var(--surface2);
}
.media-play-btn {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
  pointer-events: none;
}

/* Audio bubble */
.media-bubble-audio {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 10px 12px;
  max-width: 260px;
}
.media-audio-icon { font-size: 22px; flex-shrink: 0; }
.media-audio-info { flex: 1; min-width: 0; }

/* Document / file bubble */
.media-bubble-file {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px;
  max-width: 260px;
}
.media-file-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.media-file-info { flex: 1; min-width: 0; }
.media-file-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.media-dl-icon-btn {
  background: var(--surface2); border: none;
  border-radius: 50%; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); font-size: 15px;
  flex-shrink: 0; transition: background .15s;
}
.media-dl-icon-btn:hover { background: var(--accent); color: #fff; }

/* ── Media viewer (lightbox) ─────────────────────────────────── */
.media-viewer-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.95);
  display: none; flex-direction: column;
}
.media-viewer-overlay.open { display: flex; }
.mv-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; flex-shrink: 0;
}
.mv-title { color: #fff; font-size: 14px; font-weight: 600; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-actions { display: flex; gap: 8px; }
.mv-btn {
  background: rgba(255,255,255,.1); border: none;
  color: #fff; border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; transition: background .15s;
}
.mv-btn:hover { background: rgba(255,255,255,.2); }
.mv-close { font-size: 20px; }
.mv-content {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 16px;
}
.mv-image {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 8px;
  transition: transform .2s;
  cursor: zoom-in;
}
.mv-video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.mv-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.15); border: none;
  color: #fff; font-size: 32px;
  width: 48px; height: 64px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2; transition: background .15s;
}
.mv-nav:hover { background: rgba(255,255,255,.3); }
.mv-nav-prev { left: 12px; }
.mv-nav-next { right: 12px; }

/* ── Shared media panel ──────────────────────────────────────── */
.shared-media-panel {
  position: fixed; inset: 0; z-index: 355;
  background: var(--surface);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
  pointer-events: all;
}
.shared-media-panel.open { transform: translateX(0); }
.smp-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.smp-title { font-size: 17px; font-weight: 700; }
.smp-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap;
}
.smp-search {
  flex: 1; min-width: 120px;
  height: 36px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text); padding: 0 12px;
  font-size: 13px;
}
.smp-filter {
  height: 36px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  padding: 0 8px; font-size: 13px; cursor: pointer;
}
.smp-body { flex: 1; overflow-y: auto; padding: 16px; }
.smp-section { margin-bottom: 24px; }
.smp-section-title {
  font-size: 14px; font-weight: 700;
  color: var(--muted); margin-bottom: 10px;
}
.smp-grid-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
}
.smp-grid-files { display: flex; flex-direction: column; gap: 8px; }
.smp-media-card {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden;
  cursor: pointer; background: var(--surface2);
}
.smp-media-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.smp-video-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.smp-play-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.smp-media-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 4px; transition: background .2s;
}
.smp-media-card:hover .smp-media-overlay { background: rgba(0,0,0,.3); }
.smp-dl-btn {
  background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
  opacity: 0; transition: opacity .2s;
}
.smp-media-card:hover .smp-dl-btn { opacity: 1; }
.smp-dl-btn.flat {
  opacity: 1; background: var(--surface2); color: var(--text);
  border-radius: 50%;
}
.smp-file-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--surface2); border: 1px solid var(--border);
}
.smp-file-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.smp-file-info { flex: 1; min-width: 0; }
.smp-file-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.smp-file-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.smp-empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted); font-size: 14px;
}
.smp-pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 16px; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.smp-page-btn {
  padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  cursor: pointer; font-size: 13px; transition: background .15s;
}
.smp-page-btn:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.smp-page-btn:disabled { opacity: .4; cursor: default; }

/* ═══════════════════════════════════════════════════════════════
   EMAIL VERIFICATION — OTP INPUT STYLES
   ═══════════════════════════════════════════════════════════════ */

.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 8px;
}

.otp-box {
  width: 46px;
  height: 54px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  caret-color: var(--accent);
}

.otp-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,149,246,.15);
  transform: scale(1.06);
}

.otp-box:not(:placeholder-shown) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
}

/* Shake animation for wrong OTP */
@keyframes otpShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.otp-shake {
  animation: otpShake .45s ease;
}

/* Success state */
.otp-box.correct {
  border-color: #22c55e;
  background: rgba(34,197,94,.08);
}
