/* Whisper web client. Dark, clean, modern messenger. */
:root {
  --bg: #0E0F13;
  --surface: #16181D;
  --surface-2: #1E2128;
  --line: #262a32;
  --text: #E9ECF1;
  --muted: #8A93A2;
  --accent: #5B8CFF;
  --accent-ink: #ffffff;
  --online: #37D67A;
  --nope: #FF5A6E;
  --bubble-in: #1E2128;
  --bubble-out: #274690;
  --bubble-out-text: #EAF0FF;
  --check: #7FB0FF;
  --nav-h: 60px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
svg { display: block; }
#app { height: 100%; max-width: 620px; margin: 0 auto; position: relative; background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px; border-radius: 12px; font-weight: 600; background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--nope); border: 1px solid var(--line); }
.btn.small { height: 40px; width: auto; padding: 0 16px; border-radius: 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.link { color: var(--accent); font-weight: 600; align-self: center; }

/* ---------- auth ---------- */
.auth { height: 100%; overflow-y: auto; padding: 60px 22px 30px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 30px; font-weight: 700; letter-spacing: -.5px; color: var(--text); }
.brand svg, .brand .brandmark { width: 36px; height: 36px; } .brand svg { color: var(--accent); } .brand .brandmark { border-radius: 9px; }
.tagline { color: var(--muted); margin: -4px 0 16px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.err { color: var(--nope); font-size: 14px; min-height: 20px; }
.fineprint { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.fineprint svg { color: var(--online); }
.testcode { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 14px; text-align: center; }
.testcode b { color: var(--text); font-size: 18px; letter-spacing: 2px; }

/* ---------- shell ---------- */
.screen { position: absolute; inset: 0 0 var(--nav-h) 0; overflow-y: auto; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.3px; }
.iconbtn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 10px; }
.iconbtn:active { background: var(--surface-2); }
.nav { position: absolute; left: 0; right: 0; bottom: 0; height: var(--nav-h); display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
.nav button.on { color: var(--accent); }
.nav .dot { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; }

/* ---------- avatars ---------- */
.av { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.av.ph { color: #fff; font-weight: 600; }
.avwrap { position: relative; flex: none; }
.avwrap .online { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--online); border: 2px solid var(--surface); }

/* ---------- chat list ---------- */
.clist { display: flex; flex-direction: column; }
.citem { display: flex; gap: 12px; padding: 10px 14px; align-items: center; width: 100%; text-align: left; }
.citem:active { background: var(--surface-2); }
.cbody { flex: 1; min-width: 0; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: -10px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.citem:last-child .cbody { border-bottom: 0; }
.cline { display: flex; align-items: center; gap: 6px; }
.cname { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctime { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.ck { color: var(--muted); display: inline-flex; } .ck.read { color: var(--check); }
.prev { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.prev.typing { color: var(--accent); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.section-h { font-size: 12px; font-weight: 700; color: var(--muted); padding: 14px 16px 8px; text-transform: uppercase; letter-spacing: .5px; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 30px; color: var(--muted); gap: 8px; }
.empty h3 { color: var(--text); margin: 0; }
.searchbar { padding: 10px 14px; position: sticky; top: 57px; background: var(--bg); }

/* ---------- conversation ---------- */
.chatview { position: fixed; inset: 0; max-width: 620px; margin: 0 auto; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
.chead { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 4px; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: calc(8px + env(safe-area-inset-top)); }
.chead .who { flex: 1; min-width: 0; } .chead .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chead .who small { color: var(--muted); font-size: 13px; } .chead .who small.live { color: var(--accent); }
.msgs { flex: 1; overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.daysep { align-self: center; margin: 10px 0; padding: 3px 10px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.sysmsg { align-self: center; margin: 6px 18px 12px; padding: 8px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; text-align: center; display: flex; gap: 6px; align-items: flex-start; }
.sysmsg svg { color: var(--online); flex: none; margin-top: 1px; }
.b { max-width: 80%; padding: 7px 11px; border-radius: 16px; margin-top: 2px; position: relative; word-wrap: break-word; white-space: pre-wrap; }
.b.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 5px; }
.b.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 5px; }
.b .btext.err { font-style: italic; color: var(--muted); }
.b.deleted { font-style: italic; opacity: .65; }
.b .meta { float: right; margin: 4px -2px -2px 10px; font-size: 11px; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); position: relative; top: 4px; }
.b.out .meta { color: #A9BEEA; } .b.out .meta .read { color: #BFE0FF; }
.b .quote { display: block; border-left: 3px solid var(--accent); padding: 2px 0 2px 8px; margin: 0 0 4px; font-size: 13.5px; opacity: .9; }
.b .quote b { display: block; color: var(--accent); font-size: 12.5px; }
.b.failed { outline: 1px solid var(--nope); }
.trnote { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.b.out .trnote { color: #B9CCF2; }
.dots { display: inline-flex; gap: 2px; margin-left: 4px; } .dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.ctxbar { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px 8px; }
.ctxbar .txt { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; }
.ctxbar .txt b { color: var(--accent); font-size: 13px; display: block; }
.ctxbar .txt span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
.inrow { display: flex; align-items: flex-end; gap: 6px; }
.inrow textarea { border: 0; background: transparent; resize: none; padding: 10px 8px; max-height: 140px; line-height: 1.35; }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--accent); flex: none; }
.sendbtn:disabled { opacity: .4; }
.locked { padding: 12px; text-align: center; color: var(--muted); font-size: 14px; }
.ctxmenu { position: fixed; z-index: 70; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); min-width: 180px; padding: 6px 0; }
.ctxmenu button { display: block; width: 100%; padding: 11px 16px; text-align: left; font-size: 15px; } .ctxmenu button:active { background: var(--surface); } .ctxmenu button.red { color: var(--nope); }
.ctxshade { position: fixed; inset: 0; z-index: 69; }

/* ---------- settings / profile ---------- */
.pbody { padding: 14px 16px 30px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.center { align-items: center; text-align: center; }
.card h4 { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.photo { position: relative; overflow: hidden; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: -6px; } .hint.ok { color: var(--online); } .hint.bad { color: var(--nope); }
.invite { display: flex; gap: 8px; } .invite input { font-size: 13px; }
.rowsel { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .rowsel select { width: auto; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; } .toggle div small { display: block; color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--line); transition: .2s; } .switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::after { transform: translateX(20px); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding-top: 6px; }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 620px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow-y: auto; animation: up .2s ease-out; }
.sheet h3 { margin: 0; font-size: 19px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.pv { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.pv h3 { margin: 4px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); z-index: 90; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
