/* chat-chat 3.0 — light, fast, readable.
   System fonts only, no images for UI, no blur/shadow-heavy effects: it has to stay smooth on weak devices. */
:root {
    --bg: #f6f6fa;
    --panel: #ffffff;
    --ink: #14131c;
    --muted: #6e6c80;
    --line: #e6e5ef;
    --hover: #f1f0f7;
    --accent: #5b4fe9;
    --accent-ink: #ffffff;
    --accent-soft: #ecebff;
    --mine: #5b4fe9;
    --mine-ink: #ffffff;
    --theirs: #ffffff;
    --chat-bg: #f1f0f7;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --radius: 14px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0c0c11;
        --panel: #15151d;
        --ink: #ecebf5;
        --muted: #9391a8;
        --line: #26263a;
        --hover: #1e1e29;
        --accent: #8b80ff;
        --accent-ink: #0e0b26;
        --accent-soft: #24204a;
        --mine: #5b4fe9;
        --mine-ink: #ffffff;
        --theirs: #1e1e29;
        --chat-bg: #0e0e14;
        --danger: #ff6b6b;
        --danger-soft: #3a1b1d;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.3rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 650; margin: 18px 0 8px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { display: block; flex: 0 0 auto; }
.fig { width: 20px; height: 20px; display: block; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; margin: 8px 2px; }
.lead { color: var(--muted); margin: 6px 0 14px; }

/* ---------- controls ---------- */
.btn, .pill-btn, .dialog-go button, .lang-switch button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 0 16px;
    border: 0; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink);
    font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover, .pill-btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-quiet, .lang-switch button, .dialog-go button { background: var(--hover); color: var(--ink); }
.btn:disabled { opacity: .5; }
.round {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 40px;
    border: 0; border-radius: 50%;
    background: var(--hover); color: var(--ink);
}
.round:hover { text-decoration: none; filter: brightness(.97); }
.round.accent, .round.ok { background: var(--accent); color: var(--accent-ink); }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.tag { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--hover); }
.badge-pro { background: var(--accent); color: var(--accent-ink); }

label { display: block; margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=password], input[type=search], input[type=email], select, textarea {
    display: block; width: 100%; margin-top: 4px;
    min-height: 44px; padding: 10px 14px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel); color: var(--ink);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=file] { display: block; margin-top: 6px; max-width: 100%; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1rem; padding: 10px 4px; border-bottom: 1px solid var(--line); margin: 0; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
form > .btn { margin-top: 4px; }

.banner { padding: 10px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); margin: 10px 0; }
.banner-ok { background: var(--accent-soft); color: var(--ink); }

/* ---------- guest pages ---------- */
body.guest { display: flex; flex-direction: column; align-items: center; padding: 16px; }
.guest-tools { width: 100%; max-width: 420px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8vh; }
.lang-switch { display: inline-flex; gap: 4px; margin: 0; }
.lang-switch button { min-height: 32px; padding: 0 12px; font-size: .85rem; }
.lang-switch button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
body.guest main { width: 100%; max-width: 420px; }
.auth-card, body.guest .card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
    padding: 28px 22px; text-align: center;
}
.auth-logo { width: 56px; height: 56px; border-radius: 16px; display: block; margin: 0 auto 12px; }
.auth-card h1 { margin-bottom: 16px; }
.auth-card form { display: grid; gap: 10px; }
.auth-card input { margin: 0; }
.login-actions, .start-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.login-actions .pill-btn, .start-row .pill-btn { flex: 1; min-height: 46px; }
.start-row .fig { display: none; }
.or { color: var(--muted); font-size: .85rem; }
.google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 46px; margin-top: 12px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--ink); font-weight: 600;
}
.google-btn:hover { text-decoration: none; background: var(--hover); }
.auth-switch { margin-top: 16px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.auth-switch .pill-btn { min-height: 34px; background: var(--hover); color: var(--ink); }
.row-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.foot { color: var(--muted); font-size: .8rem; text-align: center; padding: 24px 0; }

/* ---------- app shell ---------- */
body.app { height: 100vh; height: 100dvh; overflow: hidden; }
.shell { display: flex; height: 100vh; height: 100dvh; }
.rail {
    width: 340px; flex: 0 0 340px;
    display: flex; flex-direction: column;
    background: var(--panel); border-right: 1px solid var(--line);
    padding-top: env(safe-area-inset-top, 0);
}
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.stage > main { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
body.open-chat .stage > main { overflow: hidden; }

.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 6px; }
.rail-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 750; font-size: 1.15rem; }
.rail-brand:hover { text-decoration: none; }
.rail-brand img { width: 28px; height: 28px; border-radius: 8px; }
.rail-search { position: relative; margin: 6px 12px 8px; color: var(--muted); }
.rail-search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
.rail-search input { margin: 0; min-height: 40px; padding-left: 38px; border-radius: 999px; background: var(--hover); border-color: transparent; }
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 8px; -webkit-overflow-scrolling: touch; }
.rail-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 10px 4px; }
.rail-empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.rail-empty p { margin-bottom: 14px; }

.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-row {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; border-radius: 12px; color: var(--ink);
}
.chat-row:hover { background: var(--hover); text-decoration: none; }
.chat-row.is-active { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-top, .row-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-top time { color: var(--muted); font-size: .78rem; }
.row-preview { flex: 1; min-width: 0; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-unread .row-preview { color: var(--ink); }
.unread { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 10px; }

.face {
    width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%;
    object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.1rem;
}
.reqs { margin-bottom: 4px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.req { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--accent-soft); margin: 4px 0; }
.req.is-out { background: transparent; opacity: .8; }
.req .face { width: 40px; height: 40px; flex-basis: 40px; font-size: 1rem; }
.req-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.req-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-text small { color: var(--muted); }
.req form { display: flex; gap: 6px; }
.req .round { width: 36px; height: 36px; flex-basis: 36px; }

.rail-foot {
    display: flex; align-items: center; gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--line);
}
.foot-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; padding: 6px 4px; border-radius: 10px; color: var(--muted); font-size: .72rem; text-align: center; }
.foot-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.account-menu { position: relative; flex: 1; }
.account { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; color: var(--muted); font-size: .72rem; }
.account:hover { background: var(--hover); }
/* The message composer sits on the bottom edge: the general form spacing below must not lift it. */
.stage form.composer, .composer { margin: 0; }
/* Top-aligned row: the account button has the same padding and icon box as the buttons next to it. */
.rail-foot { align-items: flex-start; }
/* Same 20px box as the icons next to it, so the labels sit on one line. */
.account .face { width: 20px; height: 20px; flex-basis: 20px; font-size: .62rem; line-height: 1; }
.account .face.letter { color: var(--ink); background: var(--hover); }
.me-name { max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; line-height: 1.2; }
.account-panel, .chat-menu-panel, .settings-panel {
    position: absolute; z-index: 30;
    min-width: 240px; max-width: min(92vw, 360px); max-height: 75vh; overflow-y: auto;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    padding: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.account-panel { bottom: calc(100% + 8px); right: 0; display: flex; flex-direction: column; gap: 2px; }
.account-panel > a, .account-panel .dialog-go button {
    display: block; width: 100%; padding: 11px 12px; border-radius: 10px;
    color: var(--ink); background: none; text-align: left; font-weight: 500; min-height: 0;
}
.account-panel > a:hover, .account-panel .dialog-go button:hover { background: var(--hover); text-decoration: none; }
.account-panel .lang-switch { padding: 6px 8px; }
.menu-close { display: block; margin-left: auto; border: 0; background: none; color: var(--muted); font-size: .8rem; padding: 4px 8px; border-radius: 8px; }
.menu-close:hover { background: var(--hover); }

/* ---------- pages inside the shell ---------- */
.panel-back { display: none; }
.home-quiet { margin: auto; text-align: center; color: var(--muted); padding: 32px; }
.home-quiet h1 { color: var(--ink); margin-bottom: 6px; }
.page, .stage .card { width: 100%; max-width: 620px; margin: 0 auto; padding: 20px 18px; }
.stage .card + .card { padding-top: 0; }
.stage .card.narrow { max-width: 480px; }
.card h1 { margin-bottom: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list li form { display: flex; gap: 6px; flex-wrap: wrap; }

.search-box { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding: 4px 4px 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); }
.search-box:focus-within { border-color: var(--accent); }
.search-box input { border: 0; margin: 0; min-height: 40px; padding: 0 4px; background: none; }
.people { list-style: none; margin: 6px 0; padding: 0; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.person b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.person form { display: flex; gap: 6px; }
.person .face { width: 42px; height: 42px; flex-basis: 42px; }
.card.invite, .invite-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 18px 0; max-width: none; }
.invite .label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { margin: 0; font-size: .85rem; }
.invite-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.invite-card p { flex: 1; min-width: 160px; font-weight: 600; }

.profile-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.avatar-round { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.avatar-empty { width: 72px; height: 72px; border-radius: 50%; background: var(--hover); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: .75rem; text-align: center; }
.profile-name { font-weight: 700; font-size: 1.1rem; }
.stage form { margin: 0 0 14px; }

.pulse { display: flex; gap: 8px; justify-content: center; margin: 18px 0; }
.pulse span { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.pulse span:nth-child(2) { animation-delay: .2s; }
.pulse span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pulse span { animation: none; } }

/* ---------- chat screen ---------- */
.thread { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.plaque {
    display: flex; align-items: center; gap: 10px;
    min-height: 60px; padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0));
    background: var(--panel); border-bottom: 1px solid var(--line);
    position: relative; z-index: 5;
}
.plaque .face { width: 40px; height: 40px; flex-basis: 40px; font-size: 1rem; }
.back-list { display: none; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: var(--ink); }
.back-list:hover { background: var(--hover); text-decoration: none; }
.plaque-title { flex: 1; min-width: 0; }
.plaque-title h1 { font-size: 1.05rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence { color: var(--muted); font-size: .82rem; }
.presence.is-online { color: var(--accent); }
.plaque-actions { display: flex; align-items: center; gap: 4px; }
.threads-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--hover); color: var(--ink); font-size: .85rem; font-weight: 500; }
.threads-link:hover { text-decoration: none; filter: brightness(.97); }
.chat-menu, .chat-settings { position: relative; }
.chat-menu > summary { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; }
.chat-menu > summary:hover { background: var(--hover); }
.chat-menu .fig-close, .chat-menu[open] .fig-menu { display: none; }
.chat-menu[open] .fig-close { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fig { filter: invert(1); } }
:root[data-theme="dark"] .fig, :root[data-theme="oled"] .fig { filter: invert(1); }
.chat-menu-panel, .settings-panel { top: calc(100% + 6px); right: 0; padding: 12px; }
.chat-menu-panel form, .settings-panel form { margin: 0 0 10px; }
.menu-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.menu-title { flex: 1; font-weight: 700; }
.menu-label { color: var(--muted); font-size: .8rem; }
.settings-panel h2 { margin-top: 4px; }
.powers { padding: 8px; border-radius: 10px; background: var(--hover); }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.log { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.log-inner { display: flex; flex-direction: column; gap: 2px; max-width: 820px; margin: 0 auto; padding: 12px 12px 8px; min-height: 100%; justify-content: flex-end; }
.day { text-align: center; margin: 10px 0 6px; }
.day span { display: inline-block; padding: 3px 12px; border-radius: 999px; background: var(--panel); color: var(--muted); font-size: .78rem; font-weight: 600; }
.earlier { text-align: center; margin: 4px 0 10px; }
.earlier a { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--panel); font-size: .85rem; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 40px 16px; }
.history-note { text-align: center; padding: 6px; background: var(--panel); border-top: 1px solid var(--line); font-size: .9rem; }

.msg {
    position: relative; max-width: min(78%, 560px);
    padding: 7px 12px 5px; border-radius: 18px;
    background: var(--theirs); align-self: flex-start;
    margin-top: 4px; word-wrap: break-word; overflow-wrap: anywhere;
    -webkit-tap-highlight-color: transparent;
}
.msg.mine { background: var(--mine); color: var(--mine-ink); align-self: flex-end; }
.msg.mine .meta, .msg.mine .quote { color: rgba(255, 255, 255, .78); }
.msg.mine .quote { border-left-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .12); }
.msg.mine a, .msg.mine .file { color: #fff; }
.msg.mine .voice-play { background: #fff; color: var(--mine); }
.msg.mine .voice-fill { background: #fff; }
.msg.mine .react { background: rgba(255, 255, 255, .2); color: #fff; }
.msg.theirs { border-bottom-left-radius: 6px; }
.msg.mine { border-bottom-right-radius: 6px; }
.msg.is-picked { outline: 2px solid var(--accent); }
.msg.is-pending { opacity: .6; }
.who { color: var(--accent); font-size: .82rem; font-weight: 650; margin-bottom: 1px; }
.quote { border-left: 3px solid var(--accent); padding: 2px 8px; margin: 2px 0 4px; color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(127, 127, 127, .08); border-radius: 0 8px 8px 0; }
.txt { white-space: pre-wrap; }
.meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 1px; font-size: .72rem; color: var(--muted); flex-wrap: wrap; }
.react { padding: 0 6px; border-radius: 999px; background: rgba(127, 127, 127, .14); color: var(--ink); font-size: .8rem; }
.react.is-mine { background: var(--accent-soft); }
.pic { display: block; margin: 2px -6px 2px; }
.pic img { display: block; border-radius: 12px; max-height: 320px; width: auto; max-width: 100%; }
.file { display: flex; align-items: center; gap: 8px; padding: 6px 0; color: var(--ink); font-weight: 500; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 4px 0; }
.voice-play { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: .9rem; }
.voice-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(127, 127, 127, .3); overflow: hidden; }
.voice-fill { display: block; height: 100%; width: 0; background: var(--accent); }

.tools {
    display: flex; gap: 4px; overflow-x: auto;
    padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line);
}
.tools button { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; min-width: 60px; border: 0; background: none; padding: 6px 4px; border-radius: 10px; color: var(--ink); font-size: .72rem; }
.tools button:hover { background: var(--hover); }
.tools .danger { color: var(--danger); }
.tools button:last-child { flex: 0 0 48px; min-width: 48px; color: var(--muted); }

.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0)); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; max-width: 820px; margin: 0 auto; }
.composer textarea {
    flex: 1; margin: 0; min-height: 44px; max-height: 160px; resize: none;
    padding: 11px 14px; border-radius: 22px; background: var(--hover); border-color: transparent; line-height: 1.35;
}
.ic {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex: 0 0 44px; margin: 0;
    border: 0; border-radius: 50%; background: none; color: var(--muted);
}
.ic:hover { background: var(--hover); color: var(--ink); }
.ic.send { background: var(--accent); color: var(--accent-ink); }
.ic.send:hover { filter: brightness(1.05); background: var(--accent); color: var(--accent-ink); }
#mic.is-on { background: var(--danger); color: #fff; }
.clip { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.reply-chip, .file-chip { display: flex; align-items: center; gap: 8px; max-width: 820px; margin: 0 auto 6px; padding: 6px 6px 6px 12px; border-left: 3px solid var(--accent); background: var(--hover); border-radius: 0 10px 10px 0; color: var(--muted); font-size: .88rem; }
.reply-chip span, .file-chip span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-chip a, .file-chip button { display: flex; border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 6px; }
.composer-note { max-width: 820px; margin: 0 auto 6px; color: var(--danger); font-size: .88rem; }
.rec { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.rec-hint { font-weight: 400; font-size: .82rem; opacity: .8; }
.emoji-pop {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px;
    max-width: 820px; max-height: 210px; overflow-y: auto; margin: 0 auto 8px;
    padding: 6px; border-radius: 14px; background: var(--hover);
}
.emoji-pop button { border: 0; background: none; font-size: 1.45rem; padding: 4px 0; border-radius: 8px; }
.emoji-pop button:hover { background: var(--panel); }
.blocked-note { text-align: center; color: var(--muted); }
.join-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- chat context menu ---------- */
.menu-trigger { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ink); }
.menu-trigger:hover, .chat-menu[open] > .menu-trigger { background: var(--hover); }
.menu-pop {
    position: absolute; z-index: 30; top: calc(100% + 6px); right: 0;
    width: min(92vw, 320px); max-height: 75vh; overflow-y: auto;
    padding: 6px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
    box-shadow: 0 16px 40px rgba(20, 16, 60, .22);
}
.menu-pop .menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; margin: 0; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-pop .menu-head .face { width: 40px; height: 40px; flex-basis: 40px; font-size: 1rem; }
.menu-pop .menu-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop form { margin: 0; }
.menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 11px 10px; border: 0; border-radius: 10px; background: none; color: var(--ink);
    font-size: .95rem; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-sub[open] > .menu-item { background: var(--hover); }
.menu-item .i { color: var(--muted); }
.menu-item span { flex: 1; }
.menu-item small { color: var(--muted); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item.danger, .menu-item.danger .i { color: var(--danger); }
.menu-form { display: flex; flex-direction: column; gap: 8px; padding: 6px 10px 12px 42px; }
.menu-form input, .menu-form select { margin: 0; min-height: 40px; }
.menu-form .btn { align-self: flex-start; min-height: 36px; }
.menu-form .hint { margin: 0; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.btn.danger { background: var(--danger); color: #fff; }
.menu-people { list-style: none; margin: 0; padding: 2px 6px 8px 42px; }
.menu-people li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.menu-people .face { width: 30px; height: 30px; flex-basis: 30px; font-size: .8rem; }
.menu-people span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-people small { color: var(--danger); }
.chip { border: 0; border-radius: 999px; padding: 5px 10px; background: var(--hover); color: var(--ink); font-size: .8rem; cursor: pointer; }
.chip.danger { color: var(--danger); }
.settings-panel { width: min(92vw, 360px); }

/* ---------- calls ---------- */
.round.ghost { background: none; color: var(--ink); }
.round.ghost:hover { background: var(--hover); }
.ringtone { display: flex; align-items: center; gap: 8px; }
.ringtone label.check { flex: 1; }
body.in-call { overflow: hidden; }
.call-screen {
    position: fixed; inset: 0; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: calc(48px + env(safe-area-inset-top, 0)) 20px calc(36px + env(safe-area-inset-bottom, 0));
    background: radial-gradient(120% 80% at 50% 0%, #3b2f9a 0%, #13112b 60%, #07060f 100%);
    color: #fff;
}
.cs-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; pointer-events: none; }
.call-screen.has-remote-video .cs-remote { opacity: 1; }
.cs-local {
    position: absolute; right: 16px; top: calc(16px + env(safe-area-inset-top, 0));
    width: 28vw; max-width: 180px; aspect-ratio: 3 / 4; object-fit: cover;
    border-radius: 14px; background: #111; border: 2px solid rgba(255, 255, 255, .25);
    transform: scaleX(-1); display: none; z-index: 2;
}
.call-screen.is-video.has-local .cs-local { display: block; }
.cs-top { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.call-screen.has-remote-video .cs-top { text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.call-screen.has-remote-video .cs-face { display: none; }
.cs-face { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 8px rgba(255, 255, 255, .06), 0 0 0 18px rgba(255, 255, 255, .03); }
.cs-letter { display: flex; align-items: center; justify-content: center; background: #5b4fe9; font-size: 3rem; font-weight: 700; }
.cs-name { font-size: 1.6rem; font-weight: 700; margin: 6px 0 0; color: #fff; }
.cs-status { color: rgba(255, 255, 255, .75); font-size: 1rem; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.cs-actions { position: relative; z-index: 1; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.cs-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; color: #fff; font-size: .82rem; }
.cs-ic { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.cs-btn:hover .cs-ic { background: rgba(255, 255, 255, .26); }
.cs-btn.is-off .cs-ic { background: #fff; color: #111; }
.cs-btn.is-red .cs-ic { background: #e53935; }
.cs-btn.is-green .cs-ic { background: #22c55e; }
.cs-btn.is-red .cs-ic svg { transform: rotate(0deg); }
.cs-btn.is-green .cs-ic { animation: cs-pulse 1.6s infinite; }
@keyframes cs-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); } 100% { box-shadow: 0 0 0 18px rgba(34, 197, 94, 0); } }
@media (prefers-reduced-motion: reduce) { .cs-btn.is-green .cs-ic { animation: none; } }

/* ---------- phones ---------- */
@media (max-width: 767px) {
    .rail { width: 100%; flex-basis: 100%; border-right: 0; }
    body.chat-screen .rail { display: none; }
    body.list-screen .stage { display: none; }
    .back-list { display: inline-flex; }
    .panel-back { display: block; padding: 10px 12px 0; padding-top: calc(10px + env(safe-area-inset-top, 0)); }
    .panel-back .back-list { display: inline-flex; width: auto; padding: 6px 12px; border-radius: 999px; background: var(--hover); }
    .msg { max-width: 86%; }
    .plaque .face { display: none; }
    .threads-link { padding: 0 10px; }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .rail { width: 300px; flex-basis: 300px; }
}

/* =====================================================================
   chat-chat 4 — themes, accents, wallpapers, Liquid Glass, new UI parts
   ===================================================================== */
:root { --glass: rgba(255, 255, 255, .6); --glass-line: rgba(255, 255, 255, .55); --shadow: 0 16px 40px rgba(20, 16, 60, .18); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --glass: rgba(24, 23, 34, .55); --glass-line: rgba(255, 255, 255, .09); --shadow: 0 16px 40px rgba(0, 0, 0, .5); }
}
:root[data-theme="dark"], :root[data-theme="oled"] {
    --bg: #0c0c11; --panel: #15151d; --ink: #ecebf5; --muted: #9391a8; --line: #26263a; --hover: #1e1e29;
    --accent: #8b80ff; --accent-ink: #0e0b26; --accent-soft: #24204a; --mine: #5b4fe9; --mine-ink: #fff;
    --theirs: #1e1e29; --chat-bg: #0e0e14; --danger: #ff6b6b; --danger-soft: #3a1b1d;
    --glass: rgba(24, 23, 34, .55); --glass-line: rgba(255, 255, 255, .09); --shadow: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}
:root[data-theme="oled"] { --bg: #000; --panel: #0a0a0d; --hover: #15151b; --theirs: #16161c; --chat-bg: #000; --line: #1c1c24; --glass: rgba(10, 10, 14, .6); }
:root[data-theme="light"] { color-scheme: light; }

/* accents: the bubble, buttons and links follow the chosen colour */
:root[data-accent="ocean"] { --accent: #0a7cff; --mine: #0a7cff; }
:root[data-accent="mint"] { --accent: #0e9f77; --mine: #0e9f77; }
:root[data-accent="sunset"] { --accent: #ef5d16; --mine: #ef5d16; }
:root[data-accent="rose"] { --accent: #e0336f; --mine: #e0336f; }
:root[data-accent="gold"] { --accent: #b9840a; --mine: #c28f12; }
:root[data-accent="mono"] { --accent: #2f343b; --mine: #2f343b; }
:root[data-accent]:not([data-accent="indigo"]) { --accent-ink: #fff; --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
:root[data-theme="dark"][data-accent="mono"], :root[data-theme="oled"][data-accent="mono"] { --accent: #c9ced6; --mine: #3a3f48; --accent-ink: #111; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"][data-accent="mono"] { --accent: #c9ced6; --mine: #3a3f48; --accent-ink: #111; } }

/* chat wallpapers (pure CSS: no image requests) */
[data-wall="dots"] .thread { background-image: radial-gradient(color-mix(in srgb, var(--accent) 22%, transparent) 1.2px, transparent 1.6px); background-size: 22px 22px; }
[data-wall="waves"] .thread { background-image: repeating-radial-gradient(circle at 0 100%, transparent 0 18px, color-mix(in srgb, var(--accent) 9%, transparent) 18px 20px); }
[data-wall="aurora"] .thread {
    background-image:
        radial-gradient(60% 50% at 10% 10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
        radial-gradient(50% 60% at 90% 30%, rgba(0, 200, 180, .16), transparent 70%),
        radial-gradient(60% 50% at 50% 100%, rgba(255, 90, 160, .14), transparent 70%);
}

/* ---------- Liquid Glass ---------- */
[data-glass="1"] body { background: var(--bg); }
[data-glass="1"] body::before {
    content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
    background:
        radial-gradient(35% 35% at 20% 25%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 70%),
        radial-gradient(30% 30% at 80% 20%, rgba(0, 200, 255, .35), transparent 70%),
        radial-gradient(35% 35% at 70% 80%, rgba(255, 80, 170, .3), transparent 70%),
        radial-gradient(30% 30% at 25% 85%, rgba(80, 255, 190, .22), transparent 70%);
    animation: glass-drift 28s ease-in-out infinite alternate;
    will-change: transform;
}
@keyframes glass-drift {
    0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    50% { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.06); }
    100% { transform: translate3d(-4%, 3%, 0) rotate(-6deg) scale(1); }
}
[data-glass="1"] .shell, [data-glass="1"] .stage, [data-glass="1"] .thread, [data-glass="1"] .log { background-color: transparent; }
[data-glass="1"] .rail, [data-glass="1"] .plaque, [data-glass="1"] .composer, [data-glass="1"] .menu-pop,
[data-glass="1"] .account-panel, [data-glass="1"] .settings-panel, [data-glass="1"] .ctx, [data-glass="1"] .ai-panel,
[data-glass="1"] .chat-search, [data-glass="1"] .selbar, [data-glass="1"] .pinbar, [data-glass="1"] .space-side,
[data-glass="1"] .stage .card, [data-glass="1"] .toast {
    background: var(--glass);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    border-color: var(--glass-line);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -1px 0 rgba(255, 255, 255, .06);
}
[data-glass="1"] .menu-pop, [data-glass="1"] .ctx, [data-glass="1"] .ai-panel, [data-glass="1"] .account-panel {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), var(--shadow);
}
[data-glass="1"] .stage .card { border-radius: 22px; margin-top: 14px; border: 1px solid var(--glass-line); }
[data-glass="1"] .msg.theirs { background: color-mix(in srgb, var(--theirs) 72%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
[data-glass="1"] .msg.mine {
    background: linear-gradient(160deg, color-mix(in srgb, var(--mine) 82%, #fff) 0%, var(--mine) 45%, color-mix(in srgb, var(--mine) 80%, #000) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 4px 14px color-mix(in srgb, var(--mine) 30%, transparent);
}
[data-glass="1"] .day span, [data-glass="1"] .earlier a { background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
[data-glass="1"] .composer textarea, [data-glass="1"] .rail-search input { background: color-mix(in srgb, var(--panel) 45%, transparent); }
[data-glass="1"] .btn, [data-glass="1"] .ic.send { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
[data-glass="1"] .chat-row.is-active { background: color-mix(in srgb, var(--accent) 18%, transparent); }
@media (prefers-reduced-motion: reduce) { [data-glass="1"] body::before { animation: none; } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    [data-glass="1"] .rail, [data-glass="1"] .plaque, [data-glass="1"] .composer, [data-glass="1"] .menu-pop, [data-glass="1"] .ctx { background: var(--panel); }
}

/* ---------- rail: servers dock and tabs ---------- */
.dock { display: flex; gap: 8px; overflow-x: auto; padding: 4px 6px 10px; scrollbar-width: none; }
.dock::-webkit-scrollbar { display: none; }
.dock-item {
    position: relative; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    background: var(--hover); color: var(--ink); font-weight: 700; transition: border-radius .2s, background .2s;
}
.dock-item:hover, .dock-item.is-active { border-radius: 12px; background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.dock-item.is-saved { color: var(--accent); }
.dock-item.is-add { color: var(--accent); background: none; border: 2px dashed var(--line); }
.dock-item.is-unread::after { content: ""; position: absolute; right: -2px; top: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); border: 2px solid var(--panel); }
.rail-tabs { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.rail-tabs button { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--hover); color: var(--muted); font-size: .82rem; font-weight: 600; }
.rail-tabs button.is-on { background: var(--accent); color: var(--accent-ink); }
.row-name .i { display: inline-block; vertical-align: -2px; margin-right: 4px; color: var(--muted); }

/* ---------- messages ---------- */
.msg { transition: background .15s, transform .15s; }
.msg.is-menu { transform: scale(1.015); box-shadow: 0 0 0 2px var(--accent); }
.msg.is-going { opacity: .35; }
.msg.is-flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.msg.is-ai { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--theirs)), var(--theirs)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.msg.is-ai .who { background: linear-gradient(90deg, var(--accent), #e0336f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.msg.is-mention { box-shadow: inset 3px 0 0 var(--accent); }
.msg.is-post { max-width: min(100%, 640px); align-self: center; width: 100%; border-radius: 16px; background: var(--theirs); color: var(--ink); }
.msg.is-post.mine .meta, .msg.is-post.mine .quote { color: var(--muted); }
.msg.is-post.mine a { color: var(--accent); }
.chat.is-selecting .msg { cursor: pointer; }
.chat.is-selecting .msg::before {
    content: ""; position: absolute; left: -30px; top: 50%; width: 20px; height: 20px; margin-top: -10px;
    border-radius: 50%; border: 2px solid var(--muted); background: var(--panel);
}
.chat.is-selecting .log-inner { padding-left: 42px; }
.chat.is-selecting .msg.is-sel::before { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--panel); }
.chat.is-selecting .msg.is-sel { filter: brightness(.94); }
.meta { gap: 4px; }
.meta .react { border: 0; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; font-size: .85rem; cursor: pointer; }
.meta .react b { font-size: .72rem; font-weight: 700; }
.msg.mine .react.is-mine { background: rgba(255, 255, 255, .35); }
.stamp { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
.stamp em { font-style: normal; opacity: .8; }
.ticks { display: inline-flex; }
.ticks.is-read { color: #7ee3ff; }
.msg.theirs .ticks.is-read { color: var(--accent); }
.txt b { font-weight: 700; }
.txt code, .ai-msg code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .88em; padding: 1px 5px; border-radius: 6px; background: rgba(127, 127, 127, .18); }
.spoiler { background: currentColor; border-radius: 4px; cursor: pointer; transition: background .2s; }
.spoiler.is-open, .spoiler:focus { background: rgba(127, 127, 127, .2); }
.mention { color: var(--accent); font-weight: 600; }
.msg.mine .mention { color: #fff; text-decoration: underline; }
.mention.is-ai { background: linear-gradient(90deg, var(--accent), #e0336f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.quote[data-goto] { cursor: pointer; }
.translation { margin: 4px 0 2px; padding: 6px 8px; border-radius: 10px; background: rgba(127, 127, 127, .12); font-size: .92rem; white-space: pre-wrap; }
.translation::before { content: "✦ "; color: var(--accent); }
.clip-video { display: block; max-width: 100%; max-height: 340px; border-radius: 12px; margin: 2px -6px; }
.file { gap: 10px; }
.file-ic { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.file > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.file small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.msg.mine .file-ic { background: rgba(255, 255, 255, .2); color: #fff; }
.msg.mine .file small { color: rgba(255, 255, 255, .75); }
.voice-play { display: flex; align-items: center; justify-content: center; }
.voice-track { height: 6px; cursor: pointer; }
.voice-time { font-size: .75rem; font-variant-numeric: tabular-nums; opacity: .75; min-width: 30px; }
.empty small { display: block; margin-top: 8px; font-size: .82rem; opacity: .8; }

/* polls */
.poll { min-width: 230px; padding: 2px 0; }
.poll-q { font-weight: 700; margin-bottom: 8px; }
.poll-opt {
    position: relative; display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 6px; padding: 8px 10px;
    border: 1px solid rgba(127, 127, 127, .3); border-radius: 10px; background: none; color: inherit; text-align: left; overflow: hidden;
}
.poll-opt.is-mine { border-color: currentColor; }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(127, 127, 127, .18); transition: width .4s; pointer-events: none; }
.msg.mine .poll-bar { background: rgba(255, 255, 255, .22); }
.poll-label { position: relative; flex: 1; }
.poll-pct { position: relative; font-weight: 700; font-size: .85rem; }
.poll-meta { font-size: .78rem; opacity: .75; }
.w0 { width: 0; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; } .w25 { width: 25%; } .w30 { width: 30%; }
.w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; } .w65 { width: 65%; }
.w70 { width: 70%; } .w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }
.poll:not(.is-voted) .poll-bar { width: 0; }

/* ---------- message context menu ---------- */
.ctx {
    position: fixed; z-index: 60; width: 236px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.ctx.is-in { animation: pop .14s ease-out; transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.ctx-reacts { display: flex; align-items: center; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx-reacts button, .ctx-all button { flex: 1; border: 0; background: none; font-size: 1.35rem; padding: 4px 0; border-radius: 10px; line-height: 1.2; transition: transform .12s; }
.ctx-reacts button:hover, .ctx-all button:hover { background: var(--hover); transform: scale(1.18); }
.ctx-reacts .ctx-more { flex: 0 0 30px; font-size: 1rem; color: var(--muted); display: flex; justify-content: center; }
.ctx-all { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx .menu-item { padding: 9px 10px; font-size: .92rem; }

/* ---------- selection bar, pin bar, search, AI ---------- */
.selbar, .pinbar {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.selbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; border-top: 1px solid var(--line); border-bottom: 0; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0)); }
.selbar-gap { flex: 1; }
.selbar .danger { color: var(--danger); }
.pinbar { width: 100%; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); cursor: pointer; }
.pinbar > .i { color: var(--accent); }
.pin-main { display: flex; flex-direction: column; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; }
.pin-main b { color: var(--accent); font-size: .8rem; }
.pin-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.chat-search, .ai-panel {
    position: absolute; z-index: 20; top: 8px; right: 8px; width: min(420px, calc(100% - 16px));
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 8px;
}
.chat-search { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-search .search-box { flex: 1; margin: 0; }
.search-results { width: 100%; max-height: 50vh; overflow-y: auto; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 10px; color: var(--ink); }
.search-results button:hover { background: var(--hover); }
.search-results small { display: block; color: var(--muted); font-size: .75rem; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 6px; }
.ai-head b { flex: 1; }
.ai-mark { display: flex; width: 30px; height: 30px; border-radius: 10px; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--accent), #e0336f); }
.ai-btn .i { color: var(--accent); }
.ai-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-out { max-height: 46vh; overflow-y: auto; padding: 4px 4px 8px; }
.ai-msg { white-space: pre-wrap; line-height: 1.5; }
.ai-msg.is-err { color: var(--danger); }
.ai-msg.is-wait { color: var(--muted); }
.ai-q { font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.ai-ask { display: flex; gap: 6px; margin: 0 !important; }
.ai-ask input { margin: 0; border-radius: 999px; min-height: 42px; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
.typing { padding: 2px 16px 4px; font-size: .8rem; color: var(--accent); max-width: 820px; margin: 0 auto; width: 100%; }
.typing::before { content: "✎ "; }
.presence.is-typing { color: var(--accent); }
.to-bottom {
    position: absolute; right: 14px; bottom: 84px; z-index: 6; width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
.chat.is-drop::after {
    content: "⬇"; position: absolute; inset: 8px; z-index: 30; display: flex; align-items: center; justify-content: center;
    font-size: 3rem; border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--accent) 12%, transparent); pointer-events: none;
}
.toast {
    position: fixed; left: 50%; bottom: 96px; z-index: 200; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 9px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 600; transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- composer ---------- */
.composer-row { align-items: flex-end; }
.field { position: relative; flex: 1; display: flex; min-width: 0; }
.field textarea { padding-right: 46px !important; }
.field .emoji-in { position: absolute; right: 0; bottom: 0; }
.js .composer:not(.has-text) .send { display: none; }
.js .composer.has-text #mic { display: none; }
.composer.is-recording .field, .composer.is-recording #more-btn { display: none; }
.composer.is-thinking textarea { opacity: .5; }
.rec.is-cancel { background: var(--hover); color: var(--muted); }
.rec-dot { animation: pulse 1s infinite; }
#mic { touch-action: none; }
.attach-pop {
    max-width: 820px; margin: 0 auto 8px; padding: 6px; border-radius: 16px; background: var(--hover);
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px;
}
.attach-pop label.menu-item { cursor: pointer; }
.poll-form { max-width: 820px; margin: 0 auto 8px; padding: 10px; border-radius: 16px; background: var(--hover); display: flex; flex-direction: column; gap: 8px; }
.poll-form input, .poll-form textarea { margin: 0; }
.poll-form .row-actions { justify-content: flex-end; margin: 0; }
.smart { display: flex; gap: 6px; overflow-x: auto; max-width: 820px; margin: 0 auto 6px; }
.smart .chip { flex: 0 0 auto; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.edit-chip button { display: flex; border: 0; background: none; color: var(--muted); padding: 4px; }

/* ---------- servers ---------- */
.face.square { border-radius: 14px; }
.hash { display: inline-flex; vertical-align: -2px; margin-right: 4px; color: var(--muted); }
.space-body { flex: 1; min-height: 0; display: flex; }
.space-side { width: 230px; flex: 0 0 230px; overflow-y: auto; padding: 8px; background: var(--panel); border-right: 1px solid var(--line); }
.ch-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 1px 0; border-radius: 10px; color: var(--muted); font-weight: 500; }
.ch-row:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.ch-row.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 650; }
.ch-row.is-unread { color: var(--ink); font-weight: 700; }
.ch-row.is-unread::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ch-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-about { color: var(--muted); font-size: .82rem; padding: 12px 10px; }
.space-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.role { font-style: normal; font-size: .72rem; color: var(--accent); }

/* ---------- forms: segmented choice, accents, switch ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg label { position: relative; margin: 0; }
.seg input, .accents input { position: absolute; opacity: 0; pointer-events: none; }
.seg label > span {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; height: 100%;
    border: 2px solid var(--line); border-radius: 14px; text-align: center; cursor: pointer; font-weight: 400;
}
.seg label > span small { color: var(--muted); font-size: .75rem; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.seg input:focus-visible + span, .accents input:focus-visible + .dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch-theme, .swatch-wall { min-height: 74px; justify-content: flex-end; }
.swatch-theme.t-auto { background: linear-gradient(135deg, #fff 50%, #15151d 50%) !important; }
.swatch-theme.t-auto b { background: var(--panel); padding: 0 6px; border-radius: 6px; }
.swatch-theme.t-light { background: #f6f6fa; color: #14131c; }
.swatch-theme.t-dark { background: #15151d; color: #ecebf5; }
.swatch-theme.t-oled { background: #000; color: #ecebf5; }
.swatch-wall.w-dots { background-image: radial-gradient(color-mix(in srgb, var(--accent) 40%, transparent) 1.2px, transparent 1.6px); background-size: 12px 12px; }
.swatch-wall.w-waves { background-image: repeating-radial-gradient(circle at 0 100%, transparent 0 8px, color-mix(in srgb, var(--accent) 20%, transparent) 8px 10px); }
.swatch-wall.w-aurora { background-image: radial-gradient(60% 60% at 20% 20%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 70%), radial-gradient(60% 60% at 80% 80%, rgba(255, 90, 160, .35), transparent 70%); }
.look-label { font-weight: 650; margin: 4px 0 8px; }
.accents { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.accents label { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; cursor: pointer; font-weight: 400; }
.accents small { font-size: .72rem; color: var(--muted); }
.dot { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--panel); box-shadow: 0 0 0 2px var(--line); }
.accents input:checked + .dot { box-shadow: 0 0 0 2px var(--ink); }
.a-indigo { background: #5b4fe9; } .a-ocean { background: #0a7cff; } .a-mint { background: #0e9f77; } .a-sunset { background: #ef5d16; }
.a-rose { background: #e0336f; } .a-gold { background: #c28f12; } .a-mono { background: #2f343b; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--hover); margin: 0 0 14px; cursor: pointer; }
.switch-row > span { flex: 1; display: flex; flex-direction: column; font-weight: 400; }
.switch-row small { color: var(--muted); font-size: .8rem; }
.switch { appearance: none; -webkit-appearance: none; width: 50px !important; height: 30px; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; flex: 0 0 50px; border: 0 !important; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* saved messages, bump */
.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list a { display: flex; flex-direction: column; gap: 2px; padding: 12px; margin-bottom: 8px; border-radius: 14px; background: var(--hover); color: var(--ink); }
.saved-list a:hover { text-decoration: none; filter: brightness(.97); }
.saved-from { color: var(--accent); font-size: .8rem; font-weight: 600; }
.saved-text { white-space: pre-wrap; }
.bump-page { text-align: center; }
.bump-orb {
    width: 150px; height: 150px; margin: 20px auto; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent));
    box-shadow: 0 0 0 14px var(--accent-soft), 0 0 0 28px color-mix(in srgb, var(--accent-soft) 50%, transparent);
}
.bump-orb.is-hit { animation: shake .5s infinite; }
.bump-orb.is-done { background: #22c55e; animation: none; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

@media (max-width: 767px) {
    .space-body { flex-direction: column; }
    .space-side { width: auto; flex: 0 0 auto; display: flex; gap: 4px; overflow-x: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
    .space-side .rail-label, .space-about { display: none; }
    .ch-row { flex: 0 0 auto; padding: 6px 10px; }
    .seg-4 { grid-template-columns: 1fr 1fr; }
    .chat-search, .ai-panel { top: 4px; right: 4px; width: calc(100% - 8px); }
    .plaque .round.ghost { width: 36px; height: 36px; flex-basis: 36px; }
    .ctx { width: min(260px, calc(100vw - 16px)); }
}

/* ---------- lite mode: weak computers and tablets ----------
   No blur, no moving layers, no transitions; long lists skip rendering off-screen rows. */
.msg, .chat-list > li { content-visibility: auto; contain-intrinsic-size: auto 64px; }
[data-lite="1"] *, [data-lite="1"] *::before, [data-lite="1"] *::after { animation: none !important; transition: none !important; }
[data-lite="1"] body::before { animation: none !important; inset: 0 !important; will-change: auto !important; }
[data-lite="1"] .rail, [data-lite="1"] .plaque, [data-lite="1"] .composer, [data-lite="1"] .menu-pop, [data-lite="1"] .account-panel,
[data-lite="1"] .settings-panel, [data-lite="1"] .ctx, [data-lite="1"] .ai-panel, [data-lite="1"] .chat-search, [data-lite="1"] .selbar,
[data-lite="1"] .pinbar, [data-lite="1"] .space-side, [data-lite="1"] .stage .card, [data-lite="1"] .toast,
[data-lite="1"] .day span, [data-lite="1"] .earlier a {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
[data-lite="1"][data-glass="1"] .rail, [data-lite="1"][data-glass="1"] .plaque, [data-lite="1"][data-glass="1"] .composer,
[data-lite="1"][data-glass="1"] .menu-pop, [data-lite="1"][data-glass="1"] .ctx, [data-lite="1"][data-glass="1"] .ai-panel,
[data-lite="1"][data-glass="1"] .chat-search, [data-lite="1"][data-glass="1"] .selbar, [data-lite="1"][data-glass="1"] .pinbar,
[data-lite="1"][data-glass="1"] .space-side, [data-lite="1"][data-glass="1"] .account-panel, [data-lite="1"][data-glass="1"] .stage .card {
    background: color-mix(in srgb, var(--panel) 92%, transparent);
}
[data-lite="1"] .msg, [data-lite="1"] .btn, [data-lite="1"] .ic.send, [data-lite="1"] .menu-pop, [data-lite="1"] .ctx,
[data-lite="1"] .ai-panel, [data-lite="1"] .chat-search, [data-lite="1"] .to-bottom { box-shadow: none !important; }
[data-lite="1"] .msg.is-menu { transform: none; outline: 2px solid var(--accent); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 767px) { .seg-3 { grid-template-columns: 1fr; } }

/* Composer field: always a visible pill (it vanished on dark glass + wallpapers). */
.composer textarea { border: 1px solid var(--line); }
[data-glass="1"] .composer textarea { background: color-mix(in srgb, var(--hover) 80%, transparent); border-color: var(--glass-line); }
[data-glass="1"] .composer textarea:focus, .composer textarea:focus { border-color: var(--accent); outline: none; }
.composer { min-height: 65px; }
@media (min-width: 1280px) {
    .log-inner, .composer-row, .reply-chip, .file-chip, .attach-pop, .poll-form, .smart, .emoji-pop, .typing, .composer-note { max-width: 960px; }
}
