:root {
  --bg: #10151d;
  --panel: #161d27;
  --panel2: #202a36;
  --line: rgba(255,255,255,.08);
  --text: #f4f7fb;
  --sub: #98a7b8;
  --accent: #62d38f;
  --mine: #4bc47b;
  --theirs: #202a36;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
body { overflow: hidden; }
button,input,textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; max-width: 760px; margin: 0 auto; background: var(--bg); }
.login-screen { display:grid; place-items:center; padding:24px; }
.login-card { width:min(360px,100%); text-align:center; }
.app-mark { width:72px; height:72px; display:grid; place-items:center; margin:0 auto 14px; border-radius:22px; font-size:36px; font-weight:800; background:linear-gradient(145deg,#7c8cff,#62d38f); }
.login-card h1 { margin:0; letter-spacing:.14em; }
.login-card p { margin:4px 0 28px; color:var(--sub); }
.login-card form { display:grid; gap:10px; }
.login-card input { height:50px; border:1px solid var(--line); border-radius:14px; background:var(--panel); color:var(--text); padding:0 16px; outline:none; }
.login-card button { height:50px; border:0; border-radius:14px; background:var(--accent); color:#0c1711; font-weight:800; }
.error { min-height:22px; margin-top:10px; color:var(--danger); font-size:13px; }
.list-header { height:calc(94px + env(safe-area-inset-top)); padding:calc(17px + env(safe-area-inset-top)) 18px 12px; display:flex; align-items:flex-end; justify-content:space-between; border-bottom:1px solid var(--line); }
.eyebrow { font-size:10px; letter-spacing:.22em; color:var(--accent); font-weight:800; }
.list-header h1 { font-size:28px; margin:2px 0 0; }
.icon-btn,.back-btn { border:0; background:transparent; font-size:30px; padding:4px 8px; }
.chat-list { height:calc(100% - 94px - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow:auto; }
.chat-row { width:100%; min-height:78px; border:0; border-bottom:1px solid var(--line); background:transparent; display:grid; grid-template-columns:54px 1fr auto; gap:12px; align-items:center; padding:10px 16px; text-align:left; }
.avatar,.mini-avatar { background:var(--panel2); overflow:hidden; display:grid; place-items:center; flex:0 0 auto; }
.avatar { width:54px; height:54px; border-radius:18px; font-size:27px; }
.mini-avatar { width:38px; height:38px; border-radius:13px; font-size:20px; }
.avatar img,.mini-avatar img { width:100%; height:100%; object-fit:cover; }
.chat-row-name { font-weight:750; margin-bottom:5px; }
.chat-row-preview { color:var(--sub); font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:58vw; }
.chat-row-time { color:var(--sub); font-size:11px; align-self:start; margin-top:11px; }
.bottom-bar { position:absolute; left:0; right:0; bottom:0; height:calc(70px + env(safe-area-inset-bottom)); padding-bottom:env(safe-area-inset-bottom); border-top:1px solid var(--line); background:rgba(16,21,29,.94); display:flex; backdrop-filter:blur(18px); }
.bottom-item { flex:1; border:0; background:transparent; color:var(--sub); display:grid; place-items:center; align-content:center; gap:3px; font-size:11px; }
.bottom-item span { font-size:17px; }
.bottom-item.active { color:var(--accent); }
.chat-screen { display:flex; flex-direction:column; }
.chat-header { height:calc(66px + env(safe-area-inset-top)); padding:calc(10px + env(safe-area-inset-top)) 10px 8px; display:flex; align-items:center; border-bottom:1px solid var(--line); background:rgba(16,21,29,.96); backdrop-filter:blur(16px); z-index:3; }
.back-btn { font-size:38px; line-height:1; width:42px; }
.chat-title-wrap { margin-left:10px; min-width:0; }
.chat-title { font-weight:800; font-size:16px; }
.chat-status { color:var(--sub); font-size:11px; margin-top:2px; }
.messages { flex:1; overflow:auto; padding:18px 12px 14px; scroll-behavior:smooth; }
.day-sep { text-align:center; color:var(--sub); font-size:10px; margin:12px 0; }
.msg-row { display:flex; align-items:flex-end; margin:5px 0; gap:7px; }
.msg-row.mine { justify-content:flex-end; }
.msg-row.theirs { justify-content:flex-start; }
.msg-avatar { width:30px; height:30px; border-radius:10px; display:grid; place-items:center; background:var(--panel2); overflow:hidden; font-size:16px; }
.msg-avatar img { width:100%; height:100%; object-fit:cover; }
.bubble-wrap { max-width:min(76%,520px); }
.bubble { padding:9px 12px; border-radius:17px; line-height:1.42; white-space:pre-wrap; word-break:break-word; font-size:15px; }
.mine .bubble { background:var(--mine); color:#07170d; border-bottom-right-radius:5px; }
.theirs .bubble { background:var(--theirs); border-bottom-left-radius:5px; }
.bubble-image { width:min(72vw,380px); max-height:420px; border-radius:16px; display:block; object-fit:cover; margin-bottom:5px; }
.meta { color:var(--sub); font-size:9px; margin-top:3px; }
.mine .meta { text-align:right; }
.typing { margin:0 0 8px 52px; width:54px; height:31px; border-radius:16px; background:var(--theirs); display:flex; justify-content:center; align-items:center; gap:4px; }
.typing span { width:5px; height:5px; border-radius:50%; background:var(--sub); animation:bounce 1s infinite ease-in-out; }
.typing span:nth-child(2){animation-delay:.12s}.typing span:nth-child(3){animation-delay:.24s}
@keyframes bounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-4px)}}
.composer { position:relative; min-height:calc(58px + env(safe-area-inset-bottom)); padding:8px 8px calc(8px + env(safe-area-inset-bottom)); display:flex; align-items:flex-end; gap:7px; border-top:1px solid var(--line); background:var(--bg); }
.attach-btn { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; background:var(--panel2); font-size:25px; color:var(--accent); flex:0 0 auto; }
.composer textarea { flex:1; resize:none; max-height:120px; min-height:36px; border:1px solid var(--line); border-radius:18px; background:var(--panel); color:var(--text); padding:8px 12px; outline:none; }
.send-btn { border:0; background:transparent; color:var(--accent); height:36px; padding:0 8px; font-weight:800; }
.image-preview-wrap { position:absolute; left:10px; bottom:calc(58px + env(safe-area-inset-bottom)); width:96px; height:96px; border-radius:14px; background:var(--panel2); padding:4px; box-shadow:0 8px 30px rgba(0,0,0,.35); }
.image-preview-wrap img { width:100%; height:100%; border-radius:10px; object-fit:cover; }
.image-preview-wrap button { position:absolute; right:-7px; top:-7px; width:25px; height:25px; border-radius:50%; border:0; background:#111; }
.usage-dialog { width:min(360px,calc(100% - 32px)); border:1px solid var(--line); border-radius:18px; background:var(--panel); color:var(--text); padding:20px; }
.usage-dialog::backdrop { background:rgba(0,0,0,.62); backdrop-filter:blur(4px); }
.usage-dialog h2 { margin:0 0 12px; font-size:20px; }
.usage-dialog p { line-height:1.55; }
.usage-dialog small { color:var(--sub); display:block; line-height:1.5; margin-bottom:16px; }
.usage-dialog button { width:100%; height:42px; border:0; border-radius:12px; background:var(--accent); color:#0c1711; font-weight:800; }
@media (min-width:761px) { .screen { border-left:1px solid var(--line); border-right:1px solid var(--line); } }
