* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; font-family: 'Tajawal', -apple-system, sans-serif; }
html, body { width:100%; height:100%; background:#fff; overflow:hidden; }

/* ===== Welcome & Login ===== */
.welcome-page, .login-page { display:flex; flex-direction:column; justify-content:center; align-items:center; height:100vh; width:100%; background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%); padding:20px; overflow-y: auto; z-index: 1; position: relative; }
.welcome-box, .login-box { width:100%; max-width:350px; background:rgba(255, 255, 255, 0.95); border: 1px solid #fff; border-radius:20px; padding:40px 30px 20px; text-align:center; box-shadow: 0 15px 35px rgba(255, 71, 126, 0.2); backdrop-filter: blur(10px); animation: fadeInScale 0.6s ease-out forwards; }
.insta-logo { font-family:'Brush Script MT',cursive; font-size:50px; color:#e6396c; margin-bottom:30px; text-shadow: 2px 2px 4px rgba(230, 57, 108, 0.2); }
.welcome-text { margin: 20px 0; color: #333; line-height: 1.6; font-size: 15px; }
.creds { display: flex; flex-direction: column; gap: 10px; background: #fff5f8; padding: 15px; border-radius: 12px; margin-top: 15px; border: 1px dashed #ffb3c6; }
.creds span { font-size: 16px; color: #e6396c; }
.creds b { font-size: 18px; color: #333; }
.login-form { display:flex; flex-direction:column; gap:6px; }
.password-wrapper { position:relative; }
.insta-input { width:100%; padding:12px 60px 12px 8px; background:#fff; border:1px solid #ffb3c6; border-radius:12px; font-size:14px; outline:none; text-align:right; transition:border-color .2s; }
.insta-input:focus { border-color:#e6396c; box-shadow: 0 0 8px rgba(230, 57, 108, 0.2); }
.toggle-password-btn { position:absolute; left:10px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; font-size:13px; color:#e6396c; font-weight:600; }
.insta-btn { width:100%; padding:12px; background:#e6396c; color:#fff; border:none; border-radius:12px; font-size:16px; font-weight:700; cursor:pointer; margin-top:12px; transition:all .3s; }
.insta-btn:active { background:#c92a5c; transform: scale(0.98); }
.error-message { color:#e6396c; font-size:13px; text-align:center; margin-top:12px; display:none; }

/* ===== Chat ===== */
.chat-page { display:none; height:100vh; height: 100dvh; width:100%; flex-direction:column; position:relative; z-index: 1; }
.chat-header { padding:12px 16px; border-bottom:1px solid #ffd1dc; display:flex; justify-content:space-between; align-items:center; backdrop-filter: blur(15px); background-color: rgba(255, 255, 255, 0.85); min-height:65px; flex-shrink: 0; box-shadow: 0 2px 10px rgba(230, 57, 108, 0.05); z-index: 10; }
.header-left { display:flex; align-items:center; gap:12px; flex:1; }
.back-arrow { font-size:22px; color:#e6396c; cursor:pointer; background:none; border:none; padding:4px 8px 4px 0; transition: transform 0.2s; }
.user-avatar { width:46px; height:46px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:22px; font-weight:700; color:#fff; background:linear-gradient(45deg, #ff477e, #e6396c); position: relative; }
.user-avatar::after { content: ''; position: absolute; top: -3px; left: -3px; right: -3px; bottom: -3px; border-radius: 50%; background: linear-gradient(45deg, #ff477e, #fecfef); z-index: -1; animation: glowPulse 2s infinite alternate; }
@keyframes glowPulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.1); opacity: 0.8; } }
.header-info { line-height:1.3; }
.header-info h2 { font-size:16px; font-weight:700; color:#333; }
.header-info p  { font-size:12px; color:#e6396c; font-weight: 600; }
.header-btn { background:none; border:none; cursor:pointer; font-size:20px; color:#e6396c; padding:4px; transition: transform 0.2s; }

.messages-container { flex:1; overflow-y:auto; padding:20px 16px; display:flex; flex-direction:column; background-color: transparent !important; background-image: none !important; }
.message-group { display:flex; margin-bottom:10px; animation: messagePop 0.4s ease-out forwards; }
@keyframes messagePop { 0% { opacity: 0; transform: translateY(20px) scale(0.9); } 70% { transform: translateY(-2px) scale(1.02); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.message-group.sent     { justify-content:flex-end; }
.message-group.received { justify-content:flex-start; }
.message-bubble { max-width:75%; padding:12px 18px; border-radius:22px; word-wrap:break-word; font-size:15px; line-height:1.5; box-shadow: 0 3px 8px rgba(0,0,0,0.04); position: relative; padding-bottom: 24px !important; }
.message-group.sent .message-bubble { background:linear-gradient(135deg, #ff477e, #e6396c); color:#fff; border-bottom-right-radius:4px; }
.message-group.received .message-bubble { background:#fff; color:#333; border:1px solid #ffd1dc; border-bottom-left-radius:4px; }
.message-time { font-size: 10px; color: #999; position: absolute; bottom: 5px; left: 12px; }
.message-group.sent .message-time { color: rgba(255, 255, 255, 0.8); left: auto; right: 12px; }
.message-image { max-width:100%; border-radius:12px; margin-top:6px; max-height:300px; cursor:pointer; display:block; }

.input-area { padding:12px 16px; border-top:1px solid #ffd1dc; display:flex; gap:8px; align-items:center; background:#fff; flex-shrink: 0; padding-bottom:max(12px, env(safe-area-inset-bottom)); }
.input-actions { display:flex; gap:8px; }
.action-btn { width:38px; height:38px; border:2px solid #e6396c; background:none; border-radius:50%; cursor:pointer; font-size:18px; display:flex; align-items:center; justify-content:center; color:#e6396c; transition: transform 0.2s; }
.input-field { flex:1; display:flex; align-items:center; background:#fff5f8; border-radius:24px; padding:10px 16px; border:1px solid #ffd1dc; }
input[type="text"] { flex:1; border:none; background:none; font-size:15px; outline:none; color:#333; }
input[type="file"] { display:none; }
.send-btn { background:none; border:none; cursor:pointer; font-size:18px; font-weight:700; color:#e6396c; padding:4px 8px; transition: all 0.3s; }
.send-btn:disabled { opacity:.4; cursor:default; animation: none !important; }
.send-btn:not(:disabled) { animation: heartbeat 1.5s infinite; }
@keyframes heartbeat { 0% { transform: scale(1); } 14% { transform: scale(1.1); } 28% { transform: scale(1); } 42% { transform: scale(1.1); } 70% { transform: scale(1); } }

.emoji-picker { display:none; position:fixed; bottom:80px; right:16px; background:#fff; border:1px solid #ffd1dc; border-radius:16px; padding:10px; grid-template-columns:repeat(6,1fr); gap:4px; max-height:220px; overflow-y:auto; z-index:1000; box-shadow:0 5px 20px rgba(230, 57, 108, 0.2); }
.emoji-picker.show { display:grid; }
.emoji-item { font-size:24px; cursor:pointer; padding:6px; border-radius:8px; text-align:center; }

/* ===== Dark Mode ===== */
body.dark-mode { background: #121212; }
body.dark-mode .chat-page { background: #121212; }
body.dark-mode .chat-header { background-color: rgba(30, 30, 30, 0.85) !important; border-bottom: 1px solid #333; }
body.dark-mode .header-info h2 { color: #fff; }
body.dark-mode .message-group.received .message-bubble { background: #2a2a2a; color: #fff; border-color: #333; }
body.dark-mode .message-time { color: #aaa; }
body.dark-mode .input-area { background: #1e1e1e; border-top: 1px solid #333; }
body.dark-mode .input-field { background: #2a2a2a; border-color: #444; }
body.dark-mode input[type="text"] { color: #fff; }
body.dark-mode .emoji-picker { background: #1e1e1e; border-color: #333; }

@keyframes fadeInScale { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
