/* 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; }
.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; }

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-y: auto;
    scrollbar-width: none;
}

.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-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; }
.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; }

.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; }

@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; }
    .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;
}
.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; }
.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; }
.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-suggestions { list-style: none; margin: 0 0 0.4rem; padding: 0.3rem; border-radius: 8px; background: var(--accent-dim); }
.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; flex: none; border-radius: 8px; color: var(--text-soft); cursor: pointer;
}
.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 { display: inline-grid; place-items: center; width: 2.4rem; flex: none; padding: 0; }
.record-button:hover:not(:disabled) { color: var(--accent); }
.recording-time { display: inline-flex; align-items: center; gap: 0.5rem; flex: none; padding: 0 0.3rem; font-variant-numeric: tabular-nums; }
.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; min-width: 3rem; 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; }
