*{box-sizing:border-box;margin:0;padding:0}
:root{--brand:#f26722;--brand-dark:#d9531a;--ink:#1c1e21;--grey:#6b7280;--line:#e7e2da;--bg:#f7f3ee;--mine:#ffd9c2;--theirs:#ffffff}
html,body{height:100%}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--ink)}
.hidden{display:none!important}
#app{max-width:560px;margin:0 auto;height:100dvh;background:#fff;display:flex;flex-direction:column;box-shadow:0 0 24px rgba(0,0,0,.06)}
.view{flex:1;display:flex;flex-direction:column;min-height:0}
button{font-family:inherit;cursor:pointer}
input{font-family:inherit;font-size:16px}
.iconBtn{background:none;border:0;width:40px;height:40px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#555}
.iconBtn svg{width:24px;height:24px}
.iconBtn:active{background:#f1ece5}
.btnPrimary{background:var(--brand);color:#fff;border:0;border-radius:24px;padding:13px 20px;font-size:16px;font-weight:600;width:100%}
.btnPrimary:active{background:var(--brand-dark)}
.btnPrimary.small,.btnGhost.small{width:auto;padding:8px 14px;font-size:14px}
.btnGhost{background:none;border:1px solid var(--line);border-radius:24px;padding:12px 20px;font-size:15px;width:100%;color:var(--ink)}
.btnDanger{background:none;border:0;color:#c62828;font-size:15px;padding:12px;width:100%}
.msg{min-height:20px;font-size:14px;color:#c62828;text-align:center;margin-top:10px}
.fld{display:block;margin:14px 0}
.fld span{display:block;font-size:13px;color:var(--grey);margin-bottom:6px}
.fld input{width:100%;border:1px solid var(--line);border-radius:12px;padding:12px 14px;outline:none}
.fld input:focus{border-color:var(--brand)}

/* auth */
.authWrap{padding:40px 28px;overflow-y:auto}
.logoBadge{width:76px;height:76px;border-radius:22px;background:var(--brand);display:flex;align-items:center;justify-content:center;margin:8px auto 14px}
.logoIcon{width:46px;height:46px}
.authWrap h1{text-align:center;font-size:28px}
.authSub{text-align:center;color:var(--grey);margin:8px 0 22px}
.tabs{display:flex;background:#f1ece5;border-radius:24px;padding:4px;margin-bottom:8px}
.tab{flex:1;border:0;background:none;padding:9px;border-radius:20px;font-size:15px;font-weight:600;color:var(--grey)}
.tab.on{background:#fff;color:var(--ink);box-shadow:0 1px 4px rgba(0,0,0,.12)}
.testCode{background:#fff7ed;border:1px dashed var(--brand);color:var(--brand-dark);border-radius:12px;padding:10px 12px;font-size:14px;text-align:center}
#sendCodeBtn,#verifyBtn{margin-top:8px}
#backBtn{margin-top:10px}

/* home */
.topBar{display:flex;align-items:center;gap:6px;padding:12px 14px;border-bottom:1px solid var(--line);background:#fff}
.brand{font-size:21px;font-weight:800;flex:1}
.brand span{color:var(--brand)}
.brand.small{font-size:18px}
.searchBar{display:flex;align-items:center;gap:8px;margin:12px 14px;background:#f1ece5;border-radius:24px;padding:0 14px}
.searchIcon{width:20px;height:20px;color:#8a8f98;flex:none}
.searchBar input{flex:1;border:0;background:none;outline:none;padding:11px 0}
.peopleResults{border-bottom:1px solid var(--line);max-height:40vh;overflow-y:auto}
.chatList{flex:1;overflow-y:auto}
.personRow,.chatRow{display:flex;gap:12px;align-items:center;padding:12px 16px;cursor:pointer}
.personRow:active,.chatRow:active{background:#faf6f1}
.avatar{width:48px;height:48px;border-radius:50%;background:var(--brand);color:#fff;font-weight:700;font-size:19px;display:flex;align-items:center;justify-content:center;flex:none;text-transform:uppercase}
.avatar.big{width:84px;height:84px;font-size:34px;margin:6px auto}
.rowMain{flex:1;min-width:0}
.rowTop{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.rowName{font-weight:600;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.rowTime{font-size:12px;color:var(--grey);flex:none}
.rowTime.unread{color:var(--brand);font-weight:700}
.rowSub{display:flex;justify-content:space-between;align-items:center;gap:8px}
.rowPreview{color:var(--grey);font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
.unreadBadge{background:var(--brand);color:#fff;border-radius:999px;min-width:20px;height:20px;font-size:12px;font-weight:700;display:flex;align-items:center;justify-content:center;padding:0 6px;flex:none}
.ticks{display:inline-flex;vertical-align:-3px;margin-right:3px}
.ticks svg{width:17px;height:17px}
.emptyNote{text-align:center;color:var(--grey);padding:36px 24px;line-height:1.6}

/* chat */
.chatBar{display:flex;align-items:center;gap:6px;padding:8px 10px;border-bottom:1px solid var(--line);background:#fff}
.chatBar .avatar{width:40px;height:40px;font-size:16px}
.chatTitles{flex:1;min-width:0}
.chatName{font-weight:700;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chatPresence{font-size:12.5px;color:var(--grey)}
.chatPresence.online{color:var(--brand);font-weight:600}
.msgList{flex:1;overflow-y:auto;padding:14px 12px 8px;background:#f3ede4;display:flex;flex-direction:column;gap:3px}
.daySep{align-self:center;background:#e5ddd0;color:#5c5648;font-size:12px;border-radius:8px;padding:4px 10px;margin:10px 0 6px}
.bubble{max-width:78%;padding:8px 10px 6px;border-radius:14px;font-size:15.5px;line-height:1.35;box-shadow:0 1px 1px rgba(0,0,0,.08);word-wrap:break-word;white-space:pre-wrap}
.bubble.mine{align-self:flex-end;background:var(--mine);border-bottom-right-radius:4px}
.bubble.theirs{align-self:flex-start;background:var(--theirs);border-bottom-left-radius:4px}
.bubble img.photo{max-width:100%;border-radius:10px;display:block}
.bubble audio{max-width:230px;height:36px}
.bMeta{display:flex;justify-content:flex-end;align-items:center;gap:4px;font-size:11px;color:#8a7a68;margin-top:3px}
.bMeta .ticks svg{width:15px;height:15px}
.typingRow{padding:0 12px 6px;background:#f3ede4}
.typingBubble{display:inline-flex;gap:4px;padding:12px 14px}
.typingBubble span{width:7px;height:7px;border-radius:50%;background:#b9ac99;animation:tp 1.2s infinite}
.typingBubble span:nth-child(2){animation-delay:.15s}
.typingBubble span:nth-child(3){animation-delay:.3s}
@keyframes tp{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-4px)}}
.composer{display:flex;align-items:center;gap:4px;padding:8px 8px calc(8px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--line)}
.composer input[type=text]{flex:1;border:1px solid var(--line);border-radius:24px;padding:11px 16px;outline:none;background:#faf7f3}
.sendBtn{background:var(--brand);border:0;width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center;flex:none}
.sendBtn svg{width:22px;height:22px}
.recBar{display:flex;align-items:center;gap:10px;padding:10px 14px calc(10px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--line)}
.recDot{width:11px;height:11px;border-radius:50%;background:#e53935;animation:blink 1s infinite}
@keyframes blink{50%{opacity:.25}}
.recHint{flex:1;color:var(--grey);font-size:14px}

/* profile */
.profileWrap{padding:20px 24px;overflow-y:auto}
.identLine{color:var(--grey);font-size:14px;text-align:center;margin:6px 0 14px}
#saveProfile{margin-top:6px}
#logoutBtn{margin-top:18px}
#deleteBtn{margin-top:4px}
