/* Jaw client theme: cool, techy black with orange. Shared by every host (browser, native shells). */

:root {
    --bg-rail: #0b0e12;
    --bg-side: #10141a;
    --bg-main: #151a21;
    --bg-raised: #1b2129;
    --bg-input: #0f1318;
    --bg-hover: #222a34;
    --line: #232b35;
    --line-strong: #2e3844;
    --text: #e4e8ee;
    --text-soft: #b3bcc8;
    --muted: #7d8899;
    --accent: #ff7a1a;
    --accent-hover: #ff9142;
    --accent-ink: #14181d;
    --accent-dim: rgba(255, 122, 26, 0.14);
    --accent-glow: 0 0 0 1px rgba(255, 122, 26, 0.45), 0 0 18px rgba(255, 122, 26, 0.25);
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --radius: 10px;
    --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", ui-monospace, Consolas, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg-rail);
    color: var(--text);
    font: 15px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

h1, h2, h3 { margin: 0 0 0.5em; font-weight: 650; letter-spacing: 0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
p { margin: 0 0 0.8em; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 0.88em; color: var(--accent-hover); }

::selection { background: var(--accent-dim); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Controls ---------- */

label { display: block; margin: 0 0 0.9rem; font-size: 0.8rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }
label > input, label > textarea { margin-top: 0.4rem; }

input, textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    text-transform: none;
    letter-spacing: normal;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--accent-glow); }
input::placeholder, textarea::placeholder { color: #566171; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}

button:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 0 16px rgba(255, 122, 26, 0.3); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.secondary { background: var(--bg-hover); color: var(--text); }
button.secondary:hover:not(:disabled) { background: var(--line-strong); box-shadow: none; }
button.ghost { background: transparent; color: var(--text-soft); padding: 0.4rem 0.6rem; }
button.ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); box-shadow: none; }
button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.4); }
button.danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.12); box-shadow: none; }
button.wide { width: 100%; }

.error { color: var(--danger); }
.notice { padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--accent-dim); color: var(--text); border: 1px solid rgba(255, 122, 26, 0.3); }
.error.notice { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.35); }
.update-prompt { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 0.5rem 0.75rem 0; }
.update-prompt .update-actions { display: flex; gap: 0.5rem; }
/* Direct calls (#102): the strip above the chat and the phone button in the top bar. */
.call-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 0.5rem 0.75rem 0; }
.call-bar .call-actions { display: flex; gap: 0.5rem; }
.call-bar.ringing { animation: call-pulse 1.2s ease-in-out infinite; }
@keyframes call-pulse { 0%, 100% { border-color: rgba(255, 122, 26, 0.3); } 50% { border-color: rgba(255, 122, 26, 0.9); } }
.topbar .call-button { margin-left: auto; display: inline-flex; align-items: center; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.row > input { flex: 1; }
.spacer { flex: 1; }

/* ---------- Avatars ---------- */

.avatar {
    --avatar-hue: 20;
    display: inline-grid;
    place-items: center;
    flex: none;
    border-radius: 50%;
    background: hsl(var(--avatar-hue) 45% 32%);
    color: hsl(var(--avatar-hue) 80% 88%);
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
}

/* Pictures and presence (#71). The wrapper keeps the avatar's size; the dot sits on its corner. */
.avatar-wrap { position: relative; display: inline-block; flex: none; vertical-align: middle; }
.avatar-wrap > .avatar { width: 100%; height: 100%; line-height: 1; }
img.avatar.picture { display: block; object-fit: cover; background: var(--bg-raised); }
.presence-dot {
    position: absolute; right: -1px; bottom: -1px; width: var(--dot); height: var(--dot);
    border-radius: 50%; border: 2px solid var(--bg-side); background: var(--muted); box-sizing: content-box;
}
.presence-dot.online { background: var(--ok); }
.presence-dot.away { background: var(--warn); }
.presence-dot.busy { background: var(--danger); }
.presence-dot.offline { background: var(--bg-side); box-shadow: inset 0 0 0 2px var(--muted); }
.status-line { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.presence-picker button { display: inline-flex; align-items: center; gap: 0.4rem; }
.presence-picker button.chosen { border-color: var(--accent); background: var(--accent-dim); }
.presence-picker .presence-dot { position: static; border-color: transparent; }
.profile-picture-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.node-picture { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; background: var(--bg-raised); }

/* ---------- Onboarding (centred card on a grid background) ---------- */

.onboarding {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1000px 500px at 50% -10%, rgba(255, 122, 26, 0.12), transparent 60%),
        linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 32px 32px,
        var(--bg-rail);
    background-blend-mode: normal, overlay, overlay, normal;
}

.card {
    width: min(460px, 100%);
    padding: 2rem;
    background: rgba(21, 26, 33, 0.92);
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

.card.wide { width: min(640px, 100%); }
.brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.4rem; }
.brand .jaw-logo { color: var(--accent); filter: drop-shadow(0 0 10px rgba(255, 122, 26, 0.45)); }
.brand-name { font-size: 1.5rem; font-weight: 750; letter-spacing: 0.04em; }
.brand-tag { color: var(--muted); font-size: 0.85rem; }

.tabs { display: flex; gap: 0.25rem; padding: 0.25rem; margin-bottom: 1.2rem; background: var(--bg-input); border-radius: 9px; border: 1px solid var(--line); }
.tabs button { flex: 1; background: transparent; color: var(--muted); padding: 0.45rem; }
.tabs button.active { background: var(--bg-hover); color: var(--text); }
.tabs button:hover:not(:disabled) { box-shadow: none; background: var(--bg-hover); }

.recovery-phrase {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.4rem;
    margin: 1rem 0 1.4rem;
    padding: 0;
    list-style: none;
    counter-reset: word;
}

.recovery-phrase li {
    counter-increment: word;
    padding: 0.4rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.9rem;
}

.recovery-phrase li::before { content: counter(word) "."; color: var(--muted); margin-right: 0.4rem; font-size: 0.75rem; }

.node-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.node-list li {
    display: flex; align-items: center; gap: 0.8rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.node-list li:hover { border-color: var(--line-strong); }
.node-meta { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; font-size: 0.85rem; color: var(--text-soft); }
/* Row buttons stay together and drop below the text when the row is narrow (phones). */
.node-list li { flex-wrap: wrap; }
.list-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.node-meta code { display: block; font-size: 0.95rem; }
/* #172: a node's description, how it's reached and its addresses in the node picker. */
.node-meta .desc { display: block; color: var(--text); margin-top: 0.2rem; }
.node-reach { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem; margin-top: 0.3rem; }
.reach-tag { font-size: 0.75rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--bg-raised); color: var(--text-soft); }
.reach-tag.tor { background: rgba(125, 78, 191, 0.25); color: #d6c2ff; }
.node-meta code.node-address { display: inline-block; font-size: 0.78rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

details { margin-top: 1rem; }
summary { cursor: pointer; color: var(--text-soft); font-weight: 600; margin-bottom: 0.8rem; }
summary:hover { color: var(--text); }

.spinner {
    width: 18px; height: 18px; flex: none;
    border: 2px solid var(--accent-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell: rail | chat list | main ---------- */

.shell { display: grid; grid-template-columns: 72px 260px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; overflow: hidden; }
/* Columns may shrink to the window; each scrolls inside itself (otherwise long pages grow the row and get clipped). */
.shell > .rail, .shell > .side, .shell > .main { min-height: 0; }

.rail {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    padding: 0.75rem 0;
    background: var(--bg-rail);
    overflow: hidden; /* #175: only the middle scrolls */
    min-height: 0;
}

/* #175: the Jaw icon (top) and the create, browse, apps and settings buttons (bottom) stay put; people and rooms scroll
   between them, and nothing in the rail ever shrinks to make room. */
.rail > *, .rail-scroll > *, .rail-bottom > * { flex: none; }
.rail-scroll, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; width: 100%; }
.rail-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; padding: 0.15rem 0; }
.rail-scroll::-webkit-scrollbar { display: none; }
.rail-bottom { margin-top: auto; }

.rail-item {
    position: relative;
    display: grid; place-items: center;
    width: 48px; height: 48px; padding: 0;
    border-radius: 50%;
    background: var(--bg-raised);
    color: var(--text-soft);
    transition: border-radius 0.18s, background 0.18s, color 0.18s;
}

.rail-item:hover:not(:disabled), .rail-item.active { border-radius: 16px; background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.rail-item .avatar-wrap, .rail-item .avatar { width: 48px !important; height: 48px !important; transition: border-radius 0.18s; }
.rail-node-picture { display: block; width: 48px; height: 48px; border-radius: inherit; object-fit: cover; transition: border-radius 0.18s; }
.rail-item.person { background: transparent; }
.rail-item.person:hover .avatar, .rail-item.person.active .avatar { border-radius: 16px; }
.rail-item.person:hover:not(:disabled), .rail-item.person.active { background: transparent; }

/* The pill on the left edge, like the selected/unread marker in Discord. */
.rail-item::before {
    content: ""; position: absolute; left: -12px;
    width: 4px; height: 0; border-radius: 0 4px 4px 0;
    background: var(--text);
    transition: height 0.18s;
}

.rail-item:hover::before { height: 20px; }
.rail-item.active::before { height: 40px; background: var(--accent); }
.rail-item.add { color: var(--ok); }
.rail-item.add:hover:not(:disabled) { background: var(--ok); color: var(--accent-ink); }
.rail-sep { width: 32px; height: 2px; flex: none; border-radius: 1px; background: var(--line-strong); margin: 0.25rem 0; }
.rail .spacer { min-height: 0.5rem; }

.side { display: flex; flex-direction: column; min-width: 0; background: var(--bg-side); border-right: 1px solid var(--line); }
.side-head { padding: 0.9rem 1rem 0.7rem; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.side-head h2 { font-size: 0.95rem; margin-bottom: 0.6rem; }
.side-head form { display: flex; gap: 0.4rem; }
.side-head input { padding: 0.45rem 0.6rem; font-size: 0.88rem; }
.side-head button { padding: 0.45rem 0.7rem; }

.chat-list { flex: 1; overflow-y: auto; padding: 0.5rem; margin: 0; list-style: none; }
.chat-list h3 { padding: 0.6rem 0.5rem 0.3rem; margin: 0; }

.chat-list button {
    display: flex; align-items: center; gap: 0.7rem;
    width: 100%; padding: 0.45rem 0.55rem;
    background: transparent; color: var(--text-soft);
    border-radius: 8px; font-weight: 500; text-align: left;
}

.chat-list button:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); box-shadow: none; }
.chat-list button.active { background: var(--bg-raised); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.chat-list .who { min-width: 0; flex: 1; }
.chat-list .who > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .who small { font-size: 0.75rem; }
.chat-list .request-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.55rem; flex-wrap: wrap; }
.chat-list .request-actions { display: flex; gap: 0.3rem; }
.chat-list .request-actions button { width: auto; padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.empty-list { padding: 1rem; color: var(--muted); font-size: 0.88rem; }

.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }

/* Top bar: what you're looking at on the left, who you are on the right. */
.topbar {
    position: relative;
    display: flex; align-items: center; gap: 0.75rem;
    min-height: 56px; padding: 0 1rem;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.topbar-title { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.topbar-title strong { font-size: 1rem; white-space: nowrap; }
.topbar-title .handle { color: var(--muted); font-size: 0.9rem; }
.title-stack { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.title-stack .home-node { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-stack .home-node .mono { opacity: 0.8; }

.me {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.3rem 0.5rem 0.3rem 0.35rem;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font-weight: 500;
}

.me:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--line-strong); box-shadow: none; }
.me .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.me .who small { font-size: 0.75rem; }
.me .who small.claim { color: var(--accent); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, 0.6); }
.status-dot.connecting { background: var(--warn); }

.popover {
    position: absolute; right: 1rem; top: calc(100% + 6px); z-index: 20;
    width: 340px; padding: 1rem;
    background: var(--bg-raised);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.popover hr, .settings hr { border: 0; border-top: 1px solid var(--line); margin: 0.9rem 0; }
.popover .actions { display: flex; gap: 0.5rem; }

/* Messages */
.messages {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column-reverse; /* keeps the newest message in view */
    padding: 1rem 0;
}

.messages ol { list-style: none; margin: 0; padding: 0; }
.msg { display: grid; grid-template-columns: 40px 1fr; column-gap: 0.9rem; padding: 0.15rem 1.2rem; }
.msg:hover { background: rgba(255, 255, 255, 0.025); }
.msg.first { margin-top: 0.9rem; }
.msg .avatar-wrap { grid-row: span 2; margin-top: 0.15rem; }
.msg-head { display: flex; align-items: baseline; gap: 0.5rem; }
.msg-head strong { font-weight: 600; }
.msg-head strong.mine { color: var(--accent); }
.msg-head time { font-size: 0.72rem; color: var(--muted); }
.msg-text { grid-column: 2; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.msg:not(.first) .msg-text { grid-column: 2; }
.msg:not(.first) time.inline { visibility: hidden; font-size: 0.68rem; color: var(--muted); grid-column: 1; text-align: right; align-self: center; }
.msg:not(.first):hover time.inline { visibility: visible; }

.chat-start { padding: 2rem 1.2rem 1rem; }
.chat-start .avatar-wrap { margin-bottom: 0.8rem; }
.chat-start h2 { font-size: 1.6rem; }

.composer { padding: 0 1rem 1.2rem; }
.composer form {
    display: flex; gap: 0.5rem; align-items: center;
    padding: 0.35rem 0.35rem 0.35rem 0.9rem;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.composer form:focus-within { border-color: rgba(255, 122, 26, 0.6); box-shadow: var(--accent-glow); }
.composer input { border: 0; background: transparent; padding: 0.55rem 0; box-shadow: none !important; }

.empty-state { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 2rem; }
.empty-state .jaw-logo { color: var(--line-strong); margin-bottom: 1rem; }
.empty-state h2 { color: var(--text); }

/* Settings */
.settings { flex: 1; overflow-y: auto; padding: 1.5rem 2rem 3rem; }
.settings section { max-width: 720px; margin-bottom: 1.2rem; padding: 1.2rem; background: var(--bg-side); border: 1px solid var(--line); border-radius: 12px; }
.settings dl { display: grid; grid-template-columns: 140px 1fr; gap: 0.6rem 1rem; margin: 0 0 0.8rem; }
.settings dt { color: var(--muted); font-size: 0.85rem; }
.settings dd { margin: 0; overflow-wrap: anywhere; }
.copyable { display: flex; gap: 0.5rem; align-items: center; }
.copyable code { flex: 1; padding: 0.5rem 0.6rem; background: var(--bg-input); border: 1px solid var(--line); border-radius: 6px; overflow-wrap: anywhere; }

/* Handle picker */
.handle-input { display: flex; align-items: center; gap: 0.5rem; }
.handle-input .at { color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.handle-check { font-size: 0.85rem; margin: 0.4rem 0 0; }
.handle-check.free { color: var(--ok); }
.handle-check.taken { color: var(--danger); }

/* ---------- Narrow screens: hide the chat list column ---------- */

.list-toggle { display: none; }
.list-backdrop { display: none; }
.list-close-row { display: none; }

@media (max-width: 720px) {
    .list-toggle { display: inline-flex; }
    .shell { grid-template-columns: 64px 1fr; }
    .side { display: none; }
    .shell.list-open .side { display: flex; position: fixed; left: 64px; top: 0; bottom: 0; width: min(280px, calc(100vw - 64px)); z-index: 30; }
    .shell.list-open .list-backdrop { display: block; position: fixed; inset: 0 0 0 64px; z-index: 29; background: rgba(0, 0, 0, 0.45); }
    .shell.list-open .list-close-row { display: flex; justify-content: flex-end; padding: 0.35rem 0.5rem 0; flex: none; }
    .list-close-row button { width: auto; padding: 0.3rem 0.6rem; font-size: 0.85rem; }
    .popover { width: calc(100vw - 2rem); }
    .settings { padding: 1rem; }
    .settings dl { grid-template-columns: 1fr; }
}

/* ---------- Blazor host bits ---------- */

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: 0.7rem 1.25rem;
    background: #3b1d12; color: var(--text); border-top: 1px solid var(--accent);
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { padding: 1rem; background: #3b1212; color: var(--text); }
.blazor-error-boundary::after { content: "Something went wrong."; }

.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 30vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: var(--line-strong); stroke-width: 0.5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--accent); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; color: var(--muted); inset: calc(30vh + 6.5rem) 0 auto 0; }
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading"); }

/* The home button on the rail is the logo: black tile, orange jaw (never inverted). */
.rail-item.home { background: #0f1317; color: var(--accent); border: 1px solid var(--line-strong); }
.rail-item.home:hover:not(:disabled), .rail-item.home.active { background: #0f1317; color: var(--accent-hover); box-shadow: var(--accent-glow); }

/* A file picker that looks like a small link-button (the real input is hidden inside the label). */
label.file-pick { display: inline; margin: 0; padding: 0.15rem 0.5rem; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--accent); cursor: pointer; text-transform: none; letter-spacing: normal; font-weight: 600; font-size: 0.8rem; }
label.file-pick:hover { background: var(--accent-dim); }
label.file-pick input[type=file] { display: none; }

/* Proof-of-work progress. */
.pow { margin-top: 0.6rem; }
.pow-bar { height: 4px; border-radius: 2px; background: var(--bg-input); overflow: hidden; }
.pow-bar span { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width 0.3s; }
.pow .ghost { padding: 0.1rem 0.4rem; font-size: 0.8rem; }

/* Rooms (#29-#32). */
.rail-item.room { font-weight: 700; font-size: 0.95rem; color: var(--text); background: var(--bg-raised); }
.rail-item.room.featured { box-shadow: inset 0 0 0 2px rgba(255, 122, 26, 0.55); }
.rail-label { color: var(--accent); font-size: 0.8rem; line-height: 1; margin: -0.1rem 0; }
.room-icon {
    display: inline-grid; place-items: center; flex: none;
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--bg-raised); border: 1px solid var(--line-strong);
    color: var(--accent); font-weight: 700; overflow: hidden;
}
/* A room's picture (#106) fills its icon or rail item, in the same shape. */
.room-picture { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.room-icon.small { width: 32px; height: 32px; border-radius: 10px; font-size: 0.8rem; }
.room-icon.big { width: 72px; height: 72px; border-radius: 20px; font-size: 1.6rem; margin-bottom: 0.8rem; }
.member-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.55rem; border-radius: 8px; color: var(--text-soft); }
.member-row:hover { background: var(--bg-hover); }
.member-row .who { flex: 1; min-width: 0; }
/* The side list makes its buttons full width; a member row's small buttons must not squeeze the name to nothing. */
.chat-list .member-row > button { flex: none; width: auto; padding: 0.2rem 0.45rem; }
.member-row .confirm-remove { display: flex; gap: 0.3rem; flex: none; }
.chat-list .member-row .confirm-remove button { width: auto; padding: 0.2rem 0.5rem; font-size: 0.8rem; }
.member-row .who > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .who small { font-size: 0.72rem; color: var(--accent); }
.member-row .ghost { padding: 0.1rem 0.4rem; }
.side-form { padding: 0.2rem 0.5rem 0.4rem; }
.side-form input { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
.side-form button { padding: 0.4rem 0.6rem; font-size: 0.85rem; }

/* Room menu (#38): click the room name at the top of the side panel. */
.room-head { position: relative; padding-bottom: 0.6rem; }
.room-menu-button {
    display: flex; align-items: center; gap: 0.5rem; width: 100%;
    padding: 0.35rem 0.5rem; margin: -0.35rem -0.5rem 0; width: calc(100% + 1rem);
    background: transparent; color: var(--text); border-radius: 8px; text-align: left; font-weight: 600;
}
.room-menu-button:hover:not(:disabled) { background: var(--bg-hover); box-shadow: none; }
.room-menu-button .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-menu-button .who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-menu-button .who small { font-weight: 400; }
.room-menu-button .chevron { color: var(--muted); font-size: 0.85rem; }
.room-menu {
    position: absolute; left: 0.6rem; right: 0.6rem; top: calc(100% - 0.2rem); z-index: 25;
    display: flex; flex-direction: column; padding: 0.35rem;
    background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 10px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.room-menu button { justify-content: flex-start; background: transparent; color: var(--text-soft); font-weight: 500; padding: 0.5rem 0.6rem; }
.room-menu button:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.room-menu button.leave { color: var(--danger); }
.room-menu button.leave:hover:not(:disabled) { background: var(--danger); color: var(--accent-ink); }
.room-menu hr { border: 0; border-top: 1px solid var(--line); margin: 0.3rem 0; }
.topbar-menu { position: relative; }
.topbar-menu .room-menu { left: auto; right: auto; width: 220px; top: 120%; }
.topbar-menu form { position: absolute; top: 120%; width: 300px; background: var(--bg-raised); padding: 0.5rem; border-radius: 10px; border: 1px solid var(--line-strong); z-index: 25; }
.channel-list { list-style: none; margin: 0 0 0.8rem; padding: 0; color: var(--text-soft); }
.channel-list li { padding: 0.25rem 0; }

/* Search and tags (#37). */
.search-box { display: flex; gap: 0.5rem; }
.search-box input { flex: 1; }
/* Browse (#75): results appear under the box as you type. */
.search-note { margin: 0.6rem 0 0; }
.search-results { margin-top: 0.8rem; }
.browse .tabs { position: sticky; top: 0; z-index: 2; }
.bot-list .list-actions { flex-direction: column; align-items: stretch; }
@media (max-width: 560px) { .bot-list .row { flex-wrap: wrap; } .bot-list .list-actions { flex-direction: row; width: 100%; } }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.tag { padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--accent-dim); color: var(--accent-hover); font-size: 0.72rem; }
.node-list .desc { display: block; color: var(--text-soft); font-size: 0.82rem; margin-top: 0.15rem; }

/* Device linking (#39). */
.link-code { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.link-code .qr { border-radius: 10px; flex: none; }
.link-code dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0.6rem 0 1rem; }
.link-code dt { color: var(--muted); }
.big-code { font-size: 1rem; letter-spacing: 0.05em; overflow-wrap: anywhere; }

/* Unread, edit and delete (#43). */
.msg { position: relative; }
.msg-actions { position: absolute; right: 1rem; top: -0.6rem; display: none; gap: 0.2rem; padding: 0.15rem; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 8px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { background: transparent; color: var(--text-soft); padding: 0.2rem 0.45rem; font-size: 0.85rem; }
.msg-actions button:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); box-shadow: none; }
.msg-actions button.del:hover:not(:disabled) { color: var(--danger); }
.edited { color: var(--muted); font-size: 0.72rem; }
.disappearing { color: var(--accent, var(--muted)); font-size: 0.72rem; white-space: nowrap; } /* #166 */
.disappear-choice { width: auto; flex: none; padding: 0.25rem 0.4rem; font-size: 0.85rem; background: transparent; border: none; color: var(--muted); }
.disappear-note { margin: 0.25rem 0 0; }
.new-divider { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 1.2rem 0.2rem; color: var(--accent); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.new-divider::before, .new-divider::after { content: ""; flex: 1; height: 1px; background: rgba(255, 122, 26, 0.5); }
.unread-badge { display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem; padding: 0 0.3rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.7rem; font-weight: 800; }
.rail-item .unread-badge { position: absolute; right: -4px; bottom: -4px; border: 3px solid var(--bg-rail); height: 1.4rem; min-width: 1.4rem; }
.chat-list button.unread .who > span:first-child { color: var(--text); font-weight: 700; }
.composer .editing { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; color: var(--accent); font-size: 0.8rem; }
.composer .editing button { padding: 0.1rem 0.5rem; font-size: 0.78rem; }

/* In-app context menus (right-click / long-press). */
.context-overlay { position: fixed; inset: 0; z-index: 900; }
.context-menu {
    position: fixed; z-index: 901; min-width: 190px; max-width: 280px;
    display: flex; flex-direction: column; padding: 0.3rem;
    background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 10px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
}
.context-menu button { justify-content: flex-start; background: transparent; color: var(--text-soft); font-weight: 500; padding: 0.45rem 0.6rem; border-radius: 6px; }
.context-menu button:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.context-menu button.danger-item { color: var(--danger); }
.context-menu button.danger-item:hover:not(:disabled) { background: var(--danger); color: var(--accent-ink); }
.context-menu hr { border: 0; border-top: 1px solid var(--line); margin: 0.25rem 0; }
/* Touch screens: long-press opens our menu instead of selecting text (use "Copy text"). */
@media (hover: none) {
    .messages, .chat-list, .rail { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

/* Custom roles (#44). */
.role-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.role-list li .role-dot { width: 14px; height: 14px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }
.role-chip {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.05rem 0.5rem;
    border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.75rem; color: var(--text-soft);
}
.role-picks { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin-top: 0.4rem; }
.role-editor { display: block !important; padding: 0.8rem 1rem; border: 1px solid var(--accent-dim); border-radius: var(--radius); background: var(--bg-raised); margin: 0 0 1rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.3rem 0 0.8rem; }
.swatch { width: 26px; height: 26px; min-width: 0; padding: 0; border-radius: 50%; border: 2px solid transparent; color: var(--text); font-size: 0.8rem; }
.swatch.on { border-color: var(--text); box-shadow: var(--accent-glow); }
.perm-checks { display: grid; gap: 0.35rem; margin-bottom: 0.8rem; }
label.check { display: flex; align-items: flex-start; gap: 0.5rem; cursor: pointer; }
label.check input { width: auto; margin-top: 0.2rem; }
label.check small { display: block; }

/* Node storage budgets (#49): label, number and unit on one line; wraps on phones. */
.node-budgets { display: grid; gap: 0.5rem; margin: 0.75rem 0; }
.node-budgets label.field { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.node-budgets label.field span { flex: 1 1 14rem; }
.node-budgets label.field input { width: 8rem; }

/* Setup files (#67). */
.setup-list { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.5rem; }
.setup-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
.setup-list .what { flex: 1 1 16rem; min-width: 0; }
.setup-list .what small { display: block; overflow-wrap: anywhere; }
.setup-list .valid { color: var(--ok); }
.setup-list .invalid { color: var(--danger); }
.setup-list .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.setup-list .actions button { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.perm-table { width: 100%; border-collapse: collapse; margin: 0.3rem 0 0.8rem; font-size: 0.85rem; }
.perm-table th, .perm-table td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); }
.perm-table select { width: auto; padding: 0.15rem 0.3rem; }
.channel-list li button { margin-left: 0.5rem; padding: 0.1rem 0.5rem; font-size: 0.78rem; }
.composer .read-only { margin: 0; padding: 0.7rem 0.9rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; }

/* Chat lists and the people picker (#46). */
.side-head-row { display: flex; align-items: center; gap: 0.4rem; }
.side-head-row h2 { flex: 1; margin: 0; }
.icon-button { display: inline-grid; place-items: center; padding: 0.3rem !important; border-radius: 6px; color: var(--text-soft); }
.icon-button:hover { color: var(--accent); }
.chat-row { position: relative; display: flex; align-items: center; }
.chat-row > button:first-child { flex: 1; min-width: 0; }
.chat-row .close-chat {
    position: absolute; right: 0.35rem; width: auto; padding: 0.15rem 0.4rem; font-size: 0.8rem;
    color: var(--muted); opacity: 0; background: transparent;
}
.chat-row:hover .close-chat, .chat-row .close-chat:focus-visible { opacity: 1; }
.chat-row .close-chat:hover { color: var(--text); background: var(--bg-hover); }
.chat-row:hover > button:first-child .unread-badge { visibility: hidden; }
@media (hover: none) { .chat-row .close-chat { opacity: 1; position: static; } }
.chat-time { position: absolute; right: 0.8rem; color: var(--muted); font-size: 0.75rem; pointer-events: none; }
.home-list .chat-row > button:first-child { padding-right: 3.5rem; }
.home-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.home-head h3 { margin: 0; }
.home-filter { margin-bottom: 0.5rem; }
.home-list { padding: 0; }
.home-waiting { margin-bottom: 1rem; } /* #200: requests and invitations above the chats */
.picker-box {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; padding: 0.35rem 0.5rem;
    background: var(--bg-input); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: text;
}
.picker-box:focus-within { border-color: var(--accent); box-shadow: var(--accent-glow); }
.picker-box input { flex: 1; min-width: 10rem; border: 0; background: transparent; box-shadow: none !important; padding: 0.35rem 0.2rem; }
.picker-chip {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.2rem 0.15rem 0.25rem;
    background: var(--accent-dim); border: 1px solid rgba(255, 122, 26, 0.35); border-radius: 999px; font-size: 0.85rem;
}
.picker-chip button { padding: 0 0.35rem; font-size: 0.75rem; min-width: 0; }
.picker-list { list-style: none; margin: 0.4rem 0 0.8rem; padding: 0.3rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg-raised); }
.picker-list button {
    display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.4rem 0.5rem; border-radius: 6px;
    background: transparent; color: var(--text-soft); font-weight: 500; justify-content: flex-start; text-align: left;
}
.picker-list button.active { background: var(--bg-hover); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.picker-list .who { min-width: 0; display: flex; flex-direction: column; }
.picker-list .who small { color: var(--muted); font-size: 0.75rem; }
.picker .row { margin-top: 0.8rem; }

/* Top of a room: older history fetched from other nodes on request (#48). */
.older-history { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 0.8rem; font-size: 0.85rem; }
.older-history.incomplete { flex-direction: column; }
.older-history .notice { max-width: 560px; text-align: center; }
.member-history { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem; padding: 0.6rem 1rem 0; font-size: 0.85rem; text-align: center; }
/* Declared bots (#53): a small tag next to the name. */
.bot-tag {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.35rem;
    border-radius: 4px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.35;
    vertical-align: middle;
}

.bot-list { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.6rem; }
.bot-list > li { padding: 0.7rem; border-radius: 8px; background: var(--accent-dim); }
.bot-commands { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.3rem 0; }

/* Bot commands and components (#54). */
.msg-command, .msg-reply, .msg-components { grid-column: 2; } /* the text column of the message grid, like .msg-text */
.msg-command code { color: var(--accent); }
.msg-reply { opacity: 0.75; margin-bottom: 0.1rem; }
.msg-components { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.35rem; }
.msg-components > * { flex: none; width: auto; }
.msg-components button, .msg-components select { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.command-menu {
    display: flex; flex-direction: column; margin: 0 0 0.4rem; border-radius: 8px; background: var(--accent-dim);
    max-height: min(18rem, 40vh); overflow: hidden;
}
.command-menu-title { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0.35rem 0.6rem 0.1rem; flex: none; }
.command-menu-back { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
.command-suggestions { list-style: none; margin: 0; padding: 0.3rem; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.command-suggestions button > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.command-menu-more { margin-left: auto; color: var(--muted); }

.command-suggestions button { display: flex; width: 100%; gap: 0.6rem; justify-content: flex-start; text-align: left; background: transparent; color: inherit; padding: 0.35rem 0.5rem; }
.command-suggestions button:hover, .command-suggestions button:focus { background: var(--accent-dim); }
.command-hint { margin: 0 0 0.3rem; opacity: 0.8; }
.bot-approval { border: 1px solid var(--accent); border-radius: 10px; padding: 0.9rem; margin: 0.6rem 0; }
.bot-approval ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
.bot-notice { margin: 0.5rem 1rem 0; }

/* Files and images (#50). */
.msg-files { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.35rem; }
.attachment-image {
    display: block; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--bg-raised);
    max-width: min(420px, 100%); max-height: 360px; cursor: zoom-in;
}
.attachment-image img { display: block; width: 100%; height: 100%; max-height: 360px; object-fit: contain; }
.attachment-image img.loading { filter: blur(2px); }
.attachment-file {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; max-width: 420px;
    border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-raised);
}
.attachment-file .who { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.attachment-file .who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-file small { color: var(--muted); }
.attachment-icon { font-size: 1.4rem; }
.attachment-zoom {
    position: fixed; inset: 0; z-index: 950; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.8rem; padding: 1rem; background: rgba(0, 0, 0, 0.85); cursor: zoom-out;
}
.attachment-zoom img { max-width: 100%; max-height: calc(100% - 4rem); object-fit: contain; }
.attachment-zoom-bar { display: flex; align-items: center; gap: 0.6rem; color: var(--text-soft); cursor: default; }
.attach-button {
    display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; flex: none; margin: 0; border-radius: 8px; color: var(--text-soft); cursor: pointer; /* labels have a form-field margin by default, which pushed the icon up */
}
.attach-button svg, .record-button svg, .composer-icon svg { display: block; }

.attach-button:hover { color: var(--accent); background: var(--bg-hover); }
.attach-button input[type="file"] { display: none; }
.upload-progress { margin: 0 0 0.3rem; }

/* Sound (#73): voice clips and audio files play in the chat; the composer records clips. */
.attachment-audio { flex-direction: column; align-items: stretch; width: min(420px, 100%); }
.attachment-audio-head { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.attachment-audio audio { width: 100%; height: 2.4rem; }
.attachment-audio > button { align-self: flex-start; }
.record-button, .composer-icon { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; flex: none; padding: 0; }
.composer form.recording > button { flex: none; white-space: nowrap; }
button.ghost.stop-button { color: var(--danger); }
.clip-preview { flex: 1; min-width: 0; height: 2.4rem; }

.record-button:hover:not(:disabled) { color: var(--accent); }
.recording-time { display: inline-flex; align-items: center; gap: 0.4rem; flex: 0 1 auto; min-width: 0; padding: 0 0.3rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.recording-limit { margin-left: 0.15rem; }
@media (max-width: 480px) { .recording-limit { display: none; } }

.recording-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--danger); animation: recording-pulse 1.2s ease-in-out infinite; }
@keyframes recording-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .recording-dot { animation: none; } }
/* A bar whose fill follows the microphone: jaw-audio.js sets --level from 0 to 1. */
.level-meter { --level: 0; display: block; height: 0.5rem; border-radius: 999px; background: var(--bg-hover); overflow: hidden; }
.level-meter > span { display: block; height: 100%; width: calc(var(--level) * 100%); background: var(--accent); transition: width 60ms linear; }
.level-meter[hidden] { display: none; }
.recording-meter { flex: 1 1 2rem; min-width: 1.5rem; align-self: center; }
.audio-settings { display: grid; gap: 0.7rem; }
.audio-settings label.field { display: grid; gap: 0.25rem; }
.audio-settings select { max-width: 100%; }
.audio-settings .level-meter { max-width: 320px; }
/* Inside names that clip with an ellipsis, the tag stays a small inline pill. */
.who .bot-tag, .node-meta .bot-tag, strong .bot-tag { display: inline-block; overflow: visible; }

/* Choosing a picture (#71): a label that looks like a secondary button, around a hidden file input. */
.btn.secondary { background: var(--bg-hover); color: var(--text); cursor: pointer; }
.btn.secondary:hover { background: var(--line-strong); }
.file-button input[type="file"] { display: none; }

/* Picture cropper (#71): drag and zoom an image inside the circle avatars show. */
.cropper { display: grid; gap: 0.4rem; justify-items: start; }
.crop-view {
    position: relative; overflow: hidden; border-radius: 8px; background: var(--bg-raised);
    touch-action: none; cursor: grab; user-select: none;
}
.crop-view:active { cursor: grabbing; }
.crop-view img { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.crop-circle {
    position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    box-shadow: 0 0 0 999px rgb(0 0 0 / 55%); outline: 2px solid rgb(255 255 255 / 70%); outline-offset: -2px;
}
.crop-zoom { width: 240px; margin: 0; }
.crop-zoom input[type="range"] { width: 100%; }

/* Channel and personal permissions (#74). */
.perm-scroll { overflow-x: auto; max-width: 100%; }
.perm-table select.tri.allow { border-color: #4cc38a; }
.perm-table select.tri.deny, .person-perms select.tri.deny { border-color: #e5484d; }
.person-perms select.tri.allow { border-color: #4cc38a; }
.person-perms { margin-top: 0.4rem; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); }
.person-perms select { width: auto; padding: 0.15rem 0.3rem; }

/* Room owners (#77). */
.owner-list { margin: 0.3rem 0 0.6rem 1.2rem; padding: 0; }
.owner-list li { margin: 0.2rem 0; }
.notice.warning { margin: 0.6rem 0; }
/* Link cards (#84): Discord-style, an accent bar on the left; players load only after pressing play. */
.msg-links { grid-column: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; margin-top: 0.35rem; }
.link-card {
    position: relative; display: flex; gap: 0.8rem; max-width: min(440px, 100%); padding: 0.6rem 2rem 0.7rem 0.8rem;
    border-left: 3px solid var(--accent); border-radius: 6px; background: var(--bg-raised);
}
.link-card.embed { width: min(440px, 100%); }
.link-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.link-site { color: var(--muted); font-size: 0.75rem; }
.link-title { color: var(--accent); font-weight: 600; overflow-wrap: anywhere; }
.link-title:hover { color: var(--accent-hover); text-decoration: underline; }
.link-description {
    margin: 0; color: var(--text-soft); font-size: 0.88rem; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.link-thumb { flex: none; align-self: flex-start; }
.link-thumb img { display: block; width: 80px; height: 80px; object-fit: cover; border-radius: 6px; }
.link-play {
    position: relative; display: block; width: 100%; margin-top: 0.3rem; padding: 0; border: 0; border-radius: 6px; overflow: hidden;
    background: #000; aspect-ratio: 16 / 9; cursor: pointer;
}
.link-play.bare { aspect-ratio: auto; height: 3rem; background: var(--bg-hover); }
.link-play img { display: block; width: 100%; height: 100%; object-fit: cover; }
.link-play .play-icon {
    position: absolute; inset: 0; margin: auto; display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%;
    background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 1.3rem; padding-left: 0.2rem;
}
.link-play:hover .play-icon, .link-play:focus-visible .play-icon { background: var(--accent); color: var(--accent-ink); }
.link-player { display: block; width: 100%; aspect-ratio: 16 / 9; margin-top: 0.3rem; border: 0; border-radius: 6px; background: #000; }
.link-remove {
    position: absolute; top: 0.3rem; right: 0.3rem; width: 1.5rem; height: 1.5rem; padding: 0; border: 0; border-radius: 4px;
    background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; opacity: 0; cursor: pointer;
}
.link-card:hover .link-remove, .link-remove:focus-visible { opacity: 1; }
.link-remove:hover { color: var(--text); background: var(--bg-hover); }
@media (hover: none) { .link-remove { opacity: 1; } }
.msg-text a { color: var(--accent); overflow-wrap: anywhere; }
.msg-text a:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Worktrees (#94): a channel of shared files ---------- */

.worktree { flex: 1; overflow-y: auto; padding: 0.8rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.worktree-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.worktree-path { display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; min-width: 0; }
.worktree-path button { padding: 0.3rem 0.45rem; font-weight: 600; }
.worktree-form { gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; }
.worktree-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--text-soft); }
.worktree-status { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.worktree-status .spinner { width: 16px; height: 16px; margin: 0; }
/* Folder sync (#97) */
.folder-sync { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); }
.folder-sync p { margin: 0; }
.folder-sync .row { gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.folder-sync input.grow { flex: 1; min-width: 12rem; }
.folder-sync-choices { border: none; margin: 0; padding: 0; display: flex; gap: 0.9rem; flex-wrap: wrap; }
.folder-sync-choices legend { font-size: 0.85rem; color: var(--text-soft); margin-bottom: 0.2rem; }
.folder-sync-notes { margin: 0; padding-left: 1.1rem; }
.folder-sync-deletes { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.4rem 0; }
.folder-sync-deletes p { margin: 0; }
.folder-sync-deletes label { display: flex; gap: 0.5rem; align-items: center; }
.worktree-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.worktree-item {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; flex-wrap: wrap;
    border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised);
}
.worktree-item .who { min-width: 0; flex: 1 1 12rem; display: flex; flex-direction: column; }
.worktree-item .who > span, .worktree-item .who > button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.worktree-item small { color: var(--muted); }
.worktree-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-left: auto; }
.worktree-versions ol { margin: 0; padding-left: 1.4rem; width: 100%; display: flex; flex-direction: column; gap: 0.2rem; }
.worktree-versions li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.worktree-heading { margin-top: 1rem; }

/* A file picker that looks like a button: the label opens the hidden input. */
label.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; margin: 0; padding: 0.6rem 1.1rem;
    border-radius: 8px; cursor: pointer; font: inherit; font-weight: 650; text-transform: none; letter-spacing: normal;
    background: var(--accent); color: var(--accent-ink); position: relative;
}
label.button.secondary { background: var(--bg-hover); color: var(--text); }
label.button.secondary:hover { background: var(--line-strong); }
label.button.ghost { background: transparent; color: var(--text-soft); padding: 0.4rem 0.6rem; font-weight: 650; }
label.button.ghost:hover { background: var(--bg-hover); color: var(--text); }
label.button.disabled { opacity: 0.45; pointer-events: none; }
label.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
button.link { background: transparent; color: var(--text); padding: 0; font-weight: 600; justify-content: flex-start; align-self: flex-start; max-width: 100%; }
button.link:hover:not(:disabled) { background: transparent; box-shadow: none; color: var(--accent-hover); text-decoration: underline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }

@media (max-width: 560px) {
    .worktree { padding: 0.6rem 0.6rem 1.2rem; }
    .worktree-actions { margin-left: 0; width: 100%; }
}
.room-picture-setting { align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.room-picture-setting .room-icon.big { margin-bottom: 0; }
/* ---------- Live text editor (#95): a text box with line numbers and others' cursors drawn over it ---------- */

.text-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0.6rem 1rem 1rem; gap: 0.5rem; }
.text-editor-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.text-editor-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.text-editor-plain { flex: 1; overflow: auto; margin: 0; padding: 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-input); font: 14px/1.5 var(--mono); }
.editor {
    flex: 1; min-height: 12rem; display: grid; grid-template-columns: auto 1fr; overflow: hidden;
    border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-input);
}
.editor-gutter {
    margin: 0; padding: 0.7rem 0.6rem 0.7rem 0.8rem; overflow: hidden; text-align: right; user-select: none;
    color: var(--muted); font: 14px/1.5 var(--mono); border-right: 1px solid var(--line); min-width: 3ch;
}
.editor-main { position: relative; min-width: 0; min-height: 0; }
.editor-main textarea {
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0.7rem; border: 0; border-radius: 0;
    resize: none; outline: none; background: transparent; color: var(--text); caret-color: var(--accent);
    font: 14px/1.5 var(--mono); white-space: pre; overflow: auto; tab-size: 4; box-shadow: none;
}
.editor-main textarea:read-only { color: var(--text-soft); }
.editor-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.editor-selection { position: absolute; opacity: 0.25; border-radius: 2px; }
.editor-caret { position: absolute; width: 0; border-left: 2px solid; }
.editor-caret span {
    position: absolute; left: -2px; top: -1.25em; padding: 0 0.35em; border-radius: 4px 4px 4px 0; white-space: nowrap;
    font: 600 11px/1.4 var(--font); color: #14181d;
}

@media (max-width: 560px) {
    .text-editor { padding: 0.5rem 0.5rem 0.8rem; }
    .editor-gutter { display: none; }
    .editor { grid-template-columns: 1fr; }
}
/* Worktree files that nodes will drop soon unless someone opens the worktree (#96). */
.worktree-item .at-risk { color: var(--warn); }

/* Worktree history (#108): a slider over a file's edits. */
.history-bar { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.history-bar input[type=range] { flex: 1 1 14rem; margin: 0; accent-color: var(--accent); }
.history-text { max-height: 50vh; white-space: pre-wrap; }
.voice-channel { padding: 1rem; overflow-y: auto; }
.voice-channel .actions { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.voice-roster { list-style: none; padding: 0; margin: 0.25rem 0; }
.voice-roster li { padding: 0.25rem 0; }
/* Emoji menu (#109): opens above the composer; a clear backdrop closes it. */
.composer { position: relative; }
.emoji-button { color: var(--text-soft); }
.emoji-button:hover:not(:disabled) { color: var(--accent); }
.emoji-backdrop { position: fixed; inset: 0; z-index: 40; }
.emoji-menu {
    position: absolute; right: 1rem; bottom: calc(100% + 0.4rem); z-index: 41;
    display: flex; flex-direction: column; gap: 0.4rem; width: min(22rem, calc(100vw - 2rem)); max-height: min(24rem, 55vh);
    padding: 0.6rem; background: var(--bg-side); border: 1px solid var(--line-strong); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.emoji-search { flex: none; }
.emoji-groups { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.emoji-group-title { margin: 0.4rem 0 0.15rem; }
.emoji-group-title:first-child { margin-top: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.2rem, 1fr)); gap: 0.1rem; }
button.emoji-choice {
    display: grid; place-items: center; width: 100%; aspect-ratio: 1; padding: 0; border-radius: 8px;
    background: transparent; font-size: 1.35rem; line-height: 1;
}
button.emoji-choice:hover, button.emoji-choice:focus-visible { background: var(--bg-hover); }

/* Mentions (#111): "@Name" chips in messages; a message that mentions you is highlighted. */
.mention { padding: 0 0.2rem; border-radius: 4px; background: rgba(120, 150, 255, 0.16); color: #aebcff; font-weight: 600; white-space: nowrap; }
.mention.mention-me { background: var(--accent-dim); color: var(--accent-hover); }
.msg.mentioned { background: rgba(255, 122, 26, 0.07); box-shadow: inset 2px 0 0 var(--accent); }
.msg.mentioned:hover { background: rgba(255, 122, 26, 0.11); }
.command-suggestions button > .avatar { flex: none; }

/* Pinned messages (#110): a pin button with the count in the top bar opens the channel's list. */
.pins-menu { position: relative; }
.pins-button { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.3rem 0.45rem; color: var(--text-soft); }
.pins-button:hover, .pins-button[aria-expanded="true"] { color: var(--accent); }
.pins-count { font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.pins-backdrop { position: fixed; inset: 0; z-index: 40; }
.pins-panel {
    position: absolute; top: 120%; right: 0; z-index: 41; display: flex; flex-direction: column;
    width: min(26rem, calc(100vw - 2rem)); max-height: min(32rem, 70vh);
    background: var(--bg-side); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
@media (max-width: 640px) { .pins-panel { position: fixed; top: 3.5rem; left: 1rem; right: 1rem; width: auto; } }
.pins-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); flex: none; }
.pins-head button { margin-left: auto; padding: 0.15rem 0.45rem; }
.pins-empty { margin: 0; padding: 1rem 0.9rem; }
.pins-empty span { display: block; margin-top: 0.3rem; font-size: 0.85rem; }
.pins-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.pin { padding: 0.55rem 0.6rem; border-radius: 8px; background: var(--bg-raised); }
.pin + .pin { margin-top: 0.4rem; }
.pin-head { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.pin-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-head time { margin-left: auto; font-size: 0.72rem; white-space: nowrap; }
.pin-text { margin-top: 0.3rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9rem; overflow: hidden; }
.pin-missing { margin: 0; }
.pin-foot { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.pin-foot button { margin-left: auto; padding: 0.1rem 0.5rem; font-size: 0.8rem; }
.msg-pinned { margin-left: 0.4rem; padding: 0 0.35rem; border-radius: 4px; background: var(--accent-dim); color: var(--accent-hover); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.msg.pinned { box-shadow: inset 2px 0 0 rgba(255, 122, 26, 0.45); }
.msg.pinned.mentioned { box-shadow: inset 2px 0 0 var(--accent); }

/* Profile cards (#113): open where someone was clicked, kept inside the window; a sheet on phones. */
.msg-avatar { grid-row: span 2; cursor: pointer; align-self: start; }
.msg-avatar .avatar-wrap { margin-top: 0.15rem; }
.msg-author, .mention, .topbar-person, .picker-avatar, .member-row { cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.topbar-person { display: inline-flex; align-items: center; gap: 0.5rem; }
.topbar-person:hover strong { text-decoration: underline; }
.picker-avatar { display: inline-flex; flex: none; border-radius: 50%; }
.picker-avatar:hover { box-shadow: 0 0 0 2px var(--accent); }
.card-backdrop { position: fixed; inset: 0; z-index: 60; }
.profile-card {
    /* #194: always fully on screen. The top is near the click but never so low that 520px won't fit, and the card never
       reaches past the bottom (it scrolls instead): it used to assume it was at most 520px tall. dvh: the visible height
       on phones, where vh can include hidden bars. */
    --card-top: clamp(8px, calc(var(--card-y) - 40px), calc(100dvh - 520px));
    position: fixed; z-index: 61; width: min(320px, calc(100vw - 16px)); overflow-y: auto; overscroll-behavior: contain;
    max-height: calc(100dvh - var(--card-top) - 8px);
    left: clamp(8px, var(--card-x), calc(100vw - min(320px, calc(100vw - 16px)) - 8px)); top: var(--card-top);
    background: var(--bg-side); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
@media (max-width: 640px) {
    .profile-card { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: calc(100dvh - 16px); }
}
.profile-card-banner { height: 56px; background: linear-gradient(120deg, rgba(255, 122, 26, 0.55), rgba(255, 122, 26, 0.08)); border-radius: 13px 13px 0 0; }
.profile-card-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 0.9rem; margin-top: -36px; }
.profile-card-head .avatar-wrap { border: 4px solid var(--bg-side); border-radius: 50%; }
.profile-card-close { padding: 0.15rem 0.45rem; margin-bottom: 0.2rem; }
.profile-card-body { padding: 0.3rem 0.9rem 0.9rem; }
.profile-card-body h3 { margin: 0.2rem 0 0; font-size: 1.15rem; font-weight: 700; text-transform: none; letter-spacing: normal; color: var(--text); overflow-wrap: anywhere; }
.profile-card-body .handle { color: var(--text-soft); font-size: 0.85rem; }
.profile-card-presence { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem; font-size: 0.85rem; color: var(--text-soft); }
.status-dot.away { background: var(--warn); }
.status-dot.busy { background: var(--danger); }
.profile-card-status { margin: 0.5rem 0 0; padding: 0.45rem 0.6rem; border-radius: 8px; background: var(--bg-raised); font-size: 0.88rem; overflow-wrap: anywhere; }
.profile-card section { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }
.profile-card h4 { margin: 0 0 0.4rem; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.profile-card p { margin: 0; }
.profile-card-row { display: grid; grid-template-columns: 6.2rem 1fr auto; gap: 0.4rem; align-items: baseline; font-size: 0.82rem; margin-bottom: 0.3rem; }
.profile-card-row > :nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.profile-card-row button { padding: 0.05rem 0.4rem; font-size: 0.75rem; }
.profile-card-id { font-size: 0.72rem; color: var(--text-soft); }
.profile-card-node { display: block; }
.profile-card-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.profile-card .chip { padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg-raised); border: 1px solid var(--line-strong); font-size: 0.78rem; }
.profile-card .chip.owner { color: var(--accent); border-color: rgba(255, 122, 26, 0.5); }
.profile-card-devices, .profile-card-rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.profile-card-devices li { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; }
.profile-card-rooms button { display: flex; font-weight: 500; font-size: 0.88rem; align-items: center; gap: 0.5rem; width: 100%; justify-content: flex-start; padding: 0.25rem 0.35rem; text-align: left; color: var(--text); }
.profile-card-rooms button > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card-rooms .room-icon.small { width: 24px; height: 24px; border-radius: 7px; font-size: 0.65rem; }
.profile-card-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.profile-card-actions button { flex: 1; }

/* Signed files (#129). */
.signed-file { margin-top: 0.75rem; padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
.signed-file .valid { color: var(--ok); }
.signed-file .invalid { color: var(--danger); }
.package-files { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; max-height: 14rem; overflow: auto; }
.package-files code { overflow-wrap: anywhere; }

/* NodeApp screens (#130): Jaw draws the border and its label; the app only fills the inside, in Jaw's own controls. */
.app-screen { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 0 0.85rem 0.85rem; margin: 0.75rem 0; background: var(--bg-main); max-width: 100%; overflow-wrap: anywhere; }
.app-screen-label { margin: 0 -0.85rem 0.6rem; padding: 0.3rem 0.85rem; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--bg-raised); border-radius: var(--radius) var(--radius) 0 0; user-select: none; }
.app-screen-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.4rem; }
.app-column { display: flex; flex-direction: column; gap: 0.55rem; }
.app-row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.app-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.75rem 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; margin: 0; min-width: 0; }
.app-group legend { padding: 0 0.3rem; color: var(--text-soft); font-weight: 600; }
.app-divider { border: none; border-top: 1px solid var(--line); width: 100%; margin: 0.2rem 0; }
.app-heading { font-weight: 700; }
.app-heading-1 { font-size: 1.25rem; }
.app-heading-2 { font-size: 1.1rem; }
.app-heading-3 { font-size: 1rem; color: var(--text-soft); }
.app-text { margin: 0; white-space: pre-wrap; }
.app-bold { font-weight: 700; }
.app-italic { font-style: italic; }
.app-code { font-family: var(--mono); background: var(--bg-input); padding: 0 0.25rem; border-radius: 4px; }
.app-list { margin: 0; padding-left: 1.2rem; }
.app-table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; }
.app-table th, .app-table td { border: 1px solid var(--line); padding: 0.25rem 0.55rem; text-align: left; }
.app-progress { display: grid; gap: 0.2rem; }
.app-progress progress { width: 100%; max-width: 24rem; }
/* Natural size, never stretched by the flex column around it (#193); pixel art stays crisp when the browser scales it. */
.app-image { max-width: 100%; height: auto; border-radius: 6px; align-self: flex-start; image-rendering: pixelated; }
.app-field { display: grid; gap: 0.25rem; }
.app-field textarea { min-height: 5rem; }
.app-choice { border: none; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
.app-screen-confirm { margin-top: 0.75rem; padding: 0.7rem 0.85rem; border: 1px solid var(--warn); border-radius: var(--radius); background: var(--bg-raised); }
.app-screen-url { overflow-wrap: anywhere; }
.app-preview-json { width: 100%; font-family: var(--mono); font-size: 0.85rem; }
.app-preview-actions { padding-left: 1.2rem; }

/* An app before it's opened (#131): grayed, with the warning. */
/* #179: an app embedded in a message sits in the message grid's text column (without this it fell into the 40px avatar
   column and wrapped one word per line), as wide as a channel's app screen would be, up to the line's width. */
.app-embed { grid-column: 2; width: min(640px, 100%); min-width: 0; }
.app-trust-card { margin: 0.75rem 0; padding: 0.7rem 0.85rem; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg-raised); color: var(--text-soft); }
.settings-tabs { flex-wrap: wrap; }
.settings-tabs button { flex: 1 1 auto; white-space: nowrap; }

/* #187: press and hold a rail icon until it pops out and the others shake, then drag it into place. */
.rail-order { display: contents; }
.rail-order > * { flex: none; } /* #175: icons never squash */
.rail-order [data-reorder-key] { transition: transform 0.15s ease; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rail-order.reordering [data-reorder-key]:not(.reorder-lifted) { animation: reorder-shake 0.28s ease-in-out infinite alternate; }
.rail-order [data-reorder-key].reorder-lifted { transition: none; z-index: 5; position: relative; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45)); }
@keyframes reorder-shake {
    from { rotate: -3deg; }
    to { rotate: 3deg; }
}
@media (prefers-reduced-motion: reduce) {
    .rail-order.reordering [data-reorder-key]:not(.reorder-lifted) { animation: none; opacity: 0.85; }
}

/* #186: on small screens the composer's tools wait behind a button and open as a row above the text box, so there's
   always room to type. On wider screens they sit in the bar as before (attach first). */
.composer-more { display: none; }
.composer-tools { display: contents; }
.composer-tools > .attach-button { order: -1; }
@media (max-width: 600px) {
    .composer form { flex-wrap: wrap; padding-left: 0.35rem; }
    .composer form > input { flex: 1 1 6rem; min-width: 0; }
    .composer-more { display: inline-grid; }
    .composer-tools { display: none; }
    .composer-tools.open { display: flex; order: -2; flex: 1 0 100%; align-items: center; gap: 0.4rem; padding: 0 0.2rem 0.2rem; border-bottom: 1px solid var(--line); }
    .composer-tools.open > .attach-button { order: 0; }
}

/* #195: profile bio, links (with bundled site icons) and promoted room. */
.profile-card-bio { margin: 0.5rem 0 0; font-size: 0.88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-card-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.profile-card-links button { display: flex; align-items: center; gap: 0.5rem; width: 100%; justify-content: flex-start; padding: 0.25rem 0.35rem; text-align: left; color: var(--text); font-weight: 500; font-size: 0.88rem; min-width: 0; }
.profile-card-links button > span { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card-links button > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.link-icon { flex: none; width: 16px; height: 16px; color: var(--text-soft); }
.profile-card-confirm { margin-top: 0.5rem; padding: 0.6rem; border-radius: 8px; background: var(--bg-raised); border: 1px solid var(--line-strong); font-size: 0.85rem; }
.profile-card-confirm p { margin: 0 0 0.4rem; }
.profile-card-confirm code { overflow-wrap: anywhere; font-size: 0.78rem; }
.profile-card-rooms button > small { margin-left: auto; flex: none; }
.profile-link-edit { gap: 0.4rem; align-items: center; margin-bottom: 0.35rem; }
.profile-link-edit input:first-of-type { flex: 0 1 11rem; min-width: 0; }
.profile-link-edit input:last-of-type { flex: 1 1 14rem; min-width: 0; }

/* #197: timelines. */
.timeline-view { max-width: 640px; width: 100%; margin: 0 auto; padding: 0.75rem 1rem 2rem; overflow-y: auto; height: 100%; box-sizing: border-box; }
.timeline-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.timeline-head h2 { margin: 0; font-size: 1.15rem; display: flex; align-items: center; gap: 0.4rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.timeline-tabs { display: flex; gap: 0.25rem; width: 100%; border-bottom: 1px solid var(--line); }
.timeline-tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--text-soft); padding: 0.45rem 0.9rem; font-weight: 600; }
.timeline-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.timeline-compose { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.6rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-raised); margin-bottom: 0.8rem; }
.timeline-compose textarea { resize: vertical; min-height: 2.6rem; }
.timeline-compose .row { align-items: center; gap: 0.6rem; justify-content: flex-end; }
.timeline-compose .row .attach-button { margin-right: auto; }
.timeline-compose small.warn { color: var(--accent); }
.timeline-compose-image { position: relative; align-self: flex-start; }
.timeline-compose-image img { max-height: 160px; max-width: 100%; border-radius: 10px; display: block; }
.timeline-compose-image button { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, 0.6); }
.timeline-list { display: flex; flex-direction: column; gap: 0.1rem; }
.timeline-post { display: flex; gap: 0.6rem; padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--line); }
.timeline-avatar { padding: 0; flex: none; align-self: flex-start; border-radius: 50%; }
.timeline-post-body { flex: 1; min-width: 0; }
.timeline-post-meta { display: flex; align-items: baseline; gap: 0.35rem; flex-wrap: wrap; }
.timeline-name { padding: 0; font-weight: 700; color: var(--text); }
.timeline-name:hover { text-decoration: underline; }
.timeline-text { margin: 0.2rem 0 0.3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline-image { display: block; max-width: 100%; max-height: 420px; border-radius: 12px; border: 1px solid var(--line); margin: 0.3rem 0; object-fit: contain; }
.timeline-image.placeholder { height: 120px; display: flex; align-items: center; justify-content: center; background: var(--bg-raised); }
.timeline-actions { display: flex; gap: 0.8rem; }
.timeline-actions button { padding: 0.1rem 0.35rem; font-size: 0.85rem; color: var(--text-soft); min-width: 2.5rem; text-align: left; }
.timeline-actions button.liked { color: #e0245e; }
.timeline-hidden-toggle { align-self: flex-start; margin-top: 0.6rem; color: var(--text-soft); }
.timeline-hidden { opacity: 0.7; }
.timeline-interests { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.6rem; }
.timeline-interests .chip { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.1rem 0.2rem 0.1rem 0.55rem; border-radius: 999px; background: var(--bg-raised); border: 1px solid var(--line-strong); font-size: 0.8rem; }
.timeline-interests .chip button { padding: 0 0.3rem; font-size: 0.75rem; }
.timeline-likers { margin: 0.2rem 0 0.6rem; }
