:root {
  --ink: #0F1B2D;
  --text: #16202E;
  --muted: #6B7A90;
  --line: #E8ECF2;
  --bg: #F3F5F9;
  --panel: #FFFFFF;
  --hot: #FF6A3D;
  --pink: #F0386B;
  --grad: linear-gradient(135deg, #FF7A3D 0%, #F0386B 100%);
  --soft: #FFF1EC;
  --online: #22C55E;
  --danger: #D92D3A;
  font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); -webkit-tap-highlight-color: transparent; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2.5px solid var(--hot); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Brand ---------- */
.brand { font-weight: 800; font-size: 30px; letter-spacing: -0.05em; color: var(--ink); line-height: 1; }
.brand .dot { display: inline-block; width: .24em; height: .24em; background: var(--grad); border-radius: 50%; margin-left: .05em; }
.brand.light { color: #fff; }
.brand.sm { font-size: 28px; }

/* ---------- Auth / landing ---------- */
.auth { height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; overflow-y: auto; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 48px 56px;
  background:
    radial-gradient(600px 400px at 85% 15%, rgba(240,56,107,.45), transparent 60%),
    radial-gradient(500px 400px at 10% 90%, rgba(255,122,61,.35), transparent 60%),
    var(--ink);
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.auth-hero .brand { position: absolute; top: 40px; left: 56px; font-size: 34px; }
.auth-hero h1 { font-size: clamp(34px, 4.4vw, 58px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 800; max-width: 12ch; }
.auth-hero p { font-size: 18px; line-height: 1.5; color: rgba(255,255,255,.72); max-width: 36ch; }
.hero-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; max-width: 360px; }
.hb { display: inline-block; padding: 10px 14px; border-radius: 20px; font-size: 15px; max-width: 80%; width: fit-content; animation: rise .5s both; }
.hb.in { background: rgba(255,255,255,.12); color: #fff; border-bottom-left-radius: 6px; backdrop-filter: blur(6px); }
.hb.out { background: var(--grad); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; box-shadow: 0 8px 24px rgba(240,56,107,.35); }
.hero-chat .hb:nth-child(2) { animation-delay: .25s; } .hero-chat .hb:nth-child(3) { animation-delay: .5s; } .hero-chat .hb:nth-child(4) { animation-delay: .75s; }
.typing { display: flex; gap: 4px; padding: 13px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: .5; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.auth-panel { display: grid; place-items: center; padding: 32px 24px; background: var(--panel); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 28px; letter-spacing: -0.03em; color: var(--ink); }
.auth-sub { color: var(--muted); margin: 6px 0 22px; }
.tabs { display: flex; background: var(--bg); border-radius: 14px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; padding: 10px; border-radius: 11px; font-weight: 600; color: var(--muted); transition: .15s; }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 2px 8px rgba(15,27,45,.08); }
#authForm label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--ink); }
#authForm input, .field { display: block; width: 100%; margin-top: 7px; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 16px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
#authForm input:focus, .field:focus { border-color: var(--hot); box-shadow: 0 0 0 4px rgba(255,106,61,.12); outline: none; }
.at-field { display: flex; align-items: center; margin-top: 7px; border: 1.5px solid var(--line); border-radius: 14px; padding-left: 15px; transition: .15s; }
.at-field:focus-within { border-color: var(--hot); box-shadow: 0 0 0 4px rgba(255,106,61,.12); }
.at-field span { color: var(--muted); font-weight: 500; }
.at-field input, #authForm .at-field input { margin: 0; border: 0; padding-left: 3px; box-shadow: none !important; background: transparent; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: -4px 0 10px; }
.btn { width: 100%; padding: 14px; border-radius: 14px; background: var(--grad); color: #fff; font-weight: 700; font-size: 16px; box-shadow: 0 8px 20px rgba(240,56,107,.25); transition: transform .1s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: var(--bg); color: var(--ink); box-shadow: none; }
.btn.danger { background: #FDECEE; color: var(--danger); box-shadow: none; }

/* ---------- App layout ---------- */
.app { height: 100%; display: grid; grid-template-columns: 390px minmax(0, 1fr); }
.side { position: relative; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 4px 20px; }
.head-actions { display: flex; gap: 6px; align-items: center; }
.icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--ink); transition: background .15s; }
.icon svg { width: 22px; height: 22px; }
.icon:hover { background: var(--bg); }
.me-btn { border-radius: 50%; padding: 0; }
.me-btn .avatar { width: 38px; height: 38px; font-size: 14px; }
.side-title { padding: 8px 20px 10px; }
.side-title h1 { font-size: 32px; letter-spacing: -0.04em; color: var(--ink); }
.search { margin: 0 16px; display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 14px; padding: 0 14px; color: var(--muted); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; border: 0; background: transparent; padding: 11px 0; font-size: 15px; outline: none; color: var(--text); }
.search:focus-within { box-shadow: 0 0 0 2px var(--hot) inset; }
.filters { display: flex; gap: 8px; padding: 12px 16px 8px; }
.filters button { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--bg); color: var(--muted); transition: .15s; }
.filters button.on { background: var(--ink); color: #fff; }

/* chat list */
.chat-list { list-style: none; padding: 4px 8px 90px; overflow-y: auto; flex: 1; min-height: 0; }
.chat-item { display: flex; gap: 13px; align-items: center; padding: 10px 10px; cursor: pointer; border-radius: 16px; transition: background .12s; }
.chat-item:hover { background: #F7F8FB; }
.chat-item.active { background: var(--soft); }
.ci-main { flex: 1; min-width: 0; }
.ci-top, .ci-bot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ci-name { font-weight: 650; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.ci-last { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.unread .ci-time { color: var(--pink); font-weight: 700; }
.unread .ci-last { color: var(--text); font-weight: 500; }
.badge { background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 7px; flex: none; }
.list-empty { padding: 48px 24px; text-align: center; color: var(--muted); line-height: 1.5; }
.list-empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }
.list-empty .btn { margin-top: 18px; width: auto; padding: 12px 22px; }
.fab { position: absolute; right: 18px; bottom: calc(82px + env(safe-area-inset-bottom, 0px)); width: 60px; height: 60px; border-radius: 20px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 28px rgba(240,56,107,.4); transition: transform .12s; z-index: 2; }
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; }

.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; flex: none; position: relative; letter-spacing: -.02em; background: #CBD5E1; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.online::after { content: ''; position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--online); border: 2.5px solid var(--panel); }
.avatar.sm { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm.online::after { width: 11px; height: 11px; }

/* ---------- Chat pane ---------- */
.pane { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background-color: #EEF1F6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23C9D1DD' stroke-width='1.6' opacity='.35'%3E%3Cpath d='M14 18h22a6 6 0 0 1 6 6v8a6 6 0 0 1-6 6H24l-6 5v-5h-4a6 6 0 0 1-6-6v-8a6 6 0 0 1 6-6z'/%3E%3Ccircle cx='88' cy='26' r='7'/%3E%3Cpath d='M80 82l6 6 12-12'/%3E%3Cpath d='M22 86c4-6 12-6 16 0M26 78h.01M34 78h.01'/%3E%3Cpath d='M92 100l3 6 6 1-4 4 1 6-6-3-6 3 1-6-4-4 6-1z'/%3E%3Cpath d='M60 52q6-8 12 0t12 0'/%3E%3C/g%3E%3C/svg%3E");
}
.pane-empty { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; color: var(--muted); padding: 24px; }
.pane-empty h2 { color: var(--ink); font-size: 24px; letter-spacing: -0.03em; }
.pane-empty p { max-width: 32ch; line-height: 1.5; }
.empty-art { display: flex; flex-direction: column; gap: 8px; width: 220px; margin-bottom: 16px; }
.empty-art .hb.in { background: var(--panel); color: var(--text); box-shadow: 0 4px 14px rgba(15,27,45,.08); }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); z-index: 2; }
.back { display: none; }
.chat-title { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; text-align: left; padding: 4px 6px; border-radius: 12px; }
.chat-title:hover { background: var(--bg); }
.chat-title .avatar { width: 44px; height: 44px; font-size: 15px; }
.chat-title-text { display: flex; flex-direction: column; min-width: 0; }
.chat-title strong { font-size: 17px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-title small.on { color: var(--online); font-weight: 600; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 6% 12px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.day { align-self: center; background: rgba(255,255,255,.9); color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 999px; margin: 14px 0 10px; box-shadow: 0 1px 3px rgba(15,27,45,.06); }
.sys { align-self: center; background: rgba(15,27,45,.06); color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0; padding: 6px 12px; border-radius: 10px; max-width: 85%; }
.older { align-self: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 7px 14px; border-radius: 999px; background: rgba(255,255,255,.8); margin-bottom: 6px; }

.m { position: relative; max-width: min(75%, 520px); padding: 8px 12px 6px; border-radius: 20px; background: var(--panel); align-self: flex-start; box-shadow: 0 1px 2px rgba(15,27,45,.08); overflow-wrap: anywhere; }
.m.mine { align-self: flex-end; background: var(--grad); color: #fff; box-shadow: 0 3px 10px rgba(240,56,107,.18); }
.m.first { margin-top: 8px; }
.m.first:not(.mine) { border-top-left-radius: 6px; }
.m.first.mine { border-top-right-radius: 6px; }
.m .who { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.m .txt { white-space: pre-wrap; line-height: 1.42; font-size: 15.5px; }
.m .txt a { color: inherit; text-decoration: underline; }
.m .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.m.mine .meta { color: rgba(255,255,255,.78); }
.m .tick { width: 17px; height: 11px; }
.m.mine.read .tick { color: #fff; }
.m.pending { opacity: .75; }
.m.failed { background: #FDECEE; color: var(--danger); }
.m.failed .meta { color: var(--danger); }
.m.pop { animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.m .img { display: block; margin: -4px -8px 5px; border-radius: 16px; overflow: hidden; cursor: zoom-in; background: rgba(0,0,0,.06); min-width: 180px; min-height: 130px; }
.m .img img { display: block; width: 100%; max-height: 380px; object-fit: cover; }
.m.first .img { border-top-left-radius: 4px; }
.m.first.mine .img { border-top-left-radius: 16px; border-top-right-radius: 4px; }

/* composer */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.compose-box { flex: 1; display: flex; align-items: flex-end; background: var(--bg); border-radius: 24px; padding: 3px 4px; transition: box-shadow .15s; }
.compose-box:focus-within { box-shadow: 0 0 0 2px rgba(255,106,61,.35); }
.compose-box textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 10px 12px 10px 4px; font-size: 16px; line-height: 1.35; max-height: 140px; outline: none; }
.attach { width: 42px; height: 42px; display: grid; place-items: center; color: var(--muted); border-radius: 50%; flex: none; }
.attach:hover { color: var(--hot); }
.attach svg { width: 22px; height: 22px; }
.send { width: 48px; height: 48px; border-radius: 50%; background: #D5DBE4; color: #fff; display: grid; place-items: center; flex: none; transition: background .15s, transform .12s; }
.send.ready { background: var(--grad); box-shadow: 0 6px 16px rgba(240,56,107,.35); }
.send:active { transform: scale(.92); }
.send svg { width: 22px; height: 22px; margin-left: 2px; }

/* ---------- Sheets / modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,27,45,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--panel); border-radius: 26px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; padding: 24px; box-shadow: 0 30px 60px rgba(15,27,45,.25); animation: sheetIn .22s ease-out; }
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } }
.sheet h2 { font-size: 22px; letter-spacing: -0.03em; margin-bottom: 14px; color: var(--ink); }
.sheet .row { display: flex; gap: 10px; margin-top: 14px; }
.sheet .row .btn { flex: 1; }
.profile-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 8px; }
.profile-top .avatar { width: 84px; height: 84px; font-size: 28px; }
.profile-top h2 { margin: 6px 0 0; }
.results { list-style: none; padding: 0; margin: 8px 0; }
.results li { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 14px; cursor: pointer; }
.results li:hover { background: var(--bg); }
.results .nm { font-weight: 600; color: var(--ink); }
.results .un { font-size: 13px; color: var(--muted); }
.results .hint { color: var(--muted); font-size: 14px; cursor: default; }
.results .hint:hover { background: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.chip { background: var(--soft); color: var(--ink); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.chip button { width: 22px; height: 22px; border-radius: 50%; font-size: 16px; line-height: 1; color: var(--pink); }
.preview-img { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 18px; background: var(--bg); margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }

.viewer { position: fixed; inset: 0; background: rgba(8,12,20,.95); z-index: 60; display: grid; place-items: center; cursor: zoom-out; padding: 16px; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 70; max-width: 90%; box-shadow: 0 10px 30px rgba(15,27,45,.3); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: calc(28px + env(safe-area-inset-top, 0px)) 24px 44px; gap: 12px; }
  .auth-hero .brand { position: static; margin-bottom: 18px; font-size: 30px; }
  .auth-hero h1 { font-size: 38px; }
  .auth-hero p { font-size: 16px; }
  .hero-chat { margin-top: 8px; }
  .auth-panel { border-radius: 28px 28px 0 0; margin-top: -24px; position: relative; padding: 28px 22px calc(28px + env(safe-area-inset-bottom, 0px)); place-items: start center; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; }
  .pane { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1), visibility .25s; visibility: hidden; }
  body.in-chat .pane { transform: none; visibility: visible; }
  .pane-empty { display: none; }
  .back { display: grid; margin-left: -6px; }
  .msgs { padding: 12px 12px 8px; }
  .m { max-width: 82%; }
  .modal { place-items: end stretch; padding: 0; }
  .sheet { max-width: none; border-radius: 26px 26px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); animation-duration: .25s; }
  .sheet::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }


/* ================= v2 additions ================= */
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tabview { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabview.scroll { overflow-y: auto; padding: 0 8px 100px; display: block; }

/* bottom navigation */
.nav { display: flex; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 14px; transition: color .15s; }
.nav button.on { color: var(--ink); }
.nav-ic { position: relative; width: 56px; height: 30px; display: grid; place-items: center; border-radius: 999px; transition: background .15s; }
.nav button.on .nav-ic { background: var(--soft); color: var(--pink); }
.nav-ic svg { width: 23px; height: 23px; }
.nav-badge { position: absolute; top: -3px; right: 6px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; font-style: normal; }
.nav-dot { position: absolute; top: 2px; right: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--pink); border: 2px solid #fff; }
.typing-txt { color: var(--online) !important; font-weight: 600; font-style: italic; }

/* people rows & finder */
.urow, .vrow { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 16px; cursor: pointer; }
.urow:hover, .vrow:hover { background: #F7F8FB; }
.ulist.big .urow { padding: 11px 10px; }
.ur-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ur-main strong { color: var(--ink); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ur-main span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tag { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--bg); padding: 4px 10px; border-radius: 999px; flex: none; }
.tag.ok { background: #E7F8EE; color: #15803D; }
.tag.on { background: #E7F8EE; color: #15803D; }
.pick { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.urow.picked .pick { background: var(--grad); color: #fff; }
.urow.picked .pick::before { content: '✓'; }
.urow.picked .pick { font-size: 0; } .urow.picked .pick::before { font-size: 14px; }
.finder { display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 16px; padding: 4px 4px 4px 14px; margin-top: 4px; border: 1.5px solid transparent; transition: .15s; }
.finder:focus-within { border-color: var(--hot); background: #fff; box-shadow: 0 0 0 4px rgba(255,106,61,.1); }
.finder .at { color: var(--muted); font-weight: 600; }
.finder-in { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 2px; font-size: 16px; outline: none; }
.finder-go { background: var(--ink); color: #fff; font-weight: 700; padding: 9px 16px; border-radius: 12px; }
.finder-res { margin-top: 8px; }
.ucard { border: 1.5px solid var(--line); border-radius: 18px; padding: 6px; animation: sheetIn .2s ease-out; }
.uc-acts { display: flex; gap: 8px; padding: 4px 6px 6px; }
.uc-acts .btn { flex: 1; }
.btn.sm { padding: 9px 14px; font-size: 14px; border-radius: 12px; width: auto; }
.pad { padding: 8px 10px; }
.sec { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 10px 6px; }
.sheet .sec { margin: 18px 2px 6px; }
.pad-find { padding: 4px 8px 6px; }
.pad-hint { font-size: 14px; color: var(--muted); margin: 0 4px 4px; }

/* vibes */
.ring { padding: 2.5px; border-radius: 50%; background: var(--grad); display: inline-grid; flex: none; }
.ring .avatar { border: 2.5px solid #fff; }
.ring.seen { background: #D5DBE4; }
.ring.mine { background: conic-gradient(#FF7A3D, #F0386B, #FF7A3D); }
.add-av { position: relative; flex: none; }
.add-av i { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--grad); color: #fff; font-style: normal; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; font-size: 14px; line-height: 1; }
.vrow.me { margin-top: 2px; }
.add-more { background: var(--soft); color: var(--pink); font-size: 20px; }
.vibe-note { font-size: 13px; color: var(--muted); text-align: center; padding: 18px 16px; line-height: 1.5; }
.vibe-compose { border-radius: 22px; padding: 22px; min-height: 240px; display: grid; place-items: center; transition: background .2s; }
.vibe-compose textarea { width: 100%; min-height: 190px; background: transparent; border: 0; resize: none; color: #fff; font-size: 24px; font-weight: 700; text-align: center; outline: none; letter-spacing: -0.02em; line-height: 1.3; }
.vibe-compose textarea::placeholder { color: rgba(255,255,255,.7); }
.swatches { display: flex; gap: 10px; justify-content: center; margin: 14px 0 4px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2.5px var(--ink); }

.story { position: fixed; inset: 0; z-index: 80; background: #05080E; color: #fff; display: flex; flex-direction: column; animation: fade .15s; }
.st-bars { display: flex; gap: 4px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0; position: relative; z-index: 3; }
.st-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.3); overflow: hidden; }
.st-bars b { display: block; height: 100%; width: 0; background: #fff; }
.st-bars i.done b { width: 100%; }
.st-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: relative; z-index: 3; }
.st-who { flex: 1; display: flex; flex-direction: column; }
.st-who small { opacity: .7; font-size: 12.5px; }
.st-x { color: #fff; font-size: 20px; width: 42px; height: 42px; border-radius: 50%; }
.st-body { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
.st-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.st-cap { position: absolute; bottom: 16px; left: 16px; right: 16px; text-align: center; background: rgba(0,0,0,.45); padding: 10px 14px; border-radius: 14px; }
.st-text { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; }
.st-text p { font-size: clamp(22px, 5vw, 34px); font-weight: 750; text-align: center; letter-spacing: -0.02em; line-height: 1.3; max-width: 22ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.st-text a { color: #fff; }
.st-zone { position: absolute; top: 90px; bottom: 90px; width: 35%; z-index: 2; }
.st-prev { left: 0; } .st-next { right: 0; width: 65%; }
.st-foot { display: flex; gap: 10px; justify-content: center; padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px)); position: relative; z-index: 3; }
.st-foot button { color: #fff; background: rgba(255,255,255,.14); padding: 11px 18px; border-radius: 999px; font-weight: 600; }
@media (min-width: 761px) { .story { background: rgba(5,8,14,.94); } .st-body, .st-bars, .st-head, .st-foot { width: 100%; max-width: 460px; margin: 0 auto; } .st-body { border-radius: 20px; overflow: hidden; } }

/* messages: replies, deleted, menu */
.quote { border-left: 3.5px solid var(--pink); background: rgba(15,27,45,.05); border-radius: 10px; padding: 6px 10px; margin: 2px -4px 6px; cursor: pointer; display: flex; flex-direction: column; max-width: 100%; }
.quote b { font-size: 12.5px; color: var(--pink); }
.quote span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m.mine .quote { background: rgba(255,255,255,.18); border-left-color: #fff; }
.m.mine .quote b { color: #fff; } .m.mine .quote span { color: rgba(255,255,255,.85); }
.m.deleted { background: rgba(255,255,255,.7); box-shadow: none; border: 1px dashed #CBD5E1; }
.m.deleted .txt { font-style: italic; color: var(--muted); font-size: 14px; }
.m.mine.deleted { background: rgba(255,255,255,.7); color: var(--muted); }
.m.mine.deleted .meta { color: var(--muted); }
.m.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(255,106,61,.5); } 100% { box-shadow: 0 0 0 0 rgba(255,106,61,0); } }
.m { user-select: text; -webkit-touch-callout: none; }
.enc { align-self: center; font-size: 12.5px; color: #8A6D1F; background: #FFF6D6; padding: 7px 12px; border-radius: 10px; margin: 4px 0 8px; text-align: center; max-width: 90%; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu button { text-align: left; padding: 14px 12px; border-radius: 14px; font-size: 16px; font-weight: 550; color: var(--ink); }
.menu button:hover { background: var(--bg); }
.danger-txt { color: var(--danger) !important; }
.menu-preview { background: var(--bg); border-radius: 14px; padding: 12px 14px; color: var(--muted); font-size: 14px; margin-bottom: 8px; max-height: 80px; overflow: hidden; }
.reply-bar { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.95); border-top: 1px solid var(--line); padding: 8px 10px 8px 14px; }
.rb-text { flex: 1; min-width: 0; border-left: 3.5px solid var(--pink); padding: 2px 10px; display: flex; flex-direction: column; }
.rb-text b { font-size: 13px; color: var(--pink); }
.rb-text span { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blocked-bar { background: rgba(255,255,255,.95); border-top: 1px solid var(--line); padding: 16px calc(14px) calc(16px + env(safe-area-inset-bottom, 0px)); text-align: center; color: var(--muted); font-size: 14px; }
.blocked-bar button { color: var(--pink); font-weight: 700; margin-left: 6px; }

/* in-app notification banner */
.notif { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -150%); width: min(420px, calc(100% - 20px)); z-index: 90; display: flex; align-items: center; gap: 12px; text-align: left; background: rgba(255,255,255,.97); backdrop-filter: blur(16px); padding: 12px 14px; border-radius: 20px; box-shadow: 0 16px 40px rgba(15,27,45,.22); transition: transform .35s cubic-bezier(.2,.9,.25,1.15), visibility .35s; border: 1px solid var(--line); visibility: hidden; }
.notif.show { transform: translate(-50%, 0); visibility: visible; }
.notif .nt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.notif strong { color: var(--ink); font-size: 15px; }
.notif .nt span { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* profile & settings */
.sheet.tall { max-width: 480px; }
.about { color: var(--text); max-width: 34ch; line-height: 1.45; margin-top: 2px; }
.pill { font-size: 13px; color: var(--muted); background: var(--bg); padding: 7px 12px; border-radius: 12px; margin-top: 6px; line-height: 1.4; }
.pill.ok { background: #E7F8EE; color: #15803D; }
.big-av .avatar { width: 96px; height: 96px; font-size: 32px; cursor: zoom-in; }
.av-edit { position: relative; }
.av-edit button { position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%; background: var(--grad); border: 3px solid #fff; font-size: 14px; }
.linkbtn { color: var(--pink); font-weight: 600; font-size: 14px; padding: 6px; }
.flabel { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 8px 2px 4px; }
.flabel .field { margin-top: 5px; color: var(--text); }
.sheet .field + .field { margin-top: 8px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; cursor: pointer; }
.setting div { display: flex; flex-direction: column; min-width: 0; }
.setting strong { color: var(--ink); font-weight: 600; font-size: 15px; }
.setting span:not(.tag) { color: var(--muted); font-size: 13px; margin-top: 2px; }
.seg { display: flex; background: var(--bg); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 11px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(15,27,45,.08); }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: #D5DBE4; position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: var(--grad); }
.switch:checked::after { transform: translateX(20px); }

@media (max-width: 760px) {
  .notif { top: calc(8px + env(safe-area-inset-top, 0px)); }
}

/* ================= v3: lock, install, encryption, dark mode ================= */
.e2e-note { align-self: center; font-size: 12.5px; color: #8A6D1F; background: #FFF6D6; padding: 8px 12px; border-radius: 12px; margin: 4px 0 10px; text-align: center; max-width: 92%; line-height: 1.4; }
.txt.locked { font-style: italic; opacity: .75; }
.m .img.loading { min-height: 160px; background: linear-gradient(100deg, rgba(0,0,0,.06) 30%, rgba(0,0,0,.12) 50%, rgba(0,0,0,.06) 70%); background-size: 300% 100%; animation: shimmer 1.2s infinite linear; }
.m .img.gone { min-height: 0; padding: 14px; font-size: 13px; text-align: center; cursor: default; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.big-emoji { font-size: 44px; line-height: 1; }
.code { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 4px; }
.code span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; font-weight: 600; letter-spacing: .06em; text-align: center; background: var(--bg); padding: 10px 0; border-radius: 12px; color: var(--ink); }
.del-acc { display: block; margin: 14px auto 0; }
.st-wait { font-size: 40px; opacity: .6; }

/* install guide */
.install-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.install-head h2 { margin: 0 0 2px; }
.app-icon { width: 60px; height: 60px; border-radius: 16px; background: var(--grad); color: #fff; font-weight: 800; font-size: 34px; letter-spacing: -0.05em; display: grid; place-items: center; position: relative; flex: none; box-shadow: 0 8px 20px rgba(240,56,107,.3); padding-bottom: 6px; }
.app-icon i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #fff; right: 13px; bottom: 17px; }
.steps { padding-left: 0; list-style: none; counter-reset: st; display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.steps li { counter-increment: st; display: flex; align-items: center; gap: 12px; line-height: 1.4; color: var(--text); }
.steps li::before { content: counter(st); width: 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--pink); font-weight: 800; display: grid; place-items: center; flex: none; }
.inl { width: 18px; height: 18px; vertical-align: -3px; color: #0A84FF; }
.hint-box { font-size: 13px; color: var(--muted); background: var(--bg); padding: 10px 12px; border-radius: 12px; margin-top: 12px; line-height: 1.45; }

/* PIN lock screen */
.lock { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; color: #fff; padding: 24px;
  background: radial-gradient(500px 400px at 85% 10%, rgba(240,56,107,.45), transparent 60%), radial-gradient(500px 400px at 10% 95%, rgba(255,122,61,.35), transparent 60%), #0F1B2D; animation: fade .15s; }
.lock-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; }
.lock .brand { font-size: 38px; margin-bottom: 26px; }
.lock-msg { font-size: 17px; font-weight: 600; min-height: 1.4em; text-align: center; }
.lock-msg.bad { color: #FFB4C2; }
.pin-dots { display: flex; gap: 18px; margin: 20px 0 30px; }
.pin-dots i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); transition: .12s; }
.pin-dots i.on { background: #fff; border-color: #fff; transform: scale(1.1); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 22px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 30px; font-weight: 500; transition: background .1s, transform .1s; }
.keypad button:active { background: rgba(255,255,255,.28); transform: scale(.94); }
.keypad button[data-k=back] { background: transparent; font-size: 24px; }
.lock-link { color: rgba(255,255,255,.75); margin-top: 26px; font-weight: 600; font-size: 14px; padding: 8px; }

/* ---------- Dark mode ---------- */
[data-theme=dark] {
  --ink: #F1F5F9; --text: #E2E8F0; --muted: #94A3B8; --line: #1E293B; --bg: #172234; --panel: #0F1726; --soft: #2A1622;
  color-scheme: dark;
}
[data-theme=dark] body { background: #0B1220; }
[data-theme=dark] .auth-hero { background: radial-gradient(600px 400px at 85% 15%, rgba(240,56,107,.4), transparent 60%), radial-gradient(500px 400px at 10% 90%, rgba(255,122,61,.3), transparent 60%), #070D18; }
[data-theme=dark] .pane { background-color: #0B1220; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23334155' stroke-width='1.6' opacity='.35'%3E%3Cpath d='M14 18h22a6 6 0 0 1 6 6v8a6 6 0 0 1-6 6H24l-6 5v-5h-4a6 6 0 0 1-6-6v-8a6 6 0 0 1 6-6z'/%3E%3Ccircle cx='88' cy='26' r='7'/%3E%3Cpath d='M80 82l6 6 12-12'/%3E%3Cpath d='M22 86c4-6 12-6 16 0M26 78h.01M34 78h.01'/%3E%3Cpath d='M92 100l3 6 6 1-4 4 1 6-6-3-6 3 1-6-4-4 6-1z'/%3E%3Cpath d='M60 52q6-8 12 0t12 0'/%3E%3C/g%3E%3C/svg%3E"); }
[data-theme=dark] .chat-head, [data-theme=dark] .composer, [data-theme=dark] .nav, [data-theme=dark] .reply-bar, [data-theme=dark] .blocked-bar { background: rgba(15,23,38,.94); }
[data-theme=dark] .m:not(.mine) { background: #1B2638; box-shadow: none; }
[data-theme=dark] .m.deleted, [data-theme=dark] .m.mine.deleted { background: rgba(27,38,56,.6); border-color: #334155; }
[data-theme=dark] .day, [data-theme=dark] .older { background: rgba(27,38,56,.92); color: var(--muted); box-shadow: none; }
[data-theme=dark] .sys { background: rgba(255,255,255,.06); }
[data-theme=dark] .quote { background: rgba(255,255,255,.06); }
[data-theme=dark] .e2e-note { background: #2A2412; color: #E8C66A; }
[data-theme=dark] .chat-item:hover, [data-theme=dark] .urow:hover, [data-theme=dark] .vrow:hover, [data-theme=dark] .results li:hover { background: #141E30; }
[data-theme=dark] .chat-item.active { background: #24131C; }
[data-theme=dark] .filters button.on, [data-theme=dark] .finder-go { background: #F1F5F9; color: #0B1220; }
[data-theme=dark] .finder:focus-within { background: var(--panel); }
[data-theme=dark] .tabs button.on, [data-theme=dark] .seg button.on { background: #24324A; color: #fff; box-shadow: none; }
[data-theme=dark] .ring .avatar, [data-theme=dark] .add-av i, [data-theme=dark] .av-edit button, [data-theme=dark] .swatches button { border-color: var(--panel); }
[data-theme=dark] .nav-dot { border-color: var(--panel); }
[data-theme=dark] .ring.seen { background: #334155; }
[data-theme=dark] .send:not(.ready) { background: #24324A; }
[data-theme=dark] .notif { background: rgba(23,34,52,.97); border-color: #24324A; }
[data-theme=dark] .toast { background: #F1F5F9; color: #0B1220; }
[data-theme=dark] .tag.ok, [data-theme=dark] .tag.on, [data-theme=dark] .pill.ok { background: #0F2E1C; color: #4ADE80; }
[data-theme=dark] .btn.danger { background: #3A1419; color: #FF8A95; }
[data-theme=dark] .danger-txt { color: #FF8A95 !important; }
[data-theme=dark] .m.failed { background: #3A1419; color: #FF8A95; }
[data-theme=dark] .modal { background: rgba(0,0,0,.6); }
[data-theme=dark] .sheet { box-shadow: 0 30px 60px rgba(0,0,0,.5); }
[data-theme=dark] .empty-art .hb.in { background: #1B2638; color: var(--text); }
[data-theme=dark] .chat-title:hover, [data-theme=dark] .icon:hover { background: #172234; }
[data-theme=dark] .switch { background: #334155; }
[data-theme=dark] .code span { background: #172234; }
[data-theme=dark] .m .img.loading { background: linear-gradient(100deg, rgba(255,255,255,.05) 30%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 70%); background-size: 300% 100%; }
