/* Connect v3 — one stylesheet, light + dark, phone first. */
:root {
  --bg: #f3f5f9; --bg2: #e9edf4; --card: #ffffff; --ink: #0d1424; --ink2: #3c465a; --muted: #6b7489; --line: #e1e6ef;
  --brand: #5b5bf6; --brand2: #4f46e5; --brand-ink: #ffffff; --accent: #2563eb;
  --ok: #16a34a; --bad: #dc2626; --call: #16a34a; --hang: #e11d48; --read: #0ea5e9;
  --me: #e6e8ff; --me-ink: #16164a; --them: #ffffff;
  --call-bg: #0b1220; --radius: 16px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.06);
  --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --bg2: #111a2c; --card: #121b2d; --ink: #e8edf7; --ink2: #c3cbdb; --muted: #8e99b0; --line: #1f2a40;
    --me: #2b2f6b; --me-ink: #e4e6ff; --brand2: #9f9bff; --them: #172238; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --bg2: #111a2c; --card: #121b2d; --ink: #e8edf7; --ink2: #c3cbdb; --muted: #8e99b0; --line: #1f2a40;
  --me: #2b2f6b; --me-ink: #e4e6ff; --brand2: #9f9bff; --them: #172238; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
body { overscroll-behavior-y: none; }
#app { max-width: 560px; margin: 0 auto; height: 100dvh; position: relative; overflow: hidden; background: var(--bg); }
@media (min-width: 900px) { #app { box-shadow: 0 0 0 1px var(--line); } }
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 1.55rem; letter-spacing: -.01em; } h2 { font-size: 1.15rem; margin: 0 0 .5rem; } h3 { font-size: .8rem; margin: 18px 16px 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
a { color: var(--accent); }
.i { width: 24px; height: 24px; fill: currentColor; flex: none; } .i.sm { width: 18px; height: 18px; } .i.lg { width: 32px; height: 32px; } .i.xs { width: 14px; height: 14px; }
.fine { color: var(--muted); font-size: .85rem; } .center { text-align: center; } .bad { color: var(--bad); } .ok { color: var(--ok); }
.msg { min-height: 1.2em; color: var(--bad); margin: 10px 0 0; font-size: .92rem; } .msg.ok { color: var(--ok); }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; overflow-y: auto; }
.center-col { display: flex; flex-direction: column; align-items: center; padding: calc(24px + var(--safe-t)) 16px 32px; }
.hero { text-align: center; margin: 4vh 0 18px; } .hero p { color: var(--muted); max-width: 340px; margin: 8px auto 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.auth-card { width: 100%; max-width: 400px; }
.points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 12px; max-width: 400px; color: var(--ink2); font-size: .95rem; }
.points li { display: flex; gap: 12px; align-items: flex-start; } .points .i { color: var(--brand2); }
.seg { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.seg-b { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font: inherit; color: var(--muted); cursor: pointer; }
.seg-b.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: .88rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.prefix-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.prefix-input span { padding-left: 14px; color: var(--muted); } .prefix-input input { border: 0; padding-left: 4px; } .prefix-input:focus-within { outline: 2px solid var(--brand); }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; width: 100%; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--bad); } .btn.small { width: auto; padding: 8px 14px; } .btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; padding: 6px 0; }
.link.light { color: #cbd5e1; }
.row-btns { display: flex; justify-content: space-between; margin-top: 8px; }
.avatar-pick { display: flex; justify-content: center; margin: 10px 0 16px; }

/* ---------- main shell ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; }
.tab-page { flex: 1; overflow-y: auto; padding-bottom: calc(76px + var(--safe-b)); }
.bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); min-height: 56px; }
.bar-act { display: flex; gap: 2px; }
.ib { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent; color: var(--ink2); cursor: pointer; flex: none; position: relative; }
.ib:hover { background: var(--bg2); } .ib.big { width: 56px; height: 56px; } .ib.on { color: var(--brand2); }
.searchbar { display: flex; align-items: center; gap: 8px; margin: 2px 12px 8px; padding: 0 12px; background: var(--bg2); border-radius: 12px; color: var(--muted); }
.searchbar input { border: 0; background: transparent; padding: 10px 0; } .searchbar input:focus { outline: none; }
.chip-row { display: flex; gap: 8px; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); font: 500 .85rem system-ui; cursor: pointer; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
.tabbar button { position: relative; background: none; border: 0; font: 500 .7rem system-ui; color: var(--muted); display: grid; gap: 2px; justify-items: center; cursor: pointer; padding: 4px 0; }
.tabbar button.active { color: var(--brand2); } .tabbar button.active .i { transform: scale(1.06); }
.badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--hang); color: #fff; font: 700 .68rem/18px system-ui; text-align: center; }

/* ---------- list rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; position: relative; }
.row:hover { background: var(--bg2); }
.row .mid { flex: 1; min-width: 0; } .row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.row .s { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.row .s .i { width: 16px; height: 16px; }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--muted); font-size: .78rem; }
.row .end .ib { width: 38px; height: 38px; color: var(--brand2); }
.row .unread { background: var(--brand); color: var(--brand-ink); border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px; font: 700 .72rem/20px system-ui; text-align: center; }
.row .end.hot { color: var(--brand2); font-weight: 600; }
.row.missed .t { color: var(--bad); }
.row-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.row-empty .i { width: 48px; height: 48px; opacity: .4; display: block; margin: 0 auto 10px; }
.tag { font: 600 .66rem system-ui; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: var(--bg2); color: var(--muted); }
.tag.free { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.sip { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.section-h { padding: 14px 16px 4px; color: var(--muted); font: 600 .75rem system-ui; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- avatars ---------- */
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; background: #94a3b8 center/cover no-repeat;
  position: relative; border: 0; padding: 0; font-size: 1.05rem; overflow: visible; }
.avatar.sm { width: 36px; height: 36px; font-size: .85rem; } .avatar.xs { width: 24px; height: 24px; font-size: .65rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; cursor: pointer; } .avatar.xxl { width: 120px; height: 120px; font-size: 2.6rem; }
.avatar .on { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2px solid var(--card); }
.avatar.xl::after { content: ""; }
.pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(91,91,246,.45); } 100% { box-shadow: 0 0 0 26px rgba(91,91,246,0); } }

/* ---------- keypad ---------- */
.line-pick { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 7px 10px 7px 12px; font: 600 .9rem system-ui; cursor: pointer; max-width: 62%; }
.line-pick span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; } .dot.off { background: var(--muted); } .dot.bad { background: var(--bad); } .dot.wait { background: var(--brand); }
.balance { display: flex; align-items: center; gap: 6px; border: 0; background: var(--bg2); color: var(--ink); border-radius: 999px; padding: 8px 12px; font: 700 .95rem system-ui; cursor: pointer; }
.dial { display: flex; flex-direction: column; align-items: center; padding: 0 16px; }
.dial-country { min-height: 1.5em; margin-top: 2vh; color: var(--muted); font-size: .95rem; }
.dial-num { width: 100%; }
#number { font-size: clamp(1.6rem, 7vw, 2.3rem); text-align: center; border: 0; background: transparent; padding: 4px 0; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
#number:focus { outline: none; }
.quote { text-align: center; color: var(--muted); min-height: 2.9em; margin: 2px 0 10px; font-size: .92rem; } .quote b { color: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 22px; margin: 0 auto 14px; width: min(320px, 100%); }
.keypad button { aspect-ratio: 1; max-height: 76px; border-radius: 50%; border: 0; background: var(--card); color: var(--ink); font: 400 1.75rem system-ui; cursor: pointer; display: grid; place-items: center; align-content: center; justify-self: center; width: min(76px, 100%); box-shadow: var(--shadow); user-select: none; }
.keypad button small { display: block; font-size: .58rem; color: var(--muted); font-weight: 600; letter-spacing: .12em; margin-top: -4px; }
.keypad button:active { background: var(--bg2); transform: scale(.95); }
.dial-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(320px, 100%); justify-items: center; }
.callbtn { display: grid; place-items: center; width: 70px; height: 70px; border-radius: 50%; border: 0; background: var(--call); color: #fff; cursor: pointer; box-shadow: 0 8px 22px rgba(22,163,74,.35); }
.callbtn:disabled { background: #94a3b8; box-shadow: none; cursor: default; }
.callbtn.hang { background: var(--hang); box-shadow: 0 8px 22px rgba(225,29,72,.4); }
.callbtn.video { background: var(--accent); box-shadow: 0 8px 22px rgba(37,99,235,.4); }

/* ---------- views (stacked full-screen pages) ---------- */
.view { position: absolute; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.view > .bar { position: relative; }
.view .body { flex: 1; overflow-y: auto; padding-bottom: calc(20px + var(--safe-b)); }
.vtitle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.vtitle .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtitle .s { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .vtitle .s.typing { color: var(--ok); }
.group { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 14px; }
@media (min-width: 480px) { .group { margin: 0 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); } }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; font: inherit; color: inherit; text-align: left; }
.item:last-child { border-bottom: 0; } .item .i { color: var(--muted); } .item .mid { flex: 1; min-width: 0; } .item .val { color: var(--muted); font-size: .9rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.item.danger, .item.danger .i { color: var(--bad); }
.item small { display: block; color: var(--muted); font-size: .8rem; }
.switch { position: relative; width: 46px; 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: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span::before { transform: translateX(18px); }
.pad { padding: 0 16px; } .pad-y { padding: 14px 16px; }
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 16px 20px; gap: 6px; }
.profile-head h2 { margin: 6px 0 0; font-size: 1.4rem; } .profile-head .fine { margin: 0; }
.action-row { display: flex; justify-content: center; gap: 12px; padding: 0 16px 18px; flex-wrap: wrap; }
.action-row button { display: grid; justify-items: center; gap: 4px; min-width: 76px; padding: 10px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--brand2); font: 500 .78rem system-ui; cursor: pointer; }
.action-row button span { color: var(--ink2); }

/* ---------- chat thread ---------- */
.thread { flex: 1; overflow-y: auto; padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 2px;
  background: var(--bg) radial-gradient(color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 1px) 0 0/22px 22px; }
.daysep { align-self: center; margin: 10px 0 6px; padding: 3px 10px; border-radius: 8px; background: var(--card); color: var(--muted); font-size: .75rem; box-shadow: var(--shadow); }
.sysmsg { align-self: center; margin: 6px 0; padding: 4px 10px; border-radius: 8px; background: var(--bg2); color: var(--muted); font-size: .78rem; text-align: center; max-width: 85%; }
.msgrow { display: flex; flex-direction: column; max-width: 82%; align-self: flex-start; }
.msgrow.me { align-self: flex-end; align-items: flex-end; }
.msgrow + .msgrow:not(.cont) { margin-top: 6px; }
.bubble { position: relative; padding: 7px 10px 6px; border-radius: 14px; background: var(--them); color: var(--ink); box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; min-width: 64px; }
.me .bubble { background: var(--me); color: var(--me-ink); }
.msgrow:not(.cont) .bubble { border-top-left-radius: 4px; } .msgrow.me:not(.cont) .bubble { border-top-left-radius: 14px; border-top-right-radius: 4px; }
.bubble .who { font: 600 .78rem system-ui; margin-bottom: 2px; }
.bubble .meta { float: right; margin: 6px 0 -4px 10px; font-size: .68rem; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.me .bubble .meta { color: color-mix(in srgb, var(--me-ink) 60%, transparent); }
.tick { width: 16px; height: 16px; fill: currentColor; } .tick.read { fill: var(--read); }
.bubble.deleted { font-style: italic; color: var(--muted); }
.bubble img.media, .bubble video.media { display: block; max-width: min(280px, 64vw); max-height: 320px; border-radius: 10px; margin: -3px -6px 4px; cursor: zoom-in; background: var(--bg2); min-height: 80px; min-width: 120px; object-fit: cover; }
.bubble .file { display: flex; align-items: center; gap: 10px; padding: 6px 2px; text-decoration: none; color: inherit; } .bubble .file .i { width: 34px; height: 34px; color: var(--accent); }
.bubble .quote-in { border-left: 3px solid var(--brand); background: color-mix(in srgb, var(--ink) 6%, transparent); padding: 4px 8px; border-radius: 6px; margin-bottom: 4px; font-size: .85rem; color: var(--ink2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble.callmsg { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.bubble.callmsg .i { color: var(--ok); } .bubble.callmsg.miss .i { color: var(--bad); }
.voice { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.voice button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.voice .bar { flex: 1; height: 4px; background: color-mix(in srgb, var(--ink) 15%, transparent); border-radius: 2px; position: static; padding: 0; min-height: 0; backdrop-filter: none; display: block; }
.voice .bar i { display: block; height: 100%; width: 0; background: var(--brand2); border-radius: 2px; }
.voice .d { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line); }
.composer .box { flex: 1; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 22px; min-width: 0; }
.composer textarea { border: 0; resize: none; max-height: 140px; padding: 10px 14px; background: transparent; line-height: 1.35; border-radius: 22px; }
.composer textarea:focus { outline: none; }
.composer .ib { width: 44px; height: 44px; }
.sendbtn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; cursor: pointer; flex: none; touch-action: none; }
.sendbtn.rec { background: var(--hang); color: #fff; animation: pulse 1.2s infinite; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line); font-size: .85rem; color: var(--ink2); }
.reply-bar div { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--brand); padding-left: 8px; }
.rec-bar { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 46px; color: var(--hang); font-variant-numeric: tabular-nums; }
.rec-bar .dotrec { width: 10px; height: 10px; border-radius: 50%; background: var(--hang); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.upl { font-size: .78rem; color: var(--muted); padding: 2px 4px; }
.newmsgs { position: absolute; right: 14px; bottom: 82px; width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; transform: rotate(-90deg); }

/* ---------- sheet / menus ---------- */
.sheet-wrap { position: absolute; inset: 0; z-index: 40; background: rgba(2,6,23,.45); display: flex; align-items: flex-end; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0; padding: 8px 0 calc(12px + var(--safe-b)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); } }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { padding: 0 18px; margin: 4px 0 10px; } .sheet .form { padding: 0 18px; } .sheet .item { border-bottom-color: transparent; }
.sheet .sheet-actions { display: flex; gap: 10px; padding: 14px 18px 0; }

/* ---------- call screen ---------- */
.call, .incoming { position: absolute; inset: 0; z-index: 30; background: radial-gradient(120% 80% at 50% 0%, #1b2a4a 0%, var(--call-bg) 60%); color: #f8fafc;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: calc(14px + var(--safe-t)) 16px calc(30px + var(--safe-b)); overflow: hidden; }
.call-top { width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.call-line { font-size: .8rem; color: #9fb0cf; display: flex; align-items: center; gap: 6px; margin: 0; }
.call-quality { display: flex; align-items: flex-end; gap: 2px; height: 16px; } .call-quality i { width: 4px; background: rgba(255,255,255,.25); border-radius: 1px; }
.call-quality i:nth-child(1) { height: 25%; } .call-quality i:nth-child(2) { height: 50%; } .call-quality i:nth-child(3) { height: 75%; } .call-quality i:nth-child(4) { height: 100%; }
.call-quality[data-q="1"] i:nth-child(-n+1), .call-quality[data-q="2"] i:nth-child(-n+2) { background: #f59e0b; }
.call-quality[data-q="3"] i:nth-child(-n+3), .call-quality[data-q="4"] i:nth-child(-n+4) { background: #4ade80; }
.call-quality[data-q="0"] i:nth-child(1) { background: #f43f5e; }
.call-who { text-align: center; margin-top: 4vh; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.call-who h2 { font-size: 1.9rem; margin: 18px 0 2px; font-weight: 600; } .call-sub { color: #9fb0cf; margin: 0; }
.call-state { margin: 10px 0 0; color: #cbd5e1; } .call-timer { font-size: 1.25rem; font-variant-numeric: tabular-nums; margin: 4px 0 0; min-height: 1.4em; } .call-cost { font-size: .82rem; color: #9fb0cf; margin: 2px 0 0; min-height: 1.2em; }
.call.video-on { background: #000; } .call.video-on .call-who { margin-top: 0; } .call.video-on .call-who .avatar, .call.video-on .call-cost { display: none; }
.call.video-on .call-who h2 { font-size: 1.2rem; margin-top: 4px; text-shadow: 0 1px 3px #000; }
.rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 0; }
.lv { position: absolute; right: 14px; top: calc(54px + var(--safe-t)); width: 28vw; max-width: 140px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; z-index: 3; box-shadow: 0 4px 14px rgba(0,0,0,.5); background: #111; transform: scaleX(-1); touch-action: none; cursor: grab; }
.lv.noflip { transform: none; }
.call-ctl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 10px; width: min(380px, 100%); z-index: 2; margin-bottom: 18px; }
.cb { display: grid; justify-items: center; gap: 6px; background: none; border: 0; color: #e2e8f0; font: 500 .72rem system-ui; cursor: pointer; }
.cb .i { width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: rgba(255,255,255,.12); box-sizing: border-box; }
.cb[aria-pressed="true"] .i { background: #f8fafc; color: var(--call-bg); } .cb:disabled { opacity: .35; cursor: default; }
.cb.rec[aria-pressed="true"] .i { background: var(--hang); color: #fff; }
#b-hang { z-index: 2; }
.call .keypad { z-index: 2; margin-bottom: 10px; } .dtmf button { background: rgba(255,255,255,.1); color: #fff; box-shadow: none; } .dtmf button small { color: #9fb0cf; }
.dtmf-sent { min-height: 1.4em; letter-spacing: .2em; color: #cbd5e1; z-index: 2; font-variant-numeric: tabular-nums; }
.call-banner { z-index: 4; position: absolute; top: calc(50px + var(--safe-t)); left: 12px; right: 12px; background: #f8fafc; color: #0b1220; border-radius: 16px; padding: 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.call-banner .mid { flex: 1; min-width: 0; } .call-banner .t { font-weight: 700; } .call-banner .s { font-size: .82rem; color: #475569; }
.call-banner .callbtn { width: 46px; height: 46px; } .call-banner .callbtn .i { width: 24px; height: 24px; }
.in-actions { display: flex; justify-content: space-around; width: min(380px, 100%); margin-bottom: 8px; }
.in-actions > div { display: grid; justify-items: center; gap: 8px; color: #cbd5e1; font-size: .85rem; }
.in-actions .callbtn { width: 74px; height: 74px; }
#b-accept { animation: wiggle 1.4s infinite; } @keyframes wiggle { 0%, 60%, 100% { transform: none; } 70% { transform: rotate(-12deg); } 80% { transform: rotate(12deg); } 90% { transform: rotate(-8deg); } }
.mini-call { position: absolute; z-index: 25; left: 10px; right: 10px; top: calc(8px + var(--safe-t)); background: var(--call); color: #fff; border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 600; }
.mini-call .mid { flex: 1; } .mini-call .s { font-weight: 400; font-size: .8rem; opacity: .9; }

/* ---------- media viewer ---------- */
.viewer { position: absolute; inset: 0; z-index: 50; background: rgba(0,0,0,.94); display: flex; flex-direction: column; }
.viewer .vbar { display: flex; justify-content: space-between; padding: calc(8px + var(--safe-t)) 8px 8px; color: #fff; } .viewer .ib { color: #fff; }
.viewer .vbody { flex: 1; display: grid; place-items: center; min-height: 0; } .viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- misc ---------- */
#toast { position: absolute; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }
.rates { width: 100%; border-collapse: collapse; } .rates th, .rates td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.rates th { color: var(--muted); font-weight: 500; font-size: .78rem; } .rates td:last-child, .rates th:last-child { text-align: right; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; } .chains { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick { padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 1rem system-ui; cursor: pointer; }
.pick.active { border-color: var(--brand); outline: 2px solid var(--brand); } .chains .pick { font-size: .82rem; font-weight: 500; }
.exact { font-size: 1.7rem; display: flex; align-items: center; gap: 8px; } .exact span { font-size: 1rem; color: var(--muted); }
.addr { display: flex; align-items: center; gap: 6px; background: var(--bg2); border-radius: 10px; padding: 8px 10px; } .addr code { word-break: break-all; font-size: .82rem; flex: 1; }
.qr { display: grid; place-items: center; margin: 14px 0; } .qr img { background: #fff; padding: 8px; border-radius: 10px; width: 180px; height: 180px; image-rendering: pixelated; }
.warn { font-size: .85rem; color: var(--ink2); background: var(--bg2); border-left: 3px solid var(--brand); padding: 8px 10px; border-radius: 6px; }
.status { font-weight: 600; } .status.ok { color: var(--ok); }
.meter { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; } .meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.pickrow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; } .pickrow input { width: 20px; height: 20px; flex: none; accent-color: var(--brand2); }
.selected-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; } .selected-chips span { background: var(--bg2); padding: 4px 10px; border-radius: 999px; font-size: .85rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.banner { margin: 0 12px 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--brand) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); font-size: .9rem; display: flex; gap: 10px; align-items: center; }
.banner .mid { flex: 1; } .banner .btn { width: auto; padding: 8px 12px; }
.dial-actions > [hidden] { display: inline-grid !important; visibility: hidden; }

/* ---------- v3: encryption, linking, feed ---------- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.wrap { overflow-wrap: anywhere; white-space: normal; }
.big { font-size: 1.4rem; }
.pad-x { padding: 0 16px; margin: 4px 0; }
.sysmsg.e2e { background: color-mix(in srgb, var(--brand) 12%, var(--bg2)); color: var(--ink2); }
.tick.bad { fill: var(--bad); }
.steps { padding-left: 1.2em; margin: 8px 0 4px; color: var(--ink2); } .steps li { margin: 4px 0; }
.qr.big img { width: min(240px, 70vw); height: auto; aspect-ratio: 1; }
.scanner { margin: 10px 0; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.posts { list-style: none; margin: 0; padding: 0 0 calc(80px + var(--safe-b)); }
.post { background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 10px; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.post-head .mid { flex: 1; min-width: 0; } .post-head small { display: block; color: var(--muted); font-size: .78rem; }
.post-imgs { display: grid; gap: 2px; background: var(--bg2); }
.post-imgs.n2, .post-imgs.n4 { grid-template-columns: 1fr 1fr; } .post-imgs.n3 { grid-template-columns: 1fr 1fr; } .post-imgs.n3 img:first-child { grid-column: span 2; }
.post-img { width: 100%; height: auto; max-height: 70vh; object-fit: cover; display: block; background: var(--bg2); min-height: 120px; cursor: zoom-in; }
.post-imgs.n2 .post-img, .post-imgs.n3 .post-img, .post-imgs.n4 .post-img { aspect-ratio: 1; max-height: none; }
.post-ext { display: flex; gap: 8px; align-items: center; padding: 14px; color: var(--muted); font-size: .9rem; }
.post-text { margin: 10px 14px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-act { display: flex; gap: 6px; padding: 2px 6px 8px; }
.post-act .ib { display: inline-flex; gap: 4px; align-items: center; width: auto; padding: 0 10px; color: var(--ink2); }
.post-act .ib span { font-size: .85rem; } .post-act .ib.liked { color: var(--brand2); }
.post-pick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.post-pick .pp { width: 72px; height: 72px; border-radius: 10px; background: center / cover var(--bg2); position: relative; }
.post-pick .pp .ib { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; background: var(--card); border-radius: 50%; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid .cell { aspect-ratio: 1; border: 0; padding: 0; background: var(--bg2); position: relative; overflow: hidden; color: var(--ink2); font: inherit; font-size: .78rem; cursor: pointer; }
.grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .cell span { display: block; padding: 8px; text-align: left; }
.grid .cell .lk { position: absolute; right: 6px; top: 6px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.media.expired { opacity: .5; }
.row .s.wrap { white-space: pre-wrap; }
