/* Reset & Base */
:root { --primary: #0084ff; --bg: #f0f2f5; --white: #ffffff; --grey: #e4e6eb; --red: #ff3b30; }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-color: var(--bg); height: 100vh; display: flex; justify-content: center; overflow: hidden; }

/* App Container */
.app-container { width: 100%; max-width: 480px; background: var(--white); display: flex; flex-direction: column; height: 100%; position: relative; box-shadow: 0 0 20px rgba(0,0,0,0.05); }

/* Header */
.header { padding: 12px 16px; background: var(--white); border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; z-index: 10; height: 60px; }
.header h2 { font-size: 18px; font-weight: 700; color: #050505; }
.badge { font-size: 10px; padding: 3px 8px; border-radius: 10px; font-weight: bold; margin-left: 8px; vertical-align: middle; display: inline-block; }
.badge-offline { background: #eee; color: #666; }
.badge-online { background: #31a24c; color: white; }
.btn-icon { background: none; border: none; font-size: 20px; color: #65676b; cursor: pointer; }

/* Screens */
.screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Welcome Screen */
.welcome-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.logo { font-size: 64px; margin-bottom: 20px; animation: bounce 2s infinite; }
.desc { color: #65676b; margin-bottom: 40px; line-height: 1.5; font-size: 14px; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 14px 40px; border-radius: 25px; font-size: 16px; font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%; max-width: 250px; }
.btn-primary:active { transform: scale(0.96); opacity: 0.9; }
.status-text { margin-bottom: 15px; color: var(--primary); font-weight: 500; min-height: 20px; }
.footer-note { padding: 20px; text-align: center; font-size: 11px; color: #bcc0c4; }

/* Chat Screen */
.messages-area { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 8px; background: #fff; scroll-behavior: smooth; }
.system-msg { text-align: center; font-size: 12px; color: #999; margin: 10px 0; font-style: italic; }

.msg-row { display: flex; width: 100%; }
.msg-bubble { padding: 8px 14px; border-radius: 18px; max-width: 75%; font-size: 15px; line-height: 1.4; word-wrap: break-word; }

/* My Message (Right) */
.msg-me { justify-content: flex-end; }
.msg-me .msg-bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }

/* Their Message (Left) */
.msg-them { justify-content: flex-start; }
.msg-them .msg-bubble { background: var(--grey); color: #050505; border-bottom-left-radius: 4px; }

/* Input Area */
.input-area { padding: 10px; border-top: 1px solid #ddd; display: flex; gap: 8px; align-items: center; background: white; }
#msg-input { flex: 1; padding: 10px 15px; border-radius: 20px; border: 1px solid #ddd; outline: none; background: #f0f2f5; font-size: 15px; }
#msg-input:focus { background: white; border-color: var(--primary); }
.btn-send { background: none; border: none; color: var(--primary); font-size: 24px; cursor: pointer; padding: 0 5px; }
.btn-send:disabled { color: #ccc; }

/* Loader */
.loader { width: 30px; height: 30px; border: 3px solid #f3f3f3; border-top: 3px solid var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 15px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }