/* ===========================================================================
   mysecret.chat styles
   =========================================================================== */
:root {
  --green: #00a884;
  --green-dark: #008f72;
  --green-action: #007a63;
  --green-action-dark: #006b57;
  --on-green: #fff;
  --focus-ring: #7ddfc3;
  --tick-blue: #53bdeb;
  --radius: 14px;
  --bubble-radius: 10px;
  --sidebar-w: 380px;
}

[data-theme='dark'] {
  --bg: #0b141a;
  --bg-2: #111b21;
  --panel: #202c33;
  --panel-2: #2a3942;
  --header: #202c33;
  --text: #e9edef;
  --muted: #8696a0;
  --border: #2a3942;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --chat-bg: #0b141a;
  --chat-pattern: rgba(255, 255, 255, 0.02);
  --chat-doodle-opacity: 0.05;
  --hover: #202c33;
  --active: #2a3942;
  --input-bg: #2a3942;
  --shadow: rgba(0, 0, 0, 0.4);
}

[data-theme='light'] {
  --bg: #ffffff;
  --bg-2: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --header: #f0f2f5;
  --text: #111b21;
  --muted: #667781;
  --border: #e9edef;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --chat-bg: #efeae2;
  --chat-pattern: rgba(0, 0, 0, 0.02);
  --chat-doodle-opacity: 0.06;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --input-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.13);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.screen { height: 100dvh; }
::placeholder { color: #9fb0ba; opacity: 1; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- buttons ---- */
.icon-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.btn-primary {
  background: var(--green-action); color: var(--on-green); border: 0; padding: 13px 18px;
  border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
  transition: background .15s;
}
.btn-primary:hover { background: var(--green-action-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-danger {
  background: transparent; color: #f15c6d; border: 1px solid #f15c6d; padding: 10px 14px;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn-danger:hover { background: rgba(241, 92, 109, .1); }
.link-btn { background: none; border: 0; color: var(--green); cursor: pointer; font-size: 14px; padding: 4px 0; }

/* ---- safe-area helpers (iPhone notch / home indicator) ---- */
.safe-top    { padding-top:    max(10px, env(safe-area-inset-top)); }
.safe-bottom { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* ---- auth (login + signup) ---- */
.auth-screen {
  display: grid; place-items: center; overflow-y: auto; position: relative;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(1100px 560px at 50% -12%, rgba(0,168,132,0.12), transparent 62%), var(--bg);
}
.auth-screen::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: url('/img/chat-doodles.svg'); background-size: 300px auto; background-repeat: repeat;
  opacity: calc(var(--chat-doodle-opacity) * 0.85);
}
.auth-back { position: absolute; z-index: 2; top: max(18px, env(safe-area-inset-top)); left: 22px; color: var(--muted); text-decoration: none; font-size: 14px; min-height: 44px; display: flex; align-items: center; padding: 0 10px; border-radius: 10px; }
.auth-back:hover { color: var(--text); background: var(--hover); }
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; background: var(--panel); padding: 28px 24px 26px;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 18px 50px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.04) inset;
}
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.brand-logo { width: 44px; height: 44px; }
.brand h1 { font-size: 26px; font-weight: 700; }
.tagline { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: 14px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; min-height: 44px; background: transparent; border: 0; color: var(--muted); padding: 10px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.auth-tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.auth-form { display: block; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .name-edit {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font-size: 16px; /* 16px = no iOS zoom-in */
}
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,168,132,.16); }
.password-wrap { position: relative; display: block !important; margin: 0 !important; }
.password-wrap input { padding-right: 82px; }
.password-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); min-width: 62px; min-height: 34px; border: 0; border-radius: 7px; background: transparent; color: var(--green); font-size: 12px; font-weight: 700; cursor: pointer; }
.password-toggle:hover { background: rgba(0,168,132,.1); }
.password-strength { display: block !important; height: 4px; margin: 8px 2px 0 !important; border-radius: 4px; background: var(--border); overflow: hidden; }
.password-strength i { display: block; width: 0; height: 100%; border-radius: inherit; background: #f15c6d; transition: width .2s, background .2s; }
.password-strength i[data-score='2'] { background: #f4b942; }
.password-strength i[data-score='3'], .password-strength i[data-score='4'] { background: var(--green); }
.auth-trust { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px 14px; color: var(--muted); font-size: 11px; }
.auth-trust span::first-letter { color: var(--green); }
.btn-primary:focus-visible, .auth-tab:focus-visible, .password-toggle:focus-visible, .auth-back:focus-visible, .icon-btn:focus-visible, .els-btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.ob-status { text-align: center; margin-top: 14px; font-size: 14px; min-height: 20px; }
.ob-status.err { color: #f15c6d; }
.ob-status.ok { color: var(--green); }
.fineprint { font-size: 12px; color: var(--muted); margin-top: 18px; text-align: center; line-height: 1.5; }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }

/* ---- sidebar ---- */
.sidebar { display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--border); min-width: 0; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--header); min-height: 60px; position: sticky; top: 0; z-index: 6;
}
.sidebar-head.safe-top { padding-top: calc(10px + env(safe-area-inset-top)); }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; }
.me-info { display: flex; flex-direction: column; min-width: 0; }
.me-info strong { font-size: 15px; }
.me-id { font-size: 12px; }
.sidebar-actions { display: flex; gap: 2px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; text-transform: uppercase;
  position: relative;
}
.avatar.big { width: 90px; height: 90px; font-size: 36px; }
/* live "online" green dot */
.avatar.is-online::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #25d366; /* WhatsApp-style green, distinct from --green so it pops on a green avatar */
  border: 2px solid var(--bg-2);
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.avatar.big.is-online::after { width: 18px; height: 18px; border-width: 3px; }
/* notification permission banner */
.notif-banner {
  display: flex; align-items: center; gap: 10px; margin: 6px 10px 8px;
  padding: 12px 12px 12px 14px; background: var(--panel);
  border: 1px solid var(--green); border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}
.notif-banner-icon { font-size: 22px; flex: none; }
.notif-banner-body { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.notif-banner-body strong { font-size: 14px; }
.notif-banner-body span { font-size: 12px; line-height: 1.35; }
.notif-banner-btn { width: auto; padding: 9px 16px; font-size: 14px; flex: none; border-radius: 8px; }
.notif-banner-dismiss { width: 32px; height: 32px; flex: none; }
.notif-banner-dismiss svg { width: 16px; height: 16px; }
@media (max-width: 480px) {
  .notif-banner {
    display: grid;
    grid-template-columns: 32px 1fr 44px;
    align-items: center;
    gap: 10px;
  }
  .notif-banner-body { flex-basis: auto; }
  .notif-banner-btn {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 2px;
    order: initial;
  }
  .notif-banner-dismiss {
    justify-self: end;
    width: 40px;
    height: 40px;
  }
}

.search { padding: 8px 12px; background: var(--bg-2); }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 8px; border: 0; background: var(--input-bg);
  color: var(--text); font-size: 16px; /* 16px = no iOS focus-zoom */
}
.search input:focus { outline: 1px solid var(--green); }
.chat-list { list-style: none; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 13px; padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border); min-width: 0;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .ci-main { flex: 1; min-width: 0; }
.chat-item .ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item .ci-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item .ci-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.badge {
  background: var(--green); color: #fff; border-radius: 11px; min-width: 20px; height: 20px;
  font-size: 12px; display: grid; place-items: center; padding: 0 6px; flex: none;
}
.conn-state { padding: 6px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.conn-state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #f15c6d; }
.conn-state.online::before { background: var(--green); }

/* ---- conversation ---- */
.conversation { position: relative; min-width: 0; background: var(--chat-bg); }
/* WhatsApp-style fixed doodle pattern behind the whole conversation (messages scroll over it) */
.conversation::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: url('/img/chat-doodles.svg');
  background-size: 300px auto; background-repeat: repeat;
  opacity: var(--chat-doodle-opacity);
}
.conversation > * { position: relative; z-index: 1; }
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); gap: 12px; padding: 40px;
}
.empty-state img { width: 90px; height: 90px; opacity: .85; }
.empty-state h2 { color: var(--text); font-weight: 600; }
.empty-state p { max-width: 420px; font-size: 14px; line-height: 1.6; }

.chat { height: 100dvh; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--header);
  min-height: 60px; border-left: 1px solid var(--border); z-index: 5; position: sticky; top: 0;
}
.chat-head.safe-top { padding-top: calc(8px + env(safe-area-inset-top)); }
.chat-head .chat-head-actions { margin-left: auto; }
.peer-info { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.peer-info strong { font-size: 16px; }
.chat-head-actions { display: flex; align-items: center; gap: 4px; }
.ttl-indicator { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-size: 12px; }
.ttl-indicator svg { width: 16px; height: 16px; }
.back-btn { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 8% 12px; display: flex; flex-direction: column; gap: 3px;
  background: transparent; /* the conversation's doodle pattern shows through */
}
.day-sep { align-self: center; background: var(--panel); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px var(--shadow); }

.bubble {
  max-width: min(70%, 560px); padding: 7px 9px 8px; border-radius: var(--bubble-radius);
  position: relative; box-shadow: 0 1px .5px var(--shadow); font-size: 14.5px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere; animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.bubble + .bubble.same { margin-top: 1px; }
.bubble .reply-quote {
  border-left: 3px solid var(--green); background: rgba(0,0,0,.18); border-radius: 6px;
  padding: 4px 8px; margin-bottom: 4px; font-size: 13px; cursor: pointer;
}
.bubble .reply-quote .rq-name { color: var(--green); font-weight: 600; display: block; font-size: 12px; }
.bubble .reply-quote .rq-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.bubble .text { white-space: pre-wrap; }
.bubble .meta-line { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; height: 15px; }
.bubble .time { font-size: 11px; color: var(--muted); }
.bubble.out .time { color: rgba(233,237,239,.6); }
.ticks { display: inline-flex; align-items: center; }
.ticks svg { width: 16px; height: 16px; stroke: rgba(233,237,239,.6); }
.ticks.read svg { stroke: var(--tick-blue); }
.bubble .lock { width: 12px; height: 12px; opacity: .5; stroke: currentColor; }

.bubble .msg-actions {
  position: absolute; top: 2px; right: 4px; opacity: 0; transition: opacity .12s;
  background: linear-gradient(transparent, var(--bubble-in)); border-radius: 6px;
}
/* Reveal-on-hover ONLY where a real pointer exists. On touch (iOS especially) the first
 * tap inside a bubble would otherwise be consumed applying this :hover (revealing the
 * actions) instead of clicking — that's the "must tap Pay twice" bug. Touch users get
 * the actions via long-press instead. */
@media (hover: hover) {
  .bubble:hover .msg-actions { opacity: 1; }
}
.bubble .reply-action { background: var(--panel); border: 0; color: var(--muted); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 3px var(--shadow); }
.bubble .reply-action svg { width: 15px; height: 15px; }

/* media bubbles */
.bubble img.media { max-width: 260px; border-radius: 8px; display: block; cursor: pointer; }
.bubble .file-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px; min-width: 200px; }
.bubble .file-chip .file-ic { width: 40px; height: 40px; border-radius: 8px; background: rgba(0,0,0,.2); display: grid; place-items: center; flex: none; }
.bubble .file-chip .file-meta { min-width: 0; }
.bubble .file-chip .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.bubble .file-chip a { color: inherit; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 2px 0; }
.voice button.play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--green); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.voice .wave { flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; }
.voice .wave i { flex: 1; background: var(--muted); border-radius: 2px; height: 30%; }
.voice .vdur { font-size: 12px; color: var(--muted); }
.voice.voice-fallback { gap: 8px; }
.voice .voice-dl { color: var(--green); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }

.system-note { align-self: center; background: rgba(0,0,0,.18); color: var(--muted); font-size: 12.5px; padding: 6px 14px; border-radius: 8px; margin: 8px 0; text-align: center; max-width: 80%; }

/* group chat styling */
.group-avatar { background: linear-gradient(135deg, #6366f1, #a855f7) !important; font-size: 22px; }
.group-avatar::after { display: none !important; } /* groups don't have presence dots */
.group-tag { display: inline-block; background: #6366f1; color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 4px; letter-spacing: .04em; vertical-align: middle; margin-right: 4px; }
.group-sender { font-size: 12px; font-weight: 600; margin-bottom: 2px; line-height: 1.2; }
.bubble.out .group-sender { display: none; }
.gi-row { flex: 1; min-width: 0; }
.gi-tag { font-size: 10px; color: var(--muted); padding: 1px 6px; border-radius: 4px; background: var(--bg); margin-left: 4px; vertical-align: middle; }
.gi-tag.admin { background: var(--green); color: #fff; font-weight: 600; }
.gi-tag.owner { background: #7c5cff; color: #fff; font-weight: 700; }
.gi-tag.moderator { background: #2575c7; color: #fff; font-weight: 600; }
.gi-remove { background: transparent; border: 0; color: #f15c6d; cursor: pointer; font-size: 18px; padding: 6px 10px; border-radius: 6px; }
.gi-remove:hover { background: rgba(241,92,109,.1); }
.gi-manage { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 24px; padding: 4px 12px; border-radius: 8px; }
.gi-manage:hover { background: var(--bg); color: var(--text); }
.gi-banned-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.secure-chat-note { margin: 12px auto 18px; max-width: 520px; padding: 12px 14px; border: 1px solid rgba(69,214,170,.35); border-radius: 12px; background: rgba(0,168,132,.1); color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.secure-chat-note strong, .secure-chat-note span { display: block; }
.secure-chat-note strong { color: var(--green); font-size: 13px; margin-bottom: 4px; }
.guest-session #btn-new, .guest-session #els-invite, .guest-session #els-find, .guest-session #open-wallet, .guest-session #open-invite-btn, .guest-session #tab-new-group { display: none !important; }
.guest-growth { margin: 8px 10px 4px; padding: 12px; border: 1px solid rgba(69,214,170,.32); border-radius: 12px; background: rgba(0,168,132,.1); display:grid; gap:6px; }
.guest-growth strong { color:var(--green); font-size:13px; }.guest-growth span { color:var(--muted); font-size:11px; line-height:1.4; }
.guest-growth div { display:flex; gap:5px; flex-wrap:wrap; }.guest-growth button { flex:1; min-width:80px; border:0; border-radius:8px; padding:8px 5px; background:var(--panel); color:var(--text); font-size:10px; font-weight:700; cursor:pointer; }
.guest-link-explain { display:grid; gap:7px; margin:8px 0 14px; padding:11px 12px; border-radius:11px; background:var(--bg); color:var(--muted); font-size:12px; line-height:1.45; }.guest-link-explain strong{color:var(--text)}.guest-link-explain span{display:block}.guest-link-explain em{font-style:normal;color:#f4b942;border-top:1px solid var(--border);padding-top:7px}
.secure-chat-trigger { color:var(--green) !important; background:rgba(0,168,132,.12) !important; }.guest-invite-focus{animation:guest-focus 1.8s ease-out}@keyframes guest-focus{0%,35%{box-shadow:0 0 0 3px rgba(69,214,170,.45);background:rgba(0,168,132,.13)}100%{box-shadow:none;background:transparent}}
.guest-invite-list{display:grid;gap:9px;margin-top:12px}.guest-invite-list h5{margin:4px 0;font-size:13px}.guest-invite-empty{text-align:center;margin:10px 0}.guest-invite-card{border:1px solid var(--border);border-radius:12px;background:var(--bg);padding:11px;display:grid;gap:9px}.guest-invite-card-head{display:flex;justify-content:space-between;gap:8px;align-items:center}.guest-invite-card-head strong{font-size:12px}.guest-invite-card-head span{font-size:11px;color:var(--muted);white-space:nowrap}.guest-invite-short{font-size:10px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.guest-invite-actions{display:flex;gap:6px}.guest-invite-actions button{flex:1;border:0;border-radius:8px;padding:8px 5px;background:var(--panel);color:var(--text);font-size:11px;font-weight:700;cursor:pointer}.guest-invite-actions button.danger{color:#f15c6d}
.pop-sticker.playing .pop-head{animation:pop-head .55s cubic-bezier(.2,.9,.3,1) 5;transform-origin:center}.pop-sticker.playing .pop-mouth{animation:pop-mouth .35s ease-in-out 8;transform-origin:center}.pop-sticker.playing .pop-shake{animation:pop-shake .18s linear 15;transform-origin:center}.pop-sticker.playing .pop-flames{animation:pop-flame .45s ease-in-out infinite;transform-origin:bottom}.pop-sticker.playing .pop-coins,.pop-sticker.playing .pop-money{animation:pop-rain .8s ease-in infinite}.pop-sticker.playing .pop-cup,.pop-sticker.playing .pop-wallet,.pop-sticker.playing .pop-alarm,.pop-sticker.playing .pop-phone{animation:pop-prop .4s ease-in-out 7;transform-origin:center}.pop-sticker.playing .pop-steam,.pop-sticker.playing .pop-waves{animation:pop-pulse 1s ease-out infinite;transform-origin:center}.pop-sticker.playing .pop-lines,.pop-sticker.playing .pop-arms{animation:pop-lines .45s ease-in-out infinite;transform-origin:center}@keyframes pop-head{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(-5px) rotate(-3deg)}}@keyframes pop-mouth{0%,100%{transform:scaleY(1)}50%{transform:scaleY(1.35) scaleX(1.08)}}@keyframes pop-shake{0%,100%{transform:translateX(-2px) rotate(-2deg)}50%{transform:translateX(2px) rotate(2deg)}}@keyframes pop-flame{0%,100%{transform:scaleY(1)}50%{transform:scaleY(1.14) scaleX(.94)}}@keyframes pop-rain{0%{transform:translateY(-12px) rotate(-8deg);opacity:0}35%{opacity:1}100%{transform:translateY(18px) rotate(12deg);opacity:0}}@keyframes pop-prop{0%,100%{transform:rotate(-3deg) scale(1)}50%{transform:rotate(3deg) scale(1.06)}}@keyframes pop-pulse{0%{transform:scale(.8);opacity:.2}60%{opacity:1}100%{transform:scale(1.18);opacity:0}}@keyframes pop-lines{0%,100%{transform:scale(.9)}50%{transform:scale(1.1)}}

/* group create — checkbox list. NB: the list sits inside a <label class="field">, so the
 * broad `.field input { width:100%; padding:13px }` rule was stretching the checkbox to the
 * full row width (breaking the layout). Scope + higher specificity so the checkbox wins. */
.directory-list .group-pick {
  flex: none; width: 18px; height: 18px; min-width: 18px; padding: 0; margin: 0 4px 0 0;
  border-radius: 4px; box-sizing: border-box; accent-color: var(--green);
}

/* ============================================================
 * UX v3 — NATIVE PATTERNS (bottom sheet, blur, skeleton, reactions, FAB)
 * ============================================================ */

/* ---- BOTTOM SHEET MODALS on mobile (replace centered modal) ---- */
@media (max-width: 768px) {
  .modal {
    align-items: flex-end !important;
    padding: 0 !important;
    animation: fade-in .18s ease-out;
  }
  .modal-card {
    width: 100% !important;
    max-width: none !important;
    border-radius: 18px 18px 0 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    max-height: 92dvh !important;
    animation: slide-up .25s cubic-bezier(.2,.85,.2,1);
    position: relative;
  }
  /* drag handle */
  .modal-card::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--muted);
    opacity: .35;
    border-radius: 2px;
  }
  .modal-head { padding-top: 14px; }
  @keyframes slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  @keyframes fade-in {
    from { background: rgba(0,0,0,0); }
    to   { background: rgba(0,0,0,.6); }
  }
}

/* ---- BACKDROP BLUR on topbars (iOS frosted glass) ---- */
@supports (backdrop-filter: blur(20px)) {
  [data-theme='dark'] .sidebar-head,
  [data-theme='dark'] .chat-head,
  [data-theme='dark'] .panel-head {
    background: rgba(32, 44, 51, 0.78);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
  }
  [data-theme='light'] .sidebar-head,
  [data-theme='light'] .chat-head,
  [data-theme='light'] .panel-head {
    background: rgba(240, 242, 245, 0.82);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
  }
  [data-theme='dark'] .composer.safe-bottom {
    background: rgba(32, 44, 51, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

/* ---- SKELETON LOADING (chat list shimmer) ---- */
.skeleton-row {
  display: flex; align-items: center; gap: 13px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.skel-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skel-line { height: 12px; border-radius: 6px; }
.skel-line.short { width: 30%; }
.skel-line.long  { width: 75%; }
.skel-avatar, .skel-line {
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- EMPTY STATE — chat list with CTA ---- */
.empty-list-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center; gap: 14px;
  height: 100%;
}
.empty-list-state .els-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #14b8a6);
  display: grid; place-items: center;
  font-size: 32px;
  box-shadow: 0 8px 24px rgba(0, 168, 132, .35);
}
.empty-list-state .els-title { font-size: 18px; font-weight: 600; color: var(--text); margin-top: 4px; }
.empty-list-state .els-desc  { font-size: 14px; color: var(--muted); max-width: 280px; line-height: 1.5; }
.empty-list-state .els-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 280px; margin-top: 8px; }
.empty-list-state .els-btn { width: 100%; padding: 13px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer; border: 0; transition: transform .08s; }
.empty-list-state .els-btn:active { transform: scale(.97); }
.empty-list-state .els-btn.primary { background: var(--green); color: #fff; }
.empty-list-state .els-btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }

/* ---- EMPTY STATE — active chat (0 msgs) ---- */
.empty-chat-hint {
  align-self: center; max-width: 280px; text-align: center;
  margin: 30vh auto 0; color: var(--muted); font-size: 14px;
  padding: 20px; border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.empty-chat-hint .ech-icon { font-size: 28px; display: block; margin-bottom: 8px; }

/* ---- SCROLL-TO-BOTTOM FAB ---- */
.scroll-bottom-fab {
  position: absolute;
  right: 22px;
  bottom: 96px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--shadow);
  z-index: 6;
  opacity: 0; pointer-events: none;
  transform: scale(.7) translateY(20px);
  transition: opacity .18s, transform .22s cubic-bezier(.2,.85,.2,1);
}
.scroll-bottom-fab.show {
  opacity: 1; pointer-events: auto;
  transform: scale(1) translateY(0);
}
.scroll-bottom-fab .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--green); color: #fff;
  border-radius: 10px; min-width: 18px; height: 18px;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center; padding: 0 4px;
}

/* ---- REACTIONS (long-press quick bar + bubble chips) ---- */
.react-bar {
  position: fixed; z-index: 250;
  display: flex; gap: 4px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 12px 32px var(--shadow);
  animation: react-pop .18s cubic-bezier(.2,.85,.2,1);
}
@keyframes react-pop {
  from { transform: scale(.5) translateY(8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);  opacity: 1; }
}
.react-bar button {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0; background: transparent;
  font-size: 22px; cursor: pointer;
  transition: transform .12s;
}
.react-bar button:hover { transform: scale(1.2); background: var(--hover); }
.react-bar button:active { transform: scale(1.4); }

.reactions {
  display: flex; gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.reaction-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
}
.reaction-chip.mine { background: var(--green); color: #fff; border-color: var(--green); }
.reaction-chip .count { font-size: 11px; opacity: .8; }

/* ---- COMPOSER "+" overflow menu ---- */
.plus-menu {
  position: fixed; z-index: 220;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px var(--shadow);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 180px;
  animation: react-pop .18s ease-out;
}
.plus-menu button {
  background: transparent; border: 0; color: var(--text);
  padding: 12px 14px; border-radius: 10px;
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; cursor: pointer; text-align: left;
}
.plus-menu button:hover { background: var(--hover); }
.plus-menu button .pm-icon { font-size: 20px; width: 24px; text-align: center; }

/* ---- COMPOSER POLISH: send button as green pill ---- */
.send-btn {
  background: var(--green-action) !important;
  color: var(--on-green) !important;
  box-shadow: 0 2px 8px rgba(0, 122, 99, .45);
}
.send-btn svg { stroke: var(--on-green); }

/* ============================================================
 * MOBILE-FIRST NATIVE FEEL
 * ============================================================ */

/* prevent iOS rubber-band and pull-to-refresh from being annoying */
html, body { overscroll-behavior: none; }
/* no double-tap zoom on tappable elements (300ms penalty + jank) */
button, a, .icon-btn, .chat-item, .sticker-grid > *, .ttl-fab, [role="button"] {
  touch-action: manipulation;
}
/* no text selection in chrome (looks native), keep selection inside bubbles */
.sidebar-head, .chat-head, .panel-head, .composer, .conn-state,
.notif-banner, .update-banner, .icon-btn, .btn-primary, .btn-secondary,
.btn-danger, .link-btn, .modal-head, .auth-tabs, .pay-card, .ci-top, .ci-time,
.gi-row, .gi-tag, .group-tag {
  -webkit-user-select: none; user-select: none;
}
.bubble .text, .field input, .name-edit, textarea, [contenteditable] {
  -webkit-user-select: text; user-select: text;
}
/* On touch, a long-press on a bubble must NOT start a native text selection or the iOS
 * copy callout — it opens our reactions/actions menu instead (Copy lives in that menu).
 * Inputs/textarea keep selection (they're excluded). */
@media (pointer: coarse) {
  .bubble, .bubble .text {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
}
/* tap highlight off (looks more native) */
* { -webkit-tap-highlight-color: transparent; }
/* iOS-style active press for big buttons */
.btn-primary:active, .pay-btn.cta:active, .auth-tab.active,
.icon-btn:active, .send-btn:active, .mic-btn:active {
  transform: scale(0.97);
  transition: transform 80ms;
}
/* native-ish slide-in for opened chat on mobile */
@media (max-width: 768px) {
  .app.show-chat .conversation {
    animation: slide-from-right .22s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes slide-from-right {
    from { transform: translateX(40%); opacity: .85; }
    to   { transform: translateX(0);   opacity: 1; }
  }
  /* fixed positions get sticky topbar treatment under notch */
  .messages { overscroll-behavior: contain; }
  /* hide ugly scrollbars on mobile */
  .messages, .chat-list, .panel-body { scrollbar-width: none; }
  .messages::-webkit-scrollbar, .chat-list::-webkit-scrollbar,
  .panel-body::-webkit-scrollbar { display: none; }
  /* native-style chevron arrows */
  .back-btn { color: var(--green); }
}
/* use dvh consistently — keyboard up/down doesn't break layout */
.app, .screen, .chat, .panel, .auth-screen { height: 100dvh; }

/* ============================================================
 * UPDATE BANNER ("new version")
 * ============================================================ */
.update-banner {
  position: fixed;
  left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 300;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(99,102,241,.4);
  animation: slide-down .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide-down {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.update-icon { font-size: 20px; animation: spin-slow 3s linear infinite; }
.update-text { flex: 1; font-size: 14px; font-weight: 600; }
.update-btn  {
  background: #fff; color: #6366f1; border: 0; padding: 8px 14px;
  border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.update-btn:active { transform: scale(.95); }
.update-x {
  background: rgba(255,255,255,.2); border: 0; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 14px;
}
@keyframes spin-slow { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ============================================================
 * ANIMATED STICKERS
 * ============================================================ */
.sticker-art.animated svg { width: 160px; height: 160px; cursor: pointer; }
.sticker-art.animated img { cursor: pointer; }
.sticker-art.animated img.playing { animation: cat-sticker-pop 1.15s cubic-bezier(.2,.85,.35,1) 2; transform-origin: 50% 85%; }
.sticker-hell-laugh img.playing{animation:evil-laugh .28s ease-in-out 9!important}.sticker-rich-duck-tycoon img.playing{animation:rich-bounce .62s cubic-bezier(.2,.9,.3,1) 5!important}.sticker-coffee-resurrection img.playing{animation:coffee-jolt .22s ease-in-out 10!important}.sticker-payday-gone img.playing{animation:wallet-sad 1.1s ease-in-out 3!important}.sticker-monday-alarm img.playing{animation:alarm-panic .16s linear 18!important}.sticker-wifi-ritual img.playing{animation:wifi-search .8s ease-in-out 5!important}@keyframes evil-laugh{0%,100%{transform:rotate(-2deg) translateY(0)}50%{transform:rotate(2deg) translateY(-5px) scale(1.03)}}@keyframes rich-bounce{0%,100%{transform:translateY(0) rotate(0)}45%{transform:translateY(-12px) rotate(-3deg) scale(1.05)}}@keyframes coffee-jolt{0%,100%{transform:translate(0) scale(1)}25%{transform:translate(-3px,-2px) scale(1.02)}75%{transform:translate(3px,1px) scale(1.02)}}@keyframes wallet-sad{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(8px) rotate(-4deg) scale(.96)}}@keyframes alarm-panic{0%,100%{transform:translateX(-3px) rotate(-2deg)}50%{transform:translateX(3px) rotate(2deg)}}@keyframes wifi-search{0%,100%{transform:rotate(-4deg) scale(1)}50%{transform:rotate(5deg) translateY(-6px) scale(1.04)}}
@keyframes cat-sticker-pop { 0%,100% { transform: translateY(0) rotate(0) scale(1); } 35% { transform: translateY(-10px) rotate(-4deg) scale(1.06); } 70% { transform: translateY(0) rotate(4deg) scale(.98); } }
.anim-funny.playing .funny-body { animation: funny-wobble .55s ease-in-out 4; transform-origin: center; }
.anim-funny.playing .funny-prop { animation: funny-prop .25s ease-in-out 8; transform-origin: center; }
.anim-funny.playing .buffer-dots circle { animation: funny-dot .9s ease-in-out infinite; }
.anim-funny.playing .buffer-dots circle:nth-child(2) { animation-delay: .15s; }
.anim-funny.playing .buffer-dots circle:nth-child(3) { animation-delay: .3s; }
@keyframes funny-wobble { 0%,100% { transform: rotate(0) translateY(0); } 50% { transform: rotate(-3deg) translateY(-3px); } }
@keyframes funny-prop { 0%,100% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
@keyframes funny-dot { 0%,100% { opacity:.25; transform:scale(.7); } 50% { opacity:1; transform:scale(1.25); } }

/* universal: only animate when .playing is on */
.sticker-art.animated svg.playing * { animation-play-state: running; }

/* ---- LAUGHING ---- */
.anim-laugh.playing .laugh-eyes  { animation: laugh-squeeze 0.7s ease-in-out 3; transform-origin: center; }
.anim-laugh.playing .laugh-mouth { animation: laugh-mouth   0.7s ease-in-out 3; transform-origin: 60% 70%; }
.anim-laugh.playing .tear-l      { animation: tear-fall-l  0.7s ease-in 3; }
.anim-laugh.playing .tear-r      { animation: tear-fall-r  0.7s ease-in 3; }
@keyframes laugh-squeeze {
  0%,100% { transform: translateY(0)   scaleY(1); }
  50%     { transform: translateY(2px) scaleY(.4); }
}
@keyframes laugh-mouth {
  0%,100% { transform: scaleY(1)   scaleX(1); }
  50%     { transform: scaleY(1.4) scaleX(1.1); }
}
@keyframes tear-fall-l {
  0%   { transform: translate(0,0)   scale(.6); opacity: 0; }
  40%  { opacity: 1; }
  100% { transform: translate(-8px,30px) scale(1.2); opacity: 0; }
}
@keyframes tear-fall-r {
  0%   { transform: translate(0,0)  scale(.6); opacity: 0; }
  40%  { opacity: 1; }
  100% { transform: translate(8px,30px) scale(1.2); opacity: 0; }
}

/* ---- CRYING ---- */
.anim-cry.playing .cry-stream { animation: cry-flow 1s linear infinite; }
.anim-cry.playing .cry-mouth  { animation: cry-mouth 2s ease-in-out infinite; transform-origin: center; }
@keyframes cry-flow {
  0%   { stroke-dasharray: 4 60; stroke-dashoffset: 0;  opacity: 1; }
  100% { stroke-dasharray: 4 60; stroke-dashoffset: -64; opacity: 1; }
}
@keyframes cry-mouth {
  0%,100% { transform: scaleY(1); }
  50%     { transform: scaleY(1.3); }
}

/* ---- SAD ---- */
.anim-sad.playing .sad-tear   { animation: sad-tear-drop 2.4s ease-in infinite; }
.anim-sad.playing .sad-mouth  { animation: sad-pulse 2.4s ease-in-out infinite; transform-origin: 60% 80%; }
@keyframes sad-tear-drop {
  0%,40% { opacity: 0; transform: translateY(0); }
  50%    { opacity: 1; transform: translateY(0); }
  90%    { opacity: 1; transform: translateY(28px) scale(1.2); }
  100%   { opacity: 0; transform: translateY(34px) scale(.5); }
}
@keyframes sad-pulse {
  0%,100% { transform: scaleY(1)   translateY(0); }
  50%     { transform: scaleY(1.2) translateY(2px); }
}

/* ---- HAPPY ---- */
.anim-happy.playing .happy-mouth { animation: happy-stretch 1.3s ease-in-out infinite; transform-origin: 60% 70%; }
.anim-happy.playing .sp1 { animation: sparkle 1.1s ease-in-out infinite; animation-delay: 0s;    transform-origin: 20px 32px; }
.anim-happy.playing .sp2 { animation: sparkle 1.1s ease-in-out infinite; animation-delay: 0.25s; transform-origin: 92px 36px; }
.anim-happy.playing .sp3 { animation: sparkle 1.1s ease-in-out infinite; animation-delay: 0.5s;  transform-origin: 100px 84px; }
.anim-happy.playing .sp4 { animation: sparkle 1.1s ease-in-out infinite; animation-delay: 0.75s; transform-origin: 14px 92px; }
@keyframes happy-stretch {
  0%,100% { transform: scaleX(1)   scaleY(1); }
  50%     { transform: scaleX(1.1) scaleY(1.2); }
}
@keyframes sparkle {
  0%,100% { opacity: 0; transform: scale(.4) rotate(0); }
  50%     { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

/* ---- HEART EYES ---- */
.anim-heart.playing .heart-l { animation: heart-pop 0.7s ease-in-out infinite; transform-origin: 42px 64px; }
.anim-heart.playing .heart-r { animation: heart-pop 0.7s ease-in-out infinite; animation-delay: 0.1s; transform-origin: 82px 64px; }
@keyframes heart-pop {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.25); }
}

/* ---- ANGRY ---- */
.anim-angry.playing .angry-face   { animation: angry-shake 0.18s ease-in-out 8; }
.anim-angry.playing .angry-brows  { animation: angry-shake 0.18s ease-in-out 8; }
.anim-angry.playing .steam-l      { animation: steam-up 1.1s ease-out infinite; animation-delay: 0s; }
.anim-angry.playing .steam-r      { animation: steam-up 1.1s ease-out infinite; animation-delay: 0.3s; }
@keyframes angry-shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-2px); }
  75%     { transform: translateX(2px); }
}
@keyframes steam-up {
  0%   { opacity: 0; transform: translateY(0)    scale(.7); }
  40%  { opacity: .9; }
  100% { opacity: 0; transform: translateY(-22px) scale(1.4); }
}

/* ---- THUMBS UP ---- */
.anim-thumb.playing .thumb-grp   { animation: thumb-bounce 0.6s ease-in-out 3; transform-origin: center; }
.anim-thumb.playing .ln          { animation: thumb-line 0.6s ease-out 3; }
@keyframes thumb-bounce {
  0%,100% { transform: translateY(0)   rotate(0); }
  50%     { transform: translateY(-6px) rotate(-4deg); }
}
@keyframes thumb-line {
  0%   { opacity: 0; transform: translateX(0); }
  60%  { opacity: 1; transform: translateX(-3px); }
  100% { opacity: 0; transform: translateX(-8px); }
}

/* ---- FIRE ---- */
.anim-fire.playing .flame { transform-origin: 60px 110px; }
.anim-fire.playing .outer { animation: fire-flicker 0.5s ease-in-out infinite; }
.anim-fire.playing .mid   { animation: fire-flicker 0.4s ease-in-out infinite; animation-delay: .08s; }
.anim-fire.playing .inner { animation: fire-flicker 0.3s ease-in-out infinite; animation-delay: .14s; }
@keyframes fire-flicker {
  0%,100% { transform: scaleY(1)   scaleX(1); }
  50%     { transform: scaleY(1.1) scaleX(0.94); }
}

/* ===== WalletConnect modal ===== */
.wc-qr {
  display: grid; place-items: center;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin: 8px auto 12px;
  max-width: 280px;
  min-height: 200px;
}
.wc-qr svg { width: 100%; height: auto; max-width: 240px; }
.wc-status {
  text-align: center;
  font-size: 14px;
  color: var(--text);
  padding: 8px 4px;
  min-height: 22px;
  line-height: 1.4;
}
.wc-wallets a { color: var(--green); text-decoration: none; }
.wc-wallets a:hover { text-decoration: underline; }

/* ===== WalletConnect deeplinks (mobile: open wallet app) ===== */
.wc-deeplinks { margin: 4px 0 10px; }
.wc-wallet-btn {
  width: 100%; padding: 14px; border-radius: 12px; border: 0;
  font-size: 16px; font-weight: 700; cursor: pointer;
  background: var(--green-action); color: var(--on-green);
  box-shadow: 0 3px 12px rgba(0,122,99,.35);
}
.wc-wallet-btn:active { transform: scale(.97); }
.wc-wallet-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px;
}
.wc-wallet-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 12px;
}
.wc-wallet-chip span { font-size: 22px; }
.wc-wallet-chip:active { background: var(--hover); }
.wc-or { text-align: center; margin-top: 12px; }
/* on mobile the QR shrinks (you can't scan your own screen) */
.wc-qr.wc-qr-compact { max-width: 160px; min-height: 120px; padding: 10px; opacity: .85; }
.wc-qr.wc-qr-compact svg { max-width: 130px; }

/* ===== call overlay ===== */
.call-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(180deg, #0b141a 0%, #111b21 100%);
  display: flex; flex-direction: column; align-items: center;
  padding: calc(env(safe-area-inset-top) + 40px) 20px calc(env(safe-area-inset-bottom) + 36px);
  animation: fade-in .2s ease-out;
}
.call-video-wrap { position: absolute; inset: 0; background: #000; z-index: -1; }
.call-remote-video { width: 100%; height: 100%; object-fit: cover; }
.call-local-video {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px;
  width: 96px; height: 132px; object-fit: cover; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.3); z-index: 2; background: #000;
}
.call-info { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6vh; text-align: center; }
.call-info .avatar.big { width: 110px; height: 110px; font-size: 44px; box-shadow: 0 8px 40px rgba(0,0,0,.5); }
.call-name { font-size: 26px; font-weight: 600; color: #fff; }
.call-status { font-size: 15px; color: var(--muted); }
.call-timer { font-size: 18px; color: #fff; }
.call-e2e { margin-top: 6px; color: var(--green) !important; }
.call-actions { margin-top: auto; display: flex; gap: 28px; align-items: center; }
.call-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  transition: transform .12s, background .15s;
}
.call-btn svg { width: 28px; height: 28px; }
.call-btn:active { transform: scale(.92); }
.call-btn.accept { background: #25d366; }
.call-btn.accept svg { animation: ring-shake .8s ease-in-out infinite; }
.call-btn.decline { background: #f15c6d; }
.call-btn.decline svg { transform: rotate(135deg); }
.call-btn.ctrl { background: rgba(255,255,255,.15); }
.call-btn.ctrl.active { background: #fff; color: #111; }
@keyframes ring-shake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
/* video-call: dim the centered info so the video shows */
.call-overlay:has(#call-video-wrap:not(.hidden)) .call-info { margin-top: auto; background: rgba(0,0,0,.35); padding: 14px 22px; border-radius: 18px; backdrop-filter: blur(8px); }

/* ===== payment bubbles ===== */
.bubble.bubble-payment { padding: 0; background: transparent !important; box-shadow: none; min-width: 240px; max-width: min(360px, 80%); }
.bubble.bubble-payment .meta-line { padding: 4px 12px 8px; background: var(--panel); border-radius: 0 0 var(--bubble-radius) var(--bubble-radius); margin: 0; height: auto; }
.pay-card { background: linear-gradient(135deg, #1f2937, #111827); color: #fff; border-radius: var(--bubble-radius); padding: 14px; border: 2px solid transparent; }
.pay-card.pay-paid { border-color: #10b981; box-shadow: 0 0 0 1px #10b98144, 0 0 18px #10b98133; }
.pay-card.pay-broadcasting, .pay-card.pay-confirming { border-color: #fbbf24; }
.pay-card.pay-failed, .pay-card.pay-expired { border-color: #ef4444; opacity: .8; }
.pay-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pay-tag { font-size: 12px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; }
.pay-help { background: transparent; border: 1px solid #475569; color: #94a3b8; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-weight: 700; font-size: 12px; }
.pay-help:hover { background: #334155; color: #fff; }
.pay-amount { font-size: 26px; font-weight: 700; margin: 8px 0 4px; color: #fff; }
.pay-amount .pay-net { font-size: 13px; font-weight: 400; color: #94a3b8; }
.pay-memo { margin-bottom: 10px; color: #cbd5e1 !important; }
.pay-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; text-decoration: none; border: 0; cursor: pointer; width: 100%; }
.pay-btn.cta { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; font-size: 15px; padding: 13px 14px; }
@media (hover: hover) { .pay-btn.cta:hover { filter: brightness(1.1); } }
.pay-btn.waiting { background: #1e293b; color: #94a3b8; cursor: default; border: 1px dashed #475569; }
.pay-btn.pending { background: #422006; color: #fbbf24; cursor: default; }
.pay-btn.paid { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.pay-btn.failed { background: #450a0a; color: #fca5a5; cursor: default; }
.pay-tx { font-family: ui-monospace, monospace; font-size: 11px; opacity: .85; }
.pay-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fbbf24; border-radius: 50%; animation: spin .9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* edited tag */
.edited-tag { font-size: 10px; color: rgba(255,255,255,.5); margin-left: 4px; font-style: italic; vertical-align: baseline; }
.bubble.in .edited-tag { color: var(--muted); }

/* msg long-press menu */
.msg-action-menu { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px var(--shadow); z-index: 200; min-width: 180px; padding: 6px; display: flex; flex-direction: column; }
.msg-action-menu button { background: transparent; border: 0; color: var(--text); text-align: left; padding: 10px 14px; font-size: 14px; border-radius: 6px; cursor: pointer; }
.msg-action-menu button:hover { background: var(--hover); }
.msg-action-menu button.danger { color: #f15c6d; }

/* invite QR */
.invite-qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; margin: 10px auto 14px; max-width: 240px; }
.invite-qr svg { width: 100%; height: auto; max-width: 220px; fill: initial; stroke: none; stroke-width: 0; }
.invite-link-box { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; word-break: break-all; font-size: 12px; margin-bottom: 4px; }

/* signature mismatch warning chip — prominent red banner inside bubble */
.sig-warn {
  background: #b91c1c; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 6px;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

/* drag-over highlight when user is dragging a file in */
body.drop-active::after {
  content: 'Pusť obrázek pro odeslání';
  position: fixed; inset: 0;
  background: rgba(37,211,102,.15);
  border: 3px dashed #25d366;
  display: grid; place-items: center;
  color: #25d366; font-size: 22px; font-weight: 600;
  pointer-events: none; z-index: 200;
}

/* TOFU key-change warning banner */
.key-warning {
  display: flex; gap: 14px; align-items: flex-start;
  margin: 8px 0 14px; padding: 14px 16px;
  background: linear-gradient(135deg, rgba(239,68,68,.18), rgba(245,158,11,.12));
  border: 2px solid #ef4444; border-radius: 12px;
  align-self: stretch; max-width: 100%;
}
.kw-icon { font-size: 24px; flex: none; line-height: 1; }
.kw-body { flex: 1; min-width: 0; }
.kw-body strong { display: block; font-size: 15px; margin-bottom: 6px; color: #fca5a5; letter-spacing: .02em; }
.kw-body .small { font-size: 12.5px; line-height: 1.45; }
.kw-fp { background: rgba(0,0,0,.25); padding: 4px 8px; border-radius: 4px; margin-top: 6px; word-break: break-all; }
.kw-fp-new { border-left: 3px solid #ef4444; }
.kw-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kw-actions button { flex: 1; min-width: 140px; padding: 9px 14px; font-size: 13px; }

/* verified contact badge → clickable */
.verified-badge { cursor: pointer; user-select: none; }
.verified-badge.verified-ok { background: rgba(34,197,94,.18); padding: 4px 10px; border-radius: 8px; color: #22c55e; }

/* sticker bubble — no background, just the art */
.bubble.sticker-bubble { background: transparent !important; box-shadow: none !important; padding: 2px 0 0; max-width: 160px; }
.bubble.sticker-bubble .sticker-art { width: 140px; height: 140px; display: block; }
.bubble.sticker-bubble .sticker-art svg { width: 100%; height: 100%; display: block; }
.bubble.sticker-bubble .sticker-art img { width: 100%; height: 100%; display: block; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.18)); }
.bubble.sticker-bubble .meta-line { background: rgba(0,0,0,.3); border-radius: 8px; padding: 2px 6px; backdrop-filter: blur(4px); margin-top: -18px; align-self: flex-end; }

/* sticker picker (anchored above the composer) */
/* sticker picker now lives inside #sticker-modal (a normal .modal) */
.sticker-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(4, 1fr);
  max-height: 60vh; overflow-y: auto;
  padding: 4px 2px;
}
.sticker-grid .sticker-tile {
  border: 0; background: var(--bg); cursor: pointer; padding: 8px;
  border-radius: 14px; display: grid; place-items: center;
  aspect-ratio: 1; transition: transform .1s, background .15s;
}
.sticker-grid .sticker-tile:active { transform: scale(.9); background: var(--hover); }
.sticker-grid .sticker-tile svg { width: 100%; height: 100%; max-width: 72px; display: block; }
.sticker-grid .sticker-tile img { width: 100%; height: 100%; max-width: 86px; display: block; object-fit: contain; filter: drop-shadow(0 3px 5px rgba(0,0,0,.16)); transition: transform .12s; }
.sticker-grid .sticker-tile:hover img { transform: translateY(-2px) scale(1.04); }
@media (max-width: 380px) { .sticker-grid { grid-template-columns: repeat(3, 1fr); } }

.sticker-picker {        /* legacy — kept harmless in case an old node lingers */
  display: none;
}
.sticker-picker.open { display: block; animation: slideUp .15s ease-out; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sticker-picker-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}
.sticker-tile {
  border: 0; background: transparent; cursor: pointer; padding: 6px;
  border-radius: 12px; transition: background .12s, transform .12s;
}
.sticker-tile:hover, .sticker-tile:active { background: var(--hover); transform: scale(1.05); }
.sticker-tile svg { width: 70px; height: 70px; display: block; margin: 0 auto; }
@media (max-width: 480px) {
  .sticker-picker { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .sticker-picker-grid { grid-template-columns: repeat(4, 1fr); }
  .sticker-tile svg { width: 64px; height: 64px; }
}

/* prominent read/delivered/sent status line under the LAST outgoing bubble */
.receipt-line {
  align-self: flex-end; margin: 2px 4px 6px 0; font-size: 12px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 0;
}
.receipt-line::before { content: '✓'; color: var(--muted); }
.receipt-line.delivered::before { content: '✓✓'; color: var(--muted); letter-spacing: -2px; }
.receipt-line.read { color: var(--tick-blue); }
.receipt-line.read::before { content: '✓✓'; color: var(--tick-blue); letter-spacing: -2px; }

/* chat list "✓✓ Přečteno"-style indicator */
.ci-prev-text { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-rcpt { color: var(--muted); letter-spacing: -1px; flex: none; font-size: 12px; }
.ci-rcpt.read { color: var(--tick-blue); }
.ci-rcpt.delivered { color: var(--muted); }

/* ---- disappearing FAB ---- */
.ttl-fab-wrap { position: absolute; right: 22px; bottom: 86px; z-index: 6; }
.ttl-fab {
  display: flex; align-items: center; gap: 7px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 22px; padding: 8px 14px; cursor: pointer;
  box-shadow: 0 3px 12px var(--shadow); font-size: 13px;
}
.ttl-fab svg { width: 18px; height: 18px; color: var(--green); }
.ttl-fab.active { color: var(--green); border-color: var(--green); }
.ttl-menu {
  position: absolute; right: 0; bottom: 52px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 28px var(--shadow); overflow: hidden; min-width: 170px;
}
.ttl-menu-title { padding: 10px 14px 6px; font-size: 12px; color: var(--muted); }
.ttl-menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text);
  padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.ttl-menu button:hover { background: var(--hover); }
.ttl-menu button.sel { color: var(--green); font-weight: 600; }

/* ---- reply bar + composer ---- */
.reply-bar { display: flex; align-items: center; background: var(--panel); padding: 8px 16px; border-left: 3px solid var(--green); }
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-name { color: var(--green); font-size: 13px; font-weight: 600; display: block; }
.reply-bar-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px;
  background: var(--header); border-left: 1px solid var(--border);
}
.composer.safe-bottom { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.rec-overlay.safe-bottom { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.composer textarea {
  flex: 1; resize: none; border: 0; border-radius: 10px; padding: 11px 14px; font-size: 16px; /* 16px = no iOS focus-zoom */
  background: var(--input-bg); color: var(--text); max-height: 140px; line-height: 1.4;
  font-family: inherit;
}
.composer textarea:focus { outline: none; }

/* Official announcements: pinned, one-way and visually distinct from private chats. */
.official-channel-item { position: relative; border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.official-channel-item::after { content: ''; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .3; }
.channel-avatar { background: linear-gradient(145deg, #12b98a, #087a68) !important; color: white; box-shadow: 0 5px 18px rgba(10, 171, 128, .25); }
.official-badge { margin-left: 7px; padding: 2px 6px; border-radius: 999px; background: rgba(18,185,138,.14); color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .06em; vertical-align: 2px; }
.channel-intro { align-self: center; width: min(520px, calc(100% - 24px)); margin: 18px auto 24px; padding: 18px; display: grid; justify-items: center; gap: 7px; text-align: center; border: 1px solid rgba(18,185,138,.28); border-radius: 18px; background: rgba(9,42,38,.78); color: var(--text); }
.channel-intro-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: linear-gradient(145deg, #12b98a, #087a68); font-size: 25px; box-shadow: 0 8px 24px rgba(10,171,128,.25); }
.channel-intro span { color: var(--muted); line-height: 1.45; }
.channel-intro small { color: var(--muted); opacity: .78; }
.channel-post { max-width: min(680px, 88%); border: 1px solid rgba(18,185,138,.18); }
.channel-post.in, .channel-post.out { align-self: flex-start; background: color-mix(in srgb, var(--panel) 90%, var(--accent) 10%); }
.channel-sender { color: var(--accent) !important; font-weight: 800; }
.channel-readonly #composer { display: none !important; }
.channel-open:not(.channel-readonly) #btn-stickers,
.channel-open:not(.channel-readonly) #btn-plus,
.channel-open:not(.channel-readonly) #btn-mic { display: none !important; }
.channel-open:not(.channel-readonly) #composer-input { border-color: rgba(18,185,138,.45); }
.channel-audience-card { max-width: 520px; max-height: min(720px, 88vh); }
.channel-audience-list { overflow: auto; display: grid; gap: 6px; margin-top: 12px; }
.channel-audience-row { display: grid; grid-template-columns: 38px 1fr 28px; align-items: center; gap: 10px; padding: 9px; border-radius: 12px; background: rgba(255,255,255,.035); }
.channel-audience-row > span:nth-child(2) { display: grid; min-width: 0; }
.channel-audience-row small { color: var(--muted); }
.channel-audience-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: rgba(18,185,138,.18); color: var(--accent); font-weight: 800; }
.push-ok { color: var(--accent); }
.send-btn, .mic-btn { background: var(--green-action); color: var(--on-green); }
.send-btn:hover, .mic-btn:hover { background: var(--green-action-dark); color: var(--on-green); }

/* ---- voice recording overlay ---- */
.rec-overlay { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--header); border-left: 1px solid var(--border); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #f15c6d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-size: 16px; }
.rec-hint { color: var(--muted); flex: 1; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 16px; padding: 22px; max-height: 86vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 18px; }
.directory { margin-top: 22px; }
.directory-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.directory-list { list-style: none; max-height: 240px; overflow-y: auto; overflow-x: hidden; }
.directory-list li { display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-radius: 8px; cursor: pointer; }
.directory-list li:hover { background: var(--hover); }
.directory-list li .avatar { flex: none; }
/* name column takes the rest and truncates — long @usernames must NOT stretch the row
 * (that caused a horizontal scroll where the name was hidden until you scrolled right). */
.directory-list .du-info { flex: 1; min-width: 0; }
.directory-list .du-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-list .du-id { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- side panels ---- */
.panel { position: fixed; top: 0; right: 0; width: min(420px, 100%); height: 100dvh; background: var(--bg-2); z-index: 40; box-shadow: -4px 0 24px var(--shadow); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .5; } to { transform: translateX(0); opacity: 1; } }
.panel-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--header); min-height: 60px; position: sticky; top: 0; z-index: 6; }
.panel-head.safe-top { padding-top: calc(14px + env(safe-area-inset-top)); }
.panel-head h3 { font-size: 18px; }
.panel-body { overflow-y: auto; padding: 8px 0 30px; }
.profile-block { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 16px; }
.name-edit { max-width: 260px; text-align: center; font-size: 18px; }
.id-row { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ci-name { font-size: 20px; font-weight: 600; }
.setting-group { padding: 14px 18px; border-top: 8px solid var(--bg); }
.setting-group h4 { color: var(--green); font-size: 13px; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.setting-row > label, .setting-row > div:first-child { flex: 1; }
.setting-group.danger { border-top-color: var(--bg); }
.verified-badge { color: var(--green); font-size: 13px; white-space: nowrap; }
select, .switch { accent-color: var(--green); }
select { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.switch { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; background: var(--panel-2); border-radius: 14px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { left: 21px; }
.app-version { text-align: center; padding: 24px 16px 0; }

/* ---- toast & lightbox ---- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--panel); color: var(--text); padding: 12px 20px; border-radius: 10px; box-shadow: 0 6px 24px var(--shadow); z-index: 100; font-size: 14px; max-width: 90%; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 90; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---- responsive (mobile) ---- */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; height: 100dvh; }
  .conversation { position: fixed; inset: 0; z-index: 20; }
  .app:not(.show-chat) .conversation { display: none; }
  .app.show-chat .sidebar { display: none; }
  .back-btn { display: grid; }
  .messages { padding: 14px 4% 10px; }
  .bubble { max-width: 82%; }
  .ttl-fab-wrap { right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .composer {
    gap: 4px;
    padding: 8px 10px;
  }
  .composer.safe-bottom { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .composer textarea {
    min-width: 0;
    border-radius: 14px;
  }
  /* bigger tap targets on touch devices */
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg { width: 22px; height: 22px; }
  .auth-card { padding: 22px 18px 22px; }
  .auth-back { top: max(8px, env(safe-area-inset-top)); left: 8px; }
  .chat { height: 100dvh; }
  /* keep status bar from overlapping the topbars */
  .sidebar-head, .chat-head, .panel-head { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* iOS standalone PWA (installed via "Add to home screen") gets even safer insets */
@media (display-mode: standalone) {
  .sidebar-head, .chat-head, .panel-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ===================== Wallet (TRON / USDT) ===================== */
#wallet-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 15px; cursor: pointer; }
.btn-ghost:hover { background: var(--active); }
.linklike { background: none; border: 0; color: var(--green); cursor: pointer; font-size: 14px; padding: 8px; align-self: center; }
.wal-big { width: 100%; padding: 14px; font-size: 16px; }
.wal-hero { text-align: center; padding: 12px 0; }
.wal-coin { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: var(--green); color: #fff; font-size: 34px; line-height: 64px; font-weight: 700; }
.wal-hero h2 { margin: 6px 0; }
.wal-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.wal-prose p { margin: 0 0 12px; line-height: 1.5; font-size: 14px; }
.wal-prose p:last-child { margin-bottom: 0; }
.wal-warn { background: rgba(255, 176, 32, .12); border: 1px solid rgba(255, 176, 32, .35); color: #ffcd6b; border-radius: 10px; padding: 12px; font-size: 13.5px; line-height: 1.45; }
.wal-input, .wal-textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); padding: 12px; font-size: 16px; box-sizing: border-box; } /* 16px = no iOS focus-zoom */
.wal-textarea { min-height: 96px; resize: vertical; font-family: inherit; }
.wal-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.wal-status { font-size: 13.5px; min-height: 18px; color: var(--muted); }
.wal-status.err { color: #f15c6d; }
.seed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seed-word { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 15px; display: flex; gap: 8px; }
.seed-i { color: var(--muted); min-width: 18px; text-align: right; }
.wal-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.wal-bar .icon-btn { font-size: 26px; line-height: 1; width: 32px; }
.wal-bar-title { font-weight: 600; font-size: 17px; }
.wal-balance-card { background: linear-gradient(135deg, var(--green), var(--green-dark)); color: #fff; border-radius: var(--radius); padding: 20px; text-align: center; }
.wal-net { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }
.wal-usdt { font-size: 30px; font-weight: 700; margin: 6px 0 2px; }
.wal-trx { font-size: 14px; color: rgba(255,255,255,.85) !important; }
.wal-addr { margin-top: 10px; background: rgba(0,0,0,.2); border: 0; color: #fff; border-radius: 20px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-family: ui-monospace, monospace; }
.wal-actions { display: flex; gap: 10px; }
.wal-actions > button { flex: 1; }
.wal-res { text-align: center; font-size: 12.5px; }
.wal-h3 { margin: 6px 0 0; font-size: 15px; }
.wal-history { display: flex; flex-direction: column; gap: 8px; }
.wal-tx { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.wal-tx-dir { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.wal-tx-dir.in { background: rgba(0,168,132,.18); color: var(--green); }
.wal-tx-dir.out { background: rgba(241,92,109,.16); color: #f15c6d; }
.wal-tx-mid { flex: 1; font-size: 14px; }
.wal-tx-peer { font-family: ui-monospace, monospace; font-size: 12px; }
.wal-tx-link { color: var(--muted); text-decoration: none; font-size: 18px; }
.wal-amt-row { display: flex; gap: 8px; }
.wal-amt-row .wal-input { flex: 1; }
.wal-max { padding: 0 16px; }
.wal-confirm { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.wal-confirm-amt { font-size: 26px; font-weight: 700; text-align: center; }
.wal-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.wal-row .wal-mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; text-align: right; }
.wal-qr { background: #fff; padding: 14px; border-radius: var(--radius); width: max-content; margin: 0 auto; }
.wal-qr svg { width: 220px; height: 220px; display: block; }
.wal-recv-addr { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; }

/* USDT payment request bubble + amount modal */
.usdt-req-card { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.pay-req-title { font-size: 12px; color: var(--muted); }
.pay-req-amt { font-size: 22px; font-weight: 700; }
.pay-req-status { margin-top: 8px; }
.pay-req-status .pay-paid { color: #10b981; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions > button { flex: 1; }
.wal-backup { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.wal-backup button { padding: 8px 16px; }
.wal-backup-text { font-size: 14px; }
.sessions-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.session-meta { font-size: 13.5px; }
/* update banner: in-progress state */
.update-icon.spin { display: inline-block; animation: cc-spin 1s linear infinite; }
@keyframes cc-spin { to { transform: rotate(360deg); } }
.update-progress { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; margin-left: 10px; }
.update-progress-bar { height: 100%; width: 40%; border-radius: 4px; background: #fff; animation: cc-indeterminate 1.1s ease-in-out infinite; }
@keyframes cc-indeterminate { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

:where(button, a, input, textarea, select, [role="button"], [role="menuitem"], .chat-item):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(125, 223, 195, .16);
}
.member-manage-card{max-width:440px}.member-manage-card .modal-head{align-items:flex-start}.member-manage-card .modal-head h3{margin:2px 0 1px;font-size:22px}.mm-label{font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:14px 0 8px}.mm-role-grid{display:grid;gap:8px}.mm-role-grid button,.mm-danger button{width:100%;display:flex;align-items:center;gap:12px;border:1px solid var(--border);border-radius:12px;background:var(--bg);color:var(--text);padding:12px;text-align:left;cursor:pointer}.mm-role-grid button>span:nth-child(2),.mm-danger button>span:nth-child(2){display:grid;gap:2px;flex:1}.mm-role-grid strong,.mm-danger strong{font-size:14px}.mm-role-grid small,.mm-danger small{font-size:11px;color:var(--muted)}.mm-role-icon{font-size:22px}.mm-role-grid i{opacity:0;color:var(--green);font-style:normal;font-weight:900}.mm-role-grid button.active{border-color:var(--green);background:rgba(0,168,132,.12)}.mm-role-grid button.active i{opacity:1}.mm-danger{margin-top:16px}.mm-danger button{margin-bottom:8px}.mm-danger button>span:first-child{font-size:20px}.mm-danger button:last-of-type{color:#ff6577;border-color:rgba(241,92,109,.3)}.mm-danger button.confirming{background:rgba(241,92,109,.14);border-color:#f15c6d;color:#ff8996}.mm-role-grid button:disabled,.mm-danger button:disabled{opacity:.55;cursor:wait}

.composer textarea:focus-visible,
.field input:focus-visible,
.search input:focus-visible,
.name-edit:focus-visible,
.wal-input:focus-visible,
.wal-textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--focus-ring);
}
.group-receipt-card{max-width:460px}.receipt-section{margin-top:16px}.receipt-section h4{display:flex;align-items:center;justify-content:space-between;font-size:13px;color:var(--muted);padding-bottom:8px;border-bottom:1px solid var(--border)}.receipt-section.read h4{color:var(--tick-blue)}.receipt-section h4 span{min-width:24px;text-align:center;padding:2px 7px;border-radius:12px;background:var(--bg)}.receipt-person{display:flex;align-items:center;gap:10px;padding:10px 2px;border-bottom:1px solid rgba(128,128,128,.1)}.receipt-person-main{display:grid;min-width:0;flex:1}.receipt-person-main strong{font-size:14px}.receipt-person-main small,.receipt-person-time small{font-size:10px;color:var(--muted)}.receipt-person-time{display:grid;text-align:right;gap:2px}.receipt-person-time span{font-size:11px}.receipt-section.read .receipt-person-time span{color:var(--tick-blue)}.receipt-empty{text-align:center;padding:12px}.bubble .msg-actions{gap:4px}

/* Desktop bundle has no marketing website or PWA installation step. */
.native-app .auth-back,
.native-app #guest-install { display: none !important; }
.native-only { display: none !important; }
.native-app .native-only.native-settings-group { display: block !important; }
.native-background-hint { margin-top: 10px; line-height: 1.45; }
