/* ==========================================================================
   Chat — tokens
   ========================================================================== */
:root {
    --paper: #eef0f7;          /* chat background */
    --surface: #ffffff;        /* panels, their bubbles */
    --surface-2: #eceef6;      /* inputs, chips */
    --line: #e1e4ef;
    --ink: #191b33;
    --ink-2: #5f6485;
    --ink-3: #979cb8;
    --mine: #3d50ff;           /* ultramarine: my bubbles */
    --mine-deep: #2d3ff0;
    --mine-ink: #ffffff;
    --mine-2: rgba(255, 255, 255, .72);
    --signal: #ff3d64;         /* recording, unread, hang up */
    --live: #14a874;           /* online, answer */
    --read: #3dffa8;           /* read ticks on my blue bubble — clearly different from grey */
    --read-on-light: #10b981;  /* read ticks on white (contacts list) */
    --glow: rgba(61, 80, 255, .10);
    --shadow: 0 1px 1px rgba(25, 27, 51, .05), 0 6px 18px -10px rgba(25, 27, 51, .22);
    --pop: 0 24px 60px -16px rgba(20, 22, 50, .38), 0 0 0 1px rgba(25, 27, 51, .05);
    --r-bubble: 20px;
    --r-tail: 6px;
    --font: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --paper: #101327;
        --surface: #181c36;
        --surface-2: #232847;
        --line: #252a4a;
        --ink: #eceeff;
        --ink-2: #a2a7cc;
        --ink-3: #6c7299;
        --mine: #4a5cff;
        --mine-deep: #3b4cf0;
        --glow: rgba(74, 92, 255, .16);
        --shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 6px 18px -10px rgba(0, 0, 0, .7);
        --pop: 0 24px 60px -16px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
        color-scheme: dark;
    }
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.4;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mine); outline-offset: 2px; }

.msym {
    font-family: 'Material Symbols Rounded';
    font-weight: 400;
    font-style: normal;
    font-size: 22px;
    line-height: 1;
    display: inline-block;
    width: 1em;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    font-variation-settings: 'FILL' 0, 'opsz' 24;
}
.msym.fill { font-variation-settings: 'FILL' 1, 'opsz' 24; }

.icon-btn {
    width: 40px; height: 40px;
    border: 0; border-radius: 50%;
    background: transparent;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ink-2);
    flex-shrink: 0;
    transition: background-color .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .msym { font-size: 20px; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
    flex-shrink: 0; position: relative;
    background: var(--ink-3);
    text-transform: uppercase;
}

.alert {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: color-mix(in srgb, var(--signal) 12%, var(--surface));
    color: var(--signal);
    border-radius: 14px; padding: 10px 12px; font-size: 14px; font-weight: 500;
}
.alert .msym { font-size: 20px; }
.alert.inline { margin: 0 12px 8px; }
.link-btn { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

/* ==========================================================================
   Login
   ========================================================================== */
.login {
    position: relative; overflow: hidden;
    min-height: 100dvh;
    display: grid; place-items: center;
    padding: 24px 16px;
    background: var(--paper);
}
.login::before, .login::after {
    content: ''; position: absolute; border-radius: 50%; pointer-events: none;
    filter: blur(60px); opacity: .55;
}
.login::before { width: 420px; height: 420px; top: -140px; right: -120px; background: color-mix(in srgb, var(--mine) 45%, transparent); }
.login::after { width: 360px; height: 360px; bottom: -150px; left: -120px; background: color-mix(in srgb, #8a5cff 35%, transparent); }
.login-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 360px;
    text-align: center;
}
.login-logo {
    width: 76px; height: 76px; border-radius: 24px;
    margin: 0 auto 18px; display: block;
    box-shadow: 0 18px 40px -14px color-mix(in srgb, var(--mine) 80%, transparent);
}
.login h1 { font-size: 30px; line-height: 1.1; margin: 0 0 6px; font-weight: 800; letter-spacing: -.02em; }
.login-sub { margin: 0 0 26px; color: var(--ink-2); font-size: 15px; }
.login form {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-radius: 26px; padding: 18px; box-shadow: var(--shadow);
    text-align: left;
}
.login .alert { margin-bottom: 14px; text-align: left; }
.field { display: block; margin-bottom: 12px; position: relative; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field input {
    width: 100%; padding: 14px 14px;
    border: 1.5px solid transparent; border-radius: 15px;
    background: var(--surface-2); outline: none; font-size: 16px;
    transition: border-color .15s, background-color .15s;
}
.field input:focus { border-color: var(--mine); background: var(--surface); }
.field.iconed .msym { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 21px; pointer-events: none; }
.field.iconed input { padding-left: 46px; }
.field.iconed input:focus + .msym, .field.iconed:focus-within .msym { color: var(--mine); }
.btn-primary {
    width: 100%; margin-top: 4px; padding: 15px;
    border: 0; border-radius: 15px;
    background: linear-gradient(160deg, var(--mine), var(--mine-deep)); color: #fff;
    font-weight: 700; font-size: 16px;
    box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--mine) 80%, transparent);
    transition: transform .12s, filter .15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.98); }
.login-card .login-mark {
    width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 18px;
    background: linear-gradient(160deg, var(--mine), var(--mine-deep)); color: #fff;
    display: grid; place-items: center;
}
.login-card .login-mark .msym { font-size: 30px; }

/* ==========================================================================
   App layout
   ========================================================================== */
.app {
    height: var(--app-h, 100dvh);
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
}
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); }
.pane-list { background: var(--surface); }
.app.in-chat .pane-list { display: none; }
.app:not(.in-chat) .pane-chat { display: none; }

@media (min-width: 860px) {
    .app {
        grid-template-columns: 350px 1fr;
        max-width: 1200px;
        margin: 0 auto;
        border-left: 1px solid var(--line);
        border-right: 1px solid var(--line);
    }
    .app.in-chat .pane-list, .app:not(.in-chat) .pane-chat { display: flex; }
    .pane-list { border-right: 1px solid var(--line); }
    .back { display: none !important; }
}

.bar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 8px 8px 14px;
    padding-top: max(8px, env(safe-area-inset-top));
    min-height: 62px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-title strong { font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.bar-title small.online { color: var(--live); font-weight: 600; }
.bar-title small.live { color: var(--mine); font-weight: 600; }
#peerStatus { text-overflow: clip; }
#peerStatus span { display: inline-block; white-space: nowrap; }
#peerStatus.marquee span { animation: status-slide var(--dur, 8s) ease-in-out infinite; }
@keyframes status-slide {
    0%, 18% { transform: translateX(0); }
    62%, 80% { transform: translateX(var(--shift, 0)); }
    100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) { #peerStatus.marquee span { animation: none; } }
.chat-bar { padding-left: 4px; gap: 6px; }
.chat-bar .avatar { margin-right: 4px; }
@media (min-width: 860px) { .chat-bar { padding-left: 18px; } }
@media (max-width: 380px) { .chat-bar .avatar { display: none; } }

/* Notifications banner */
.notif-banner {
    margin: 4px 12px 6px; padding: 10px 6px 10px 12px;
    display: flex; align-items: center; gap: 10px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--mine) 9%, var(--surface));
    font-size: 13.5px; color: var(--ink-2);
}
.notif-banner > .msym { color: var(--mine); }
.notif-banner p { flex: 1; margin: 0; }
.notif-banner > button:not(.icon-btn) {
    border: 0; border-radius: 10px; padding: 7px 12px;
    background: var(--mine); color: #fff; font-weight: 700; font-size: 13.5px;
}

/* Search */
.search {
    margin: 10px 12px 6px;
    display: flex; align-items: center; gap: 6px;
    background: var(--surface-2);
    border-radius: 14px;
    padding: 0 4px 0 12px;
}
.search > .msym { color: var(--ink-3); font-size: 20px; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 11px 4px; font-size: 16px; }
.search .icon-btn { background: var(--mine); color: #fff; }

/* Contacts */
.contacts { list-style: none; margin: 0; padding: 4px 0 16px; overflow-y: auto; flex: 1; }
.contact {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; margin: 0 6px; border-radius: 18px;
    cursor: pointer;
    transition: background-color .12s;
}
.contact:hover { background: var(--surface-2); }
.contact.active { background: color-mix(in srgb, var(--mine) 11%, var(--surface)); }
.contact .avatar { width: 50px; height: 50px; font-size: 19px; }
.contact .dot {
    position: absolute; right: 0; bottom: 1px;
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--live); border: 2.5px solid var(--surface);
}
.contact-main { flex: 1; min-width: 0; }
.contact-top, .contact-bottom { display: flex; align-items: center; gap: 8px; }
.contact-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-time { font-size: 12px; color: var(--ink-3); flex-shrink: 0; }
.contact.unread .contact-time { color: var(--mine); font-weight: 700; }
.contact-preview {
    flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2);
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap; overflow: hidden; margin-top: 1px;
}
.contact-preview span:last-child { overflow: hidden; text-overflow: ellipsis; }
.contact-preview .msym { font-size: 17px; }
.contact-preview .you { flex-shrink: 0; }
.contact-preview.gone { font-style: italic; }
.contact-preview.live { color: var(--mine); font-weight: 600; }
.contact.unread .contact-preview { color: var(--ink); font-weight: 500; }
.badge {
    min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px;
    background: var(--mine); color: #fff; font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tag-admin { color: var(--mine); font-size: 17px !important; vertical-align: -3px; }

.empty, .chat-placeholder {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; color: var(--ink-2); padding: 32px; gap: 10px;
}
.empty .msym, .chat-placeholder .msym { font-size: 40px; color: var(--ink-3); }
.empty p, .chat-placeholder p { margin: 0; max-width: 30ch; }

/* ==========================================================================
   Chat
   ========================================================================== */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.scroller {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 10px 10px;
    background: var(--paper);
}
@media (min-width: 860px) { .scroller { padding: 12px 32px 12px; } }
.messages { list-style: none; margin: 0 auto; padding: 0; max-width: 820px; display: flex; flex-direction: column; }
.loading { align-self: center; color: var(--ink-3); font-size: 13px; padding: 14px 0; }

.day { align-self: center; margin: 16px 0 8px; }
.day span {
    display: inline-block;
    padding: 4px 12px; border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    color: var(--ink-2);
    font-size: 12.5px; font-weight: 600;
    box-shadow: var(--shadow);
}

.msg { display: flex; margin-top: 2px; position: relative; }
.msg.first { margin-top: 9px; }
.msg.mine { justify-content: flex-end; }
.bubble-wrap { position: relative; max-width: min(80%, 540px); display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine .bubble-wrap { align-items: flex-end; }
.bubble {
    position: relative;
    max-width: 100%;
    padding: 7px 12px 7px;
    border-radius: var(--r-bubble);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
    transition: box-shadow .3s;
}
.msg.mine .bubble { background: linear-gradient(170deg, var(--mine), var(--mine-deep)); color: var(--mine-ink); }
.msg.theirs.last .bubble { border-bottom-left-radius: var(--r-tail); }
.msg.mine.last .bubble { border-bottom-right-radius: var(--r-tail); }
.msg.flash .bubble { box-shadow: 0 0 0 3px var(--signal); }
.msg.enter .bubble-wrap { animation: pop-in .22s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .msg.enter .bubble-wrap { animation: none; } }

.text { white-space: pre-wrap; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.text.big-emoji { font-size: 40px; line-height: 1.15; }
.meta-space { display: inline-block; height: 1px; vertical-align: bottom; }

.meta {
    position: absolute; right: 11px; bottom: 6px;
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11.5px; color: var(--ink-3);
    white-space: nowrap; user-select: none; line-height: 1;
}
.msg.mine .meta { color: var(--mine-2); }
.meta .msym { font-size: 16px; }
.meta .msym.ticks { font-size: 17px; }
.ticks.sent, .ticks.dlv { opacity: .85; }
.meta .ticks.read, .ticks.read { color: var(--read); opacity: 1; font-variation-settings: 'FILL' 1, 'wght' 600, 'opsz' 24; }
.contact-preview .ticks { font-size: 18px; color: var(--ink-3); flex-shrink: 0; margin-right: 1px; }
.contact-preview .ticks.read { color: var(--read-on-light); }
.msg-info .info-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.msg-info .info-row:first-child { border-top: 0; }
.msg-info .ticks { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--mine); color: rgba(255,255,255,.75); font-size: 20px; }
.msg-info .ticks.read { color: var(--read); }
.msg-info b { display: block; font-size: 15px; }
.msg-info span { color: var(--ink-2); font-size: 14px; }
.meta .edited { font-style: italic; }
.meta .pending-ico { font-size: 14px; }
.meta.on-media {
    right: 10px; bottom: 8px;
    padding: 3px 7px; border-radius: 10px;
    background: rgba(10, 12, 30, .55); color: #fff;
}
.meta-row { height: 20px; position: relative; }
.voice .meta, .meta-row .meta { position: static; }
.meta-row .meta { position: absolute; right: 7px; bottom: 2px; }

/* reply quote inside bubble */
.quote {
    display: block; width: 100%; text-align: left;
    border: 0; margin: 2px 0 6px; padding: 6px 10px;
    border-radius: 12px; border-left: 3px solid var(--mine);
    background: color-mix(in srgb, var(--ink) 6%, transparent);
    font-size: 13.5px;
}
.msg.mine .quote { background: rgba(255, 255, 255, .16); border-left-color: #fff; }
.quote b { display: block; font-size: 12.5px; color: var(--mine); }
.msg.mine .quote b { color: #fff; }
.quote span { display: flex; align-items: center; gap: 4px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote .msym { font-size: 15px; }

.deleted { display: inline-flex; align-items: center; gap: 6px; font-style: italic; opacity: .75; }
.deleted .msym { font-size: 18px; }

/* reactions */
.reacts {
    position: relative; z-index: 1;
    margin: -8px 10px 0;
    display: inline-flex; align-items: center; gap: 2px;
    padding: 2px 7px; border-radius: 999px;
    border: 2px solid var(--paper);
    background: var(--surface); box-shadow: var(--shadow);
    font-size: 14px; line-height: 1.3;
}
.reacts b { font-size: 12px; color: var(--ink-2); margin-left: 3px; }
.reacts.mine-react { background: color-mix(in srgb, var(--mine) 14%, var(--surface)); }

/* call log */
.msg.call-row .bubble { display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 10px; cursor: pointer; }
.call-ic {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--live) 15%, transparent); color: var(--live);
}
.msg.mine .call-ic { background: rgba(255, 255, 255, .18); color: #fff; }
.call-ic.missed { background: color-mix(in srgb, var(--signal) 14%, transparent); color: var(--signal); }
.call-ic .msym { font-size: 20px; }
.call-text b { display: block; font-size: 14.5px; }
.call-text small { font-size: 12px; opacity: .7; }

/* message actions trigger (desktop hover) */
.more {
    position: absolute; top: 4px;
    width: 28px; height: 28px; border-radius: 50%; border: 0;
    background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow);
    display: none; align-items: center; justify-content: center; z-index: 2;
}
.msg.mine .more { left: -34px; }
.msg.theirs .more { right: -34px; }
.more .msym { font-size: 20px; }
@media (hover: hover) { .msg:hover .more { display: inline-flex; } }
@media (hover: none) {
    .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

/* media */
.bubble.has-media { padding: 4px; }
.bubble.has-media .caption { padding: 5px 8px 3px; }
.media-img, .media-video {
    display: block; position: relative;
    border: 0; padding: 0; margin: 0;
    border-radius: 16px; overflow: hidden;
    background: color-mix(in srgb, var(--ink) 10%, transparent);
    max-width: 100%;
}
.media-img img, .media-video video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-video video { background: #000; }
.media-local { opacity: .7; }
.bubble.has-media > .meta { right: 12px; bottom: 7px; }

.progress { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 12, 30, .35); }
.progress-ring {
    width: 54px; height: 54px; border-radius: 50%;
    background: conic-gradient(#fff calc(var(--p, 0) * 1%), rgba(255,255,255,.25) 0);
    display: grid; place-items: center;
}
.progress-ring button {
    width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: rgba(10, 12, 30, .7); color: #fff;
    display: grid; place-items: center;
}

/* voice notes */
.bubble.has-voice { padding: 8px 12px 6px 8px; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 232px; }
.voice-play {
    width: 42px; height: 42px; border-radius: 50%; border: 0; flex-shrink: 0;
    background: var(--mine); color: #fff;
    display: grid; place-items: center;
}
.msg.mine .voice-play { background: #fff; color: var(--mine); }
.voice-play .msym { font-size: 28px; }
.voice-body { flex: 1; min-width: 0; }
.wave { height: 32px; display: flex; align-items: center; gap: 2px; cursor: pointer; touch-action: none; }
.wave i {
    flex: 1; min-width: 2px; max-width: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--ink) 25%, transparent);
    height: calc(12% + var(--h) * .88%);
    transition: background-color .1s;
}
.wave i.on { background: var(--mine); }
.msg.mine .wave i { background: rgba(255, 255, 255, .38); }
.msg.mine .wave i.on { background: #fff; }
.voice-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.msg.mine .voice-foot { color: var(--mine-2); }
.voice-right { display: inline-flex; gap: 6px; align-items: center; }
.voice-speed {
    border: 0; border-radius: 9px; padding: 1px 7px;
    font-size: 11.5px; font-weight: 700;
    background: color-mix(in srgb, var(--ink) 10%, transparent); color: inherit;
}
.msg.mine .voice-speed { background: rgba(255, 255, 255, .2); }

/* jump-to-bottom */
.jump {
    position: absolute; right: 14px; bottom: 132px;
    width: 42px; height: 42px; border-radius: 50%; border: 0;
    background: var(--surface); color: var(--ink-2); box-shadow: var(--pop);
    display: grid; place-items: center; z-index: 3;
}
.jump b {
    position: absolute; top: -6px; right: -4px;
    min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
    background: var(--mine); color: #fff; font-size: 11.5px;
    display: grid; place-items: center;
}
.jump b:empty { display: none; }

/* ==========================================================================
   Composer
   ========================================================================== */
.composer {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.quick {
    display: flex; gap: 6px; overflow-x: auto;
    padding: 8px 12px 0;
    scrollbar-width: none;
}
.quick::-webkit-scrollbar { display: none; }
.quick button {
    flex-shrink: 0;
    border: 0; background: var(--surface-2);
    border-radius: 999px; padding: 6px 12px;
    font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--ink-2);
    transition: background-color .12s, color .12s;
}
.quick button:hover { background: color-mix(in srgb, var(--mine) 14%, var(--surface)); color: var(--mine); }
.composer.no-quick .quick { display: none; }

.context-bar {
    display: flex; align-items: center; gap: 10px;
    margin: 8px 12px 0; padding: 8px 6px 8px 12px;
    border-radius: 14px; background: var(--surface-2);
    border-left: 3px solid var(--mine);
}
.context-bar > .msym { color: var(--mine); }
.context-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; }
.context-body b { color: var(--mine); font-size: 13px; }
.context-body span { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.context-body .msym { font-size: 16px; }

.compose-row, .rec-row { display: flex; align-items: flex-end; gap: 2px; padding: 8px 8px 10px; }
.compose-row > .icon-btn { margin-bottom: 4px; }
.icon-btn.ghost { color: var(--ink-2); }
#quickToggle[aria-pressed="true"] { color: var(--mine); }
.input-wrap {
    flex: 1; min-width: 0;
    display: flex; align-items: flex-end;
    min-height: 46px;
    background: var(--surface-2); border-radius: 23px;
    padding: 3px 4px 3px 16px;
    margin: 0 4px;
    border: 1.5px solid transparent;
    transition: border-color .15s;
}
.input-wrap:focus-within { border-color: color-mix(in srgb, var(--mine) 55%, transparent); }
.input-wrap textarea {
    flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
    font-size: 16px; line-height: 22px; padding: 9px 0; margin: 0;
    min-height: 40px; max-height: 140px; overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--ink-3); }
.input-wrap .icon-btn { margin-bottom: 1px; }
.action-btn {
    width: 46px; height: 46px; border-radius: 50%; border: 0; flex-shrink: 0;
    background: linear-gradient(160deg, var(--mine), var(--mine-deep)); color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--mine) 70%, transparent);
    transition: transform .12s;
}
.action-btn:active { transform: scale(.94); }
.action-btn .msym { font-size: 24px; }

/* recording */
.rec-row { align-items: center; }
.rec-live {
    flex: 1; min-width: 0; height: 46px;
    display: flex; align-items: center; gap: 10px;
    background: color-mix(in srgb, var(--signal) 10%, var(--surface-2));
    border-radius: 23px; padding: 0 16px; margin: 0 4px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--signal); animation: blink 1s infinite; flex-shrink: 0; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--signal); min-width: 40px; }
.rec-live canvas { flex: 1; min-width: 0; height: 34px; }
.rec-row .action-btn { background: var(--signal); box-shadow: none; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

/* ==========================================================================
   Floating: menus, emoji, overlay, dialogs
   ========================================================================== */
.menu {
    position: fixed; z-index: 70;
    min-width: 230px; max-width: calc(100vw - 16px); padding: 6px;
    background: var(--surface); border-radius: 18px; box-shadow: var(--pop);
    display: flex; flex-direction: column;
}
.menu button, .menu a {
    display: flex; align-items: center; gap: 12px;
    border: 0; background: transparent; text-align: left;
    padding: 11px 12px; border-radius: 12px;
    font-size: 15px; color: var(--ink); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .msym { color: var(--ink-2); font-size: 21px; }
.menu .danger, .menu .danger .msym { color: var(--signal); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.react-bar { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .react-bar button { padding: 6px; font-size: 24px; line-height: 1; border-radius: 50%; width: 40px; height: 40px; justify-content: center; }
.menu .react-bar button.on { background: color-mix(in srgb, var(--mine) 18%, var(--surface)); }
.menu .react-bar .react-more { background: var(--surface-2); }
.menu .react-bar .react-more .msym { font-size: 20px; }

.emoji-pop {
    position: fixed; z-index: 75;
    width: 304px; max-width: calc(100vw - 24px);
    max-height: 260px; overflow-y: auto;
    padding: 8px;
    background: var(--surface); border-radius: 18px; box-shadow: var(--pop);
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-pop button { border: 0; background: transparent; font-size: 24px; padding: 4px 0; border-radius: 8px; line-height: 1.2; }
.emoji-pop button:hover { background: var(--surface-2); }

.overlay {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(10, 12, 30, .55);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.overlay.dark { background: rgba(4, 5, 14, .95); padding: 0; backdrop-filter: none; }

.dialog {
    width: 100%; max-width: 420px; max-height: 90dvh; overflow-y: auto;
    background: var(--surface); border-radius: 26px; box-shadow: var(--pop);
    padding: 22px 20px 16px;
}
.dialog.wide { max-width: 520px; }
.dialog h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.dialog p { margin: 0 0 14px; color: var(--ink-2); }
.dialog .check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14.5px; }
.dialog .check input[type=checkbox], .dialog .check input[type=radio] { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--mine); }
.dialog .check > span { flex: 1; min-width: 0; }
.dialog-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.dialog-actions button { border: 0; border-radius: 14px; padding: 13px; font-weight: 700; background: var(--surface-2); }
.dialog-actions .primary { background: var(--mine); color: #fff; }
.dialog-actions .danger { background: var(--signal); color: #fff; }
.dialog-actions .quiet { background: transparent; color: var(--ink-2); }

/* media preview before sending */
.preview { width: 100%; height: 100%; display: flex; flex-direction: column; color: #fff; }
.preview-top { display: flex; align-items: center; gap: 8px; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); }
.preview-top .icon-btn { color: #fff; }
.preview-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.preview-top span { flex: 1; font-weight: 600; }
.preview-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; }
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 100%; border-radius: 12px; }
.preview-thumbs { display: flex; gap: 8px; padding: 6px 12px; overflow-x: auto; justify-content: center; }
.preview-thumbs button { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; padding: 0; border: 2px solid transparent; background: #222; flex-shrink: 0; position: relative; }
.preview-thumbs button.on { border-color: #fff; }
.preview-thumbs img, .preview-thumbs video { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-thumbs .msym { position: absolute; left: 4px; bottom: 4px; font-size: 16px; color: #fff; text-shadow: 0 0 4px #000; }
.preview-bottom { display: flex; gap: 8px; align-items: flex-end; padding: 10px 10px max(12px, env(safe-area-inset-bottom)); }
.preview-bottom textarea {
    flex: 1; resize: none; border: 0; outline: none; border-radius: 22px;
    background: rgba(255,255,255,.12); color: #fff; padding: 12px 16px; font-size: 16px; max-height: 120px;
}
.preview-bottom textarea::placeholder { color: rgba(255,255,255,.6); }
.lightbox { width: 100%; height: 100%; display: flex; flex-direction: column; }
.lightbox .preview-stage img { border-radius: 0; }
.lightbox a.icon-btn { color: #fff; }

/* admin */
.admin-list { list-style: none; margin: 8px 0 0; padding: 0; }
.admin-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.admin-list li:first-child { border-top: 0; }
.admin-list .avatar { width: 38px; height: 38px; font-size: 15px; }
.admin-info { flex: 1; min-width: 0; }
.admin-info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-info small { color: var(--ink-2); font-size: 12.5px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 8px; margin-left: 6px; vertical-align: 1px; }
.pill.admin { background: color-mix(in srgb, var(--mine) 16%, transparent); color: var(--mine); }
.ghost-opts .check.radio { padding: 10px 12px; margin: 6px 0; border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.ghost-opts .check.radio:has(input:checked) { background: color-mix(in srgb, var(--mine) 14%, var(--surface)); }
.ghost-opts .check.radio input { accent-color: var(--mine); margin-top: 3px; }
.ghost-opts b { display: block; font-size: 15px; }
.ghost-opts small { display: block; color: var(--ink-2); font-size: 13px; }
.ghost-date { margin-top: 8px; width: 100%; padding: 9px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px; }
.pill.ghost { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink-2); }
#meSub.ghost-on { color: var(--mine); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
#meSub .msym { font-size: 15px; width: auto; }
.pill.blocked { background: color-mix(in srgb, var(--signal) 16%, transparent); color: var(--signal); }

.toast {
    position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    z-index: 120; background: var(--ink); color: var(--paper);
    padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
    box-shadow: var(--pop); max-width: calc(100vw - 32px);
}

/* ==========================================================================
   Call screen
   ========================================================================== */
.call-screen {
    position: fixed; inset: 0; z-index: 100;
    background: radial-gradient(900px 600px at 50% 0%, #26306e, #0b0d1e 70%);
    color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    overflow: hidden;
}
.call-remote {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    background: #000; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.call-screen.remote-cam .call-remote { opacity: 1; }
.call-center {
    position: relative; z-index: 1; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    margin-bottom: 120px;
    transition: transform .3s, opacity .3s;
}
.call-avatar { width: 112px; height: 112px; font-size: 44px; margin-bottom: 10px; box-shadow: 0 0 0 10px rgba(255,255,255,.06), 0 0 0 22px rgba(255,255,255,.03); }
.call-screen[data-mode="incoming"] .call-avatar { animation: ring-pulse 1.6s infinite; }
@keyframes ring-pulse { 50% { box-shadow: 0 0 0 16px rgba(255,255,255,.08), 0 0 0 34px rgba(255,255,255,.03); } }
@media (prefers-reduced-motion: reduce) { .call-screen[data-mode="incoming"] .call-avatar { animation: none; } }
.call-name { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.call-status { font-size: 15px; opacity: .8; font-variant-numeric: tabular-nums; }
.call-screen.remote-cam .call-center {
    position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; margin: 0;
    align-items: flex-start; text-align: left; gap: 0;
    text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.call-screen.remote-cam .call-avatar { display: none; }
.call-screen.remote-cam .call-name { font-size: 18px; }
.call-unmute {
    position: absolute; z-index: 3; top: 40%; left: 50%; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 8px;
    border: 0; border-radius: 999px; padding: 12px 18px;
    background: #fff; color: #11131f; font-weight: 700;
}
.call-audio { display: none; }
.call-local {
    position: absolute; z-index: 2;
    right: 14px; top: max(14px, env(safe-area-inset-top));
    width: 108px; height: 150px; object-fit: cover; border-radius: 18px;
    background: #000; box-shadow: 0 10px 30px rgba(0,0,0,.5);
    display: none;
}
.call-local.mirror { transform: scaleX(-1); }
.call-screen.local-cam .call-local { display: block; }
.call-controls {
    position: absolute; z-index: 2; left: 0; right: 0;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
    display: none; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 0 16px;
}
.call-screen[data-mode="incoming"] .call-incoming,
.call-screen[data-mode="active"] .call-active { display: flex; }
.cbtn {
    width: 64px; border: 0; background: none; color: #fff;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.cbtn .msym {
    width: 60px; height: 60px; border-radius: 50%;
    display: grid; place-items: center; font-size: 28px;
    background: rgba(255,255,255,.16);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    transition: background-color .15s, color .15s;
}
.cbtn small { font-size: 12px; opacity: .85; white-space: nowrap; }
.cbtn.red .msym { background: var(--signal); }
.cbtn.green .msym { background: var(--live); }
.cbtn.off .msym { background: #fff; color: #11131f; }
.cbtn.on .msym { background: #fff; color: #11131f; }
.call-incoming .cbtn { width: 84px; }
.call-incoming .cbtn .msym { width: 66px; height: 66px; }

.scroller::-webkit-scrollbar, .contacts::-webkit-scrollbar { width: 6px; }
.scroller::-webkit-scrollbar-thumb, .contacts::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
