/* ==========================================================================
   KSpeak · Modern Chat Theme
   Element-inspired layout · Manrope typography · Deep warm dark palette
   ========================================================================== */

:root {
    /* Background stack — warm-tinted dark */
    --bg-0: #08090c;            /* deepest (page) */
    --bg-1: #0e1014;            /* deep panel */
    --bg-2: #13151b;            /* rooms sidebar / members sidebar */
    --bg-3: #171922;            /* chat background */
    --bg-4: #1d2029;            /* elevated panels */
    --bg-5: #252934;            /* hover */
    --bg-6: #2f3442;            /* active / pressed */

    /* Borders */
    --border: rgba(255, 255, 255, 0.055);
    --border-strong: rgba(255, 255, 255, 0.095);
    --border-focus: rgba(45, 212, 191, 0.45);

    /* Text */
    --text: #e7ebf2;
    --text-soft: #bfc5d1;
    --text-dim: #8891a1;
    --text-muted: #5a6270;
    --text-faint: #3c424d;

    /* Accents */
    --accent: #2dd4bf;             /* teal primary */
    --accent-bright: #5eead4;
    --accent-dim: #14b8a6;
    --accent-wash: rgba(45, 212, 191, 0.12);
    --accent-glow: rgba(45, 212, 191, 0.35);

    --coral: #fb923c;              /* warm secondary (online/attention) */
    --coral-wash: rgba(251, 146, 60, 0.15);
    --violet: #a78bfa;
    --rose: #fb7185;
    --danger: #f87171;
    --warning: #fbbf24;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 32px var(--accent-glow);

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;
    --r-2xl: 24px;
    --r-full: 999px;

    /* Typography */
    --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
    --font-display: "Instrument Serif", Georgia, serif;

    /* Motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11";
}

body {
    overflow: hidden;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
    padding: 0;
}

::selection {
    background: var(--accent-wash);
    color: var(--accent-bright);
}

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--r-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
    background-clip: padding-box;
    border: 2px solid transparent;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.is-hidden { display: none !important; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================================================
   AUTH VIEW
   ========================================================================== */

.auth-view {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: var(--bg-0);
}

body[data-auth-pending="1"] .auth-view {
    visibility: hidden;
    pointer-events: none;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 20% 10%, rgba(45, 212, 191, 0.08), transparent 60%),
        radial-gradient(ellipse 50% 35% at 80% 90%, rgba(167, 139, 250, 0.07), transparent 60%),
        radial-gradient(ellipse 40% 25% at 90% 20%, rgba(251, 146, 60, 0.05), transparent 70%);
    pointer-events: none;
    animation: bg-drift 22s var(--ease-smooth) infinite alternate;
}

@keyframes bg-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-2%, 2%, 0) scale(1.05); }
}

.auth-view::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
}

.auth-grid {
    position: relative;
    z-index: 1;
    flex: 1;
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 56px);
    gap: clamp(24px, 5vw, 80px);
    align-items: center;
    overflow-y: auto;
}

.auth-hero {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 560px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hero-orb {
    width: 52px;
    height: 52px;
    border-radius: var(--r-lg);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.02em;
    color: #0a0b0e;
    background:
        linear-gradient(135deg, var(--accent-bright), var(--accent));
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 8px 24px -4px var(--accent-glow);
}

.brand-wordmark {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    margin: 0;
}

.auth-hero h2 {
    font-size: clamp(32px, 4vw, 48px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0;
    color: var(--text);
}

.auth-hero h2 em {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    color: var(--accent-bright);
    letter-spacing: -0.01em;
}

.auth-lede {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dim);
    margin: 0;
    max-width: 520px;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.metric-card {
    position: relative;
    padding: 16px 16px 16px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.metric-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.metric-dot {
    position: absolute;
    left: 16px;
    top: 20px;
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--dot, var(--accent));
    box-shadow: 0 0 12px var(--dot, var(--accent));
}

.metric-card strong {
    padding-left: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.metric-card span:not(.metric-dot) {
    padding-left: 12px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
}

.auth-hero-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.status-pulse {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent-glow);
    animation: pulse 2.2s var(--ease-smooth) infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(45, 212, 191, 0); }
    100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}

.auth-card {
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-card-inner {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
        var(--bg-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.auth-card-inner::before {
    content: "";
    position: absolute;
    top: 0; left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(45, 212, 191, 0.5), transparent);
}

.auth-switch {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-switch-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.guest-notice {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(45, 212, 191, 0.06), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(45, 212, 191, 0.18);
    border-radius: var(--r-md);
    align-items: flex-start;
    margin-bottom: 4px;
}

.guest-notice svg {
    width: 18px;
    height: 18px;
    color: var(--accent-bright);
    flex-shrink: 0;
    margin-top: 1px;
}

.guest-notice p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-soft);
}

.guest-notice strong {
    color: var(--accent-bright);
    font-weight: 700;
}

.switch-btn {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    border-radius: var(--r-sm);
    transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.switch-btn.is-active {
    color: var(--text);
    background: var(--bg-6);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stack label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stack label span {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-4);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

input::placeholder {
    color: var(--text-faint);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--border-focus);
    background: var(--bg-5);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.primary-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(180deg, var(--accent-bright), var(--accent-dim));
    color: #081413;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.005em;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: transform 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out), filter 0.2s var(--ease-out);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.18) inset,
        0 8px 20px -6px var(--accent-glow);
}

.primary-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 12px 28px -6px var(--accent-glow);
}

.primary-btn:active { transform: translateY(0); filter: brightness(0.95); }

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s var(--ease-out);
}

.primary-btn:hover svg { transform: translateX(3px); }

.auth-inline-notice {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
    min-height: 46px;
    display: flex;
    align-items: center;
}

.auth-foot {
    margin: 20px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

@media (max-width: 860px) {
    .auth-grid { grid-template-columns: 1fr; padding: 24px; gap: 32px; }
    .auth-hero { order: 2; }
    .auth-card { order: 1; }
}

/* ==========================================================================
   APP VIEW · Grid
   ========================================================================== */

.app-view {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr 260px;
    background: var(--bg-3);
    overflow: hidden;
}

.app-view:not(.has-room) .members-sidebar {
    display: none;
}

.app-view:not(.has-room) {
    grid-template-columns: 300px 1fr;
}

@media (max-width: 1100px) {
    .app-view,
    .app-view:not(.has-room) {
        grid-template-columns: 260px 1fr;
    }
    .members-sidebar { display: none !important; }
}

/* ==========================================================================
   Column 1 · Rooms sidebar
   ========================================================================== */

.rooms-sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.sidebar-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

.session-profile {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 12px;
    color: var(--text-soft);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn-ghost {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    color: var(--text-dim);
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    flex-shrink: 0;
}

.icon-btn-ghost svg { width: 16px; height: 16px; }
.icon-btn-ghost:hover { background: var(--bg-4); color: var(--text); }
#logoutBtn.icon-btn-ghost:hover {
    background: rgba(251, 113, 133, 0.1);
    color: var(--rose);
}

.sidebar-search {
    position: relative;
    margin: 12px 12px 4px;
}

.sidebar-search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 13px;
    transition: all 0.2s var(--ease-out);
}

.sidebar-search input:focus {
    background: var(--bg-5);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-5);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    pointer-events: none;
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 8px 8px;
}

.sidebar-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 6px;
    user-select: none;
}

.section-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.section-label .caret {
    width: 12px;
    height: 12px;
    transition: transform 0.2s var(--ease-out);
}

.section-add-btn {
    width: 22px;
    height: 22px;
    border-radius: var(--r-xs);
    display: grid;
    place-items: center;
    color: var(--text-dim);
    transition: all 0.2s var(--ease-out);
}

.section-add-btn svg { width: 14px; height: 14px; }
.section-add-btn:hover {
    background: var(--bg-4);
    color: var(--accent);
}

/* Room creator drawer */
.room-creator {
    margin: 4px 4px 12px;
}
.room-creator > summary { display: none; }
.room-creator:not([open]) { display: none; }

.create-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: linear-gradient(180deg, rgba(45, 212, 191, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
}

.create-form-head h3 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.create-form-head p {
    margin: 0;
    font-size: 11px;
    color: var(--text-dim);
}

.create-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.create-form label span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}
.create-form input, .create-form select {
    font-size: 13px;
    padding: 8px 10px;
}
.create-form .primary-btn { padding: 9px 14px; font-size: 13px; }

/* Room list */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 2px;
}

.room-item {
    position: relative;
    display: block;
    padding: 0;
    border-radius: var(--r-md);
    cursor: default;
    transition: background 0.15s var(--ease-out);
    min-height: 42px;
}

.room-item-clickable {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 7px 32px 7px calc(10px + var(--room-indent, 0px)); /* leave room for kebab on right */
    border-radius: var(--r-md);
    cursor: pointer;
    min-height: 42px;
}

.room-item:hover {
    background: var(--bg-4);
}

.room-item.is-active {
    background: var(--bg-5);
}

.room-item.is-active::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 2px;
}

.room-item.is-lobby {
    background: linear-gradient(90deg, rgba(45, 212, 191, 0.06), transparent 80%);
}

.room-item.is-lobby:hover {
    background: linear-gradient(90deg, rgba(45, 212, 191, 0.1), var(--bg-4) 80%);
}

.room-item.is-lobby.is-active {
    background: linear-gradient(90deg, rgba(45, 212, 191, 0.14), var(--bg-5) 80%);
}

.room-item.is-lobby .room-title::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    margin-right: 6px;
    vertical-align: middle;
}

.room-item.is-private .room-title::after {
    content: "🔒";
    font-size: 9px;
    margin-left: 6px;
    opacity: 0.7;
    vertical-align: middle;
}

.room-item.is-nested .room-item-clickable::before {
    content: "";
    position: absolute;
    left: calc(14px + var(--room-indent, 0px) - 10px);
    top: 9px;
    bottom: 9px;
    width: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(45, 212, 191, 0.12));
    border-radius: 999px;
}

.room-item.is-nested .room-title-wrap::before {
    content: "";
    width: 10px;
    height: 1px;
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
    flex-shrink: 0;
}

.room-item.is-channel .room-title {
    font-weight: 700;
}

.room-item.is-nested .room-title {
    font-size: 13px;
}

/* Kebab menu (3-dot) inside each room item — revealed on hover */
.room-kebab {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    background: var(--bg-5);
    border: 1px solid var(--border);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s var(--ease-out), color 0.15s var(--ease-out), background 0.15s var(--ease-out);
    z-index: 2;
}
.room-kebab svg { width: 14px; height: 14px; }
.room-item:hover .room-kebab,
.room-item.is-menu-open .room-kebab {
    opacity: 1;
    pointer-events: auto;
}
.room-kebab:hover {
    color: var(--text);
    background: var(--bg-6);
    border-color: var(--border-strong);
}
.room-item.is-menu-open .room-kebab {
    color: var(--accent);
    border-color: rgba(45, 212, 191, 0.3);
    background: var(--accent-wash);
}

/* Floating context menu */
.room-menu {
    position: fixed;
    min-width: 180px;
    padding: 4px;
    background: var(--bg-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    animation: modal-in 0.12s var(--ease-out);
}

.room-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    background: transparent;
    border: none;
    transition: background 0.12s var(--ease-out), color 0.12s var(--ease-out);
}
.room-menu-item:hover {
    background: var(--bg-5);
    color: var(--text);
}
.room-menu-item.warn { color: var(--rose); }
.room-menu-item.warn:hover {
    background: rgba(251, 113, 133, 0.1);
    color: var(--rose);
}
.room-menu-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}
.room-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 2px;
}

/* Checkbox row in forms */
.checkbox-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    align-items: flex-start;
    padding: 10px 12px;
    background: var(--bg-5);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.checkbox-row > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.checkbox-row strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.checkbox-row span {
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.5;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* Invite search input */
.invite-search-wrap {
    position: relative;
}
.invite-search-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}
.invite-search-wrap input {
    padding-left: 36px;
}

.room-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

.room-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.room-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.room-title-wrap {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.room-item.is-active .room-title {
    color: var(--text);
    font-weight: 700;
}

.room-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px 2px 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    flex-shrink: 0;
    line-height: 1.2;
    transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.room-count svg {
    width: 11px;
    height: 11px;
    opacity: 0.85;
}

.room-count.is-live {
    color: var(--accent-bright);
    background: var(--accent-wash);
    border-color: rgba(45, 212, 191, 0.24);
}

.room-item.is-active .room-count.is-live {
    color: var(--accent-bright);
    background: rgba(45, 212, 191, 0.18);
    border-color: rgba(45, 212, 191, 0.36);
}

.room-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none; /* hidden by default; keep room item tight */
}

.room-meta-line {
    display: flex;
    gap: 8px;
    font-size: 10.5px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: lowercase;
}

.room-meta-line span:first-child {
    display: inline-block;
    padding: 1px 7px;
    background: var(--bg-4);
    border-radius: var(--r-full);
    font-weight: 500;
}

.room-item.is-active .room-meta-line span:first-child {
    background: var(--accent-wash);
    color: var(--accent-bright);
}

.sidebar-footer {
    padding: 8px 14px 14px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.notice {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    padding: 6px 10px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty state */
.empty-state {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.6;
}

.empty-state-chat {
    margin: auto;
    padding: 48px 24px;
    max-width: 320px;
}

.empty-state-orb {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    color: var(--accent);
}

.empty-state-orb svg { width: 28px; height: 28px; }

.empty-state-chat h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.empty-state-chat p {
    margin: 0;
    font-size: 13px;
    color: var(--text-dim);
}

/* ==========================================================================
   Column 2 · Chat area
   ========================================================================== */

.chat-area {
    background: var(--bg-3);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    min-height: 56px;
    background: var(--bg-3);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    z-index: 2;
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header-avatar .avatar {
    width: 100%;
    height: 100%;
    border-radius: var(--r-md);
    font-size: 14px;
}

.chat-header-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-header-text h2 {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-topic {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.state-chip {
    padding: 4px 10px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    font-weight: 500;
    margin-right: 4px;
    white-space: nowrap;
}

.header-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    color: var(--text-dim);
    transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}

.header-icon-btn svg { width: 17px; height: 17px; }

.header-icon-btn:hover {
    background: var(--bg-4);
    color: var(--text);
}

.header-icon-btn.is-active {
    background: var(--accent-wash);
    color: var(--accent-bright);
    box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.22);
}

.header-icon-btn.is-off {
    background: rgba(248, 113, 113, 0.08);
    color: var(--danger);
}

.header-icon-btn.is-off:hover {
    background: rgba(248, 113, 113, 0.14);
    color: #fca5a5;
}

.header-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.header-icon-btn:disabled:hover {
    background: transparent;
    color: var(--text-dim);
}

/* Voice strip */
.voice-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    background: var(--bg-4);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}

.voice-text {
    flex: 1;
    min-width: 0;
}

.voice-latency-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 4px 9px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.voice-latency-chip.is-hidden {
    display: none;
}

.voice-latency-chip.is-good {
    border-color: rgba(34, 197, 94, 0.28);
    color: #22c55e;
}

.voice-latency-chip.is-mid {
    border-color: rgba(251, 191, 36, 0.32);
    color: var(--warning);
}

.voice-latency-chip.is-bad {
    border-color: rgba(251, 113, 133, 0.34);
    color: var(--rose);
}

.voice-settings-chip {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--bg-5);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.voice-settings-chip:hover {
    background: var(--accent-wash);
    border-color: var(--accent);
    color: var(--accent-bright);
    transform: translateY(-1px);
}

.voice-settings-chip.is-ptt {
    border-color: rgba(251, 191, 36, 0.32);
    color: var(--warning);
}

.voice-clear-chat-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: var(--r-full);
    border: 1px solid rgba(248, 113, 113, 0.28);
    background: rgba(248, 113, 113, 0.08);
    color: var(--danger);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), transform 0.16s var(--ease-out), opacity 0.16s var(--ease-out);
}

.voice-clear-chat-btn:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.16);
    border-color: rgba(248, 113, 113, 0.44);
    color: #fecaca;
    transform: translateY(-1px);
}

.voice-clear-chat-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.voice-strip.is-live {
    background: linear-gradient(90deg, var(--accent-wash), transparent 40%);
    color: var(--accent-bright);
}

.voice-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--text-faint);
    flex-shrink: 0;
}

.voice-strip.is-live .voice-dot {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

.voice-strip.is-warn { color: var(--warning); }
.voice-strip.is-warn .voice-dot { background: var(--warning); }

/* Message list */
.message-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 8px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    scroll-behavior: smooth;
}

.message-list:empty { display: flex; align-items: center; justify-content: center; }

.message-item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    column-gap: 2px;
    padding: 4px 18px 4px 0;
    margin-left: 0;
    position: relative;
    transition: background 0.1s var(--ease-out);
    align-items: start;
}

.message-item:hover {
    background: rgba(255, 255, 255, 0.018);
}

.message-item.is-first-in-group {
    margin-top: 10px;
    padding-top: 6px;
}

.message-avatar {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
    margin: 2px auto 0;
    justify-self: center;
    flex-shrink: 0;
    display: none; /* default: hidden (grouped), shown on first-in-group */
}

.message-item.is-first-in-group .message-avatar {
    display: grid;
}

.message-copy {
    min-width: 0;
    padding-right: 12px;
}

.message-meta {
    display: none;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 1px;
}

.message-item.is-first-in-group .message-meta {
    display: flex;
}

.message-meta strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--msg-name, var(--text));
    letter-spacing: -0.005em;
}

.message-meta span {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 400;
}

.message-copy p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-soft);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-item:not(.is-first-in-group) .message-copy {
    position: relative;
}

/* show timestamp on hover for grouped messages */
.message-item:not(.is-first-in-group) .message-copy::before {
    content: attr(data-time);
    position: absolute;
    left: -60px;
    top: 3px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s var(--ease-out);
    width: 52px;
    text-align: right;
    pointer-events: none;
}

.message-item:not(.is-first-in-group):hover .message-copy::before {
    opacity: 1;
}

/* Composer */
.composer {
    padding: 12px 18px 18px;
    background: var(--bg-3);
}

.composer-shell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px 12px;
    background: var(--bg-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.composer-shell:focus-within {
    border-color: var(--border-focus);
    background: var(--bg-5);
    box-shadow: 0 0 0 4px var(--accent-wash);
}

.composer-shell input {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text);
}

.composer-shell input:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.composer-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    color: var(--text-dim);
    transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out);
    flex-shrink: 0;
}

.composer-icon svg { width: 17px; height: 17px; }

.composer-icon:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.composer-send {
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    color: #081413;
    background: linear-gradient(135deg, var(--accent-bright), var(--accent));
    box-shadow: 0 2px 10px -2px var(--accent-glow);
    transition: transform 0.15s var(--ease-out), filter 0.15s var(--ease-out);
    flex-shrink: 0;
}

.composer-send svg { width: 16px; height: 16px; }

.composer-send:hover { transform: translateY(-1px); filter: brightness(1.05); }

.composer-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.7);
}

/* ==========================================================================
   Column 3 · Members sidebar
   ========================================================================== */

.members-sidebar {
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

.members-header .eyebrow {
    margin: 0 0 2px;
    font-size: 10px;
    letter-spacing: 0.14em;
}

.members-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.members-count {
    padding: 2px 9px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.member-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.member-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.member-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px 0;
}

.member-group-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.member-group-count {
    padding: 2px 8px;
    border-radius: var(--r-full);
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    font-size: 10px;
    font-family: var(--font-mono);
}

.member-group-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-group.is-offline .member-group-title {
    color: rgba(226, 232, 240, 0.62);
}

.member-group.is-offline .member-item {
    background: rgba(148, 163, 184, 0.04);
    border-color: rgba(148, 163, 184, 0.08);
}

.member-item {
    padding: 8px 10px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.018);
    border: 1px solid rgba(255, 255, 255, 0.035);
    transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
    position: relative;
}

.member-item:nth-child(even) {
    background: rgba(45, 212, 191, 0.035);
    border-color: rgba(45, 212, 191, 0.07);
}

.member-item:hover {
    background: var(--bg-4);
    border-color: var(--border-strong);
}

.member-header {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    align-items: center;
}

.member-avatar-button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    display: grid;
    place-items: center;
    cursor: zoom-in;
}

.member-avatar {
    width: 32px;
    height: 32px;
    position: relative;
    transition: transform 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out), filter 0.16s var(--ease-out);
}

.member-avatar-button:hover .member-avatar {
    transform: scale(1.08);
    filter: brightness(1.04);
    box-shadow: 0 10px 18px -14px rgba(15, 23, 42, 0.8);
}

.member-avatar-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--r-full);
}

.member-avatar::after {
    content: "";
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: var(--text-faint);
    border: 2px solid var(--bg-2);
    border-radius: var(--r-full);
}

.member-item .badge.is-accent + .member-avatar::after,
.member-item[data-online="1"] .member-avatar::after {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.member-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.member-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.member-title-wrap {
    min-width: 0;
    flex: 1;
}

.member-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.member-copy p {
    margin: 0;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: lowercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding-left: 42px;
}

.badge {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: lowercase;
    color: var(--text-dim);
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    letter-spacing: 0.02em;
}

.badge.is-accent {
    color: var(--accent-bright);
    background: var(--accent-wash);
    border-color: rgba(45, 212, 191, 0.24);
}

.badge.is-warn {
    color: var(--warning);
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.24);
}

.member-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    padding-left: 42px;
    flex-wrap: wrap;
}

.mini-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--r-sm);
    background: var(--bg-4);
    border: 1px solid var(--border);
    color: var(--text-soft);
    transition: all 0.15s var(--ease-out);
    cursor: pointer;
}

.mini-btn:hover {
    background: var(--bg-5);
    color: var(--text);
    border-color: var(--border-strong);
}

.mini-btn.warn {
    color: var(--rose);
    border-color: rgba(251, 113, 133, 0.2);
}

.mini-btn.warn:hover {
    background: rgba(251, 113, 133, 0.1);
    border-color: rgba(251, 113, 133, 0.4);
}

.mini-select {
    width: auto;
    min-width: 96px;
    padding: 4px 26px 4px 10px;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 700;
    background-color: var(--bg-4);
}

/* ==========================================================================
   Avatars (generic)
   ========================================================================== */

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: -0.01em;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg,
            hsl(var(--avatar-hue, 180), 62%, 58%),
            hsl(calc(var(--avatar-hue, 180) + 35), 62%, 40%));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.avatar.has-image {
    background: rgba(255, 255, 255, 0.04);
}

.avatar.has-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.room-avatar {
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.36) inset;
    background: rgba(7, 10, 20, 0.96);
    background-clip: padding-box;
}

.room-avatar.has-image {
    background: rgba(7, 10, 20, 0.98);
}

.room-avatar.has-image img {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    object-fit: contain;
    object-position: center center;
    transform: none;
}

.room-item.is-active .room-avatar,
.chat-header-avatar .room-avatar {
    border-color: rgba(45, 212, 191, 0.34);
}

.member-avatar,
.message-avatar {
    border-radius: var(--r-full);
}

.message-avatar { font-size: 13px; }

.member-avatar-preview-root {
    z-index: 1150;
}

.member-avatar-preview-card {
    position: relative;
    width: min(280px, calc(100vw - 28px));
    padding: 22px 20px 18px;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background:
        radial-gradient(circle at top, rgba(45, 212, 191, 0.12), transparent 46%),
        rgba(10, 14, 20, 0.96);
    box-shadow: 0 28px 80px rgba(2, 6, 23, 0.56);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.member-avatar-preview-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: var(--r-full);
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
    font-size: 16px;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.member-avatar-preview-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.member-avatar-preview-frame {
    width: 124px;
    height: 124px;
    display: grid;
    place-items: center;
}

.member-avatar-preview-media {
    width: 124px;
    height: 124px;
    font-size: 38px;
    box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.7);
}

.member-avatar-preview-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    text-align: center;
}

.member-avatar-preview-meta {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.avatar-uploader {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 12px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.avatar-uploader.compact {
    grid-template-columns: 56px minmax(0, 1fr);
}

.avatar-preview-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.avatar-preview {
    width: 52px;
    min-width: 52px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-preview .avatar {
    width: 52px;
    height: 52px;
    font-size: 14px;
}

.avatar-preview.is-room .avatar,
.avatar-preview .room-avatar {
    border-radius: var(--r-md);
}

.avatar-uploader.compact .avatar-preview,
.avatar-uploader.compact .avatar-preview .avatar {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    height: 48px;
}

.avatar-uploader-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.checkbox-row.compact-row {
    gap: 10px !important;
}

.checkbox-row.compact-row strong {
    display: block;
    margin-bottom: 2px;
}

@media (max-width: 640px) {
    .avatar-uploader,
    .avatar-uploader.compact {
        grid-template-columns: 1fr;
    }

    .avatar-preview-stack {
        flex-direction: row;
        align-items: center;
    }
}
/* Audio mount */
.audio-mount {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 1px; height: 1px;
    overflow: hidden;
}

/* ==========================================================================
   Settings Modal
   ========================================================================== */

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: modal-in 0.2s var(--ease-out);
}

@keyframes modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 6, 10, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: min(88vh, 820px);
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-rise 0.25s var(--ease-out);
}

@keyframes modal-rise {
    from { transform: translateY(8px) scale(0.985); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-card::before {
    content: "";
    position: absolute;
    top: 0; left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(45, 212, 191, 0.5), transparent);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-head .eyebrow {
    margin: 0 0 4px;
}

.modal-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.modal-tabs {
    display: flex;
    gap: 2px;
    padding: 10px 16px 0;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.modal-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
    white-space: nowrap;
}

.modal-tab svg {
    width: 15px;
    height: 15px;
}

.modal-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

.modal-tab::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    transform: scaleX(0);
    transition: transform 0.2s var(--ease-out);
}

.modal-tab.is-active {
    color: var(--text);
}

.modal-tab.is-active::after {
    transform: scaleX(1);
}

.modal-tab.is-hidden {
    display: none !important;
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-3);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
    animation: tab-fade 0.2s var(--ease-out);
}

@keyframes tab-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-group {
    padding: 16px 18px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-group + .settings-group {
    margin-top: 16px;
}

.settings-group h3 {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.settings-group label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-group label span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: -0.005em;
}

.read-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-5);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.field-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.field-value {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.toggle-row > div strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
    letter-spacing: -0.005em;
}

.toggle-row > div p {
    margin: 0;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
}

.toggle-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.toggle-state-label {
    min-width: 52px;
    text-align: right;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.toggle-btn {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: var(--r-full);
    background: var(--bg-6);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}

.toggle-btn .toggle-pill {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: var(--r-full);
    background: var(--text-dim);
    transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.toggle-btn[data-locked="1"] {
    background: var(--accent-wash);
    border-color: rgba(45, 212, 191, 0.4);
}

.toggle-btn[data-locked="1"] .toggle-pill {
    transform: translateX(20px);
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.danger-zone {
    border-color: rgba(248, 113, 113, 0.22) !important;
    background: rgba(248, 113, 113, 0.04) !important;
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-btn {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--danger);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    flex-shrink: 0;
}

.danger-btn:hover {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.5);
    color: var(--text);
}

.settings-hint {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.55;
}

.ptt-key-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background:
        radial-gradient(circle at top right, rgba(251, 191, 36, 0.1), transparent 34%),
        var(--bg-5);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
}

.ptt-key-picker-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.field-label-inline {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: -0.005em;
}

.ptt-help-card {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(251, 191, 36, 0.18);
    background: rgba(251, 191, 36, 0.07);
}

.ptt-help-card strong {
    color: var(--text);
    font-size: 12.5px;
}

.ptt-help-card span {
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.45;
}

.ptt-helper-download {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(34, 197, 94, 0.42);
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.98), rgba(22, 163, 74, 0.92));
    box-shadow: 0 14px 34px rgba(6, 78, 59, 0.26);
}

.ptt-helper-download-copy {
    display: grid;
    gap: 5px;
}

.ptt-helper-download-copy strong {
    color: #f3fff6;
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.ptt-helper-download-copy span {
    color: rgba(236, 253, 245, 0.96);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}


.ptt-helper-download-copy a {
    color: #ecfeff;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 800;
}

.ptt-helper-download-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.ptt-helper-download .mini-btn {
    white-space: nowrap;
    flex-shrink: 0;
    border-color: rgba(209, 250, 229, 0.34);
    background: rgba(240, 253, 244, 0.14);
    color: #f3fff6;
    font-weight: 800;
}

.ptt-helper-download .mini-btn:hover {
    background: rgba(240, 253, 244, 0.22);
    border-color: rgba(209, 250, 229, 0.56);
    color: #ffffff;
}

.ptt-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.ptt-preset-btn {
    min-height: 42px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-3);
    color: var(--text-soft);
    font-weight: 800;
    font-size: 12px;
    line-height: 1.1;
    cursor: pointer;
    transition: background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.ptt-preset-btn small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
}

.ptt-preset-btn:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: var(--bg-4);
    color: var(--text);
}

.ptt-preset-btn.is-active {
    border-color: var(--accent);
    background: var(--accent-wash);
    color: var(--accent-bright);
    box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.12);
}

.key-capture-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-3);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-soft);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    font-size: 13px;
    width: 100%;
}

.key-capture-btn:hover {
    background: var(--bg-4);
    border-color: var(--accent);
    color: var(--text);
}

.key-capture-btn.is-listening {
    border-style: solid;
    border-color: var(--border-focus);
    background: var(--accent-wash);
    color: var(--accent-bright);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
    animation: key-pulse 1.2s var(--ease-smooth) infinite;
}

@keyframes key-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12); }
    50%      { box-shadow: 0 0 0 8px rgba(45, 212, 191, 0.02); }
}

.key-capture-btn kbd {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    padding: 6px 14px;
    background: var(--bg-5);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text);
    min-width: 72px;
    text-align: center;
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.35),
        0 1px 0 rgba(255, 255, 255, 0.04);
}

.key-capture-btn.is-listening kbd {
    background: var(--accent);
    color: #081413;
    border-color: var(--accent-bright);
    box-shadow: 0 0 0 1px var(--accent-bright);
}

.key-capture-btn span {
    font-size: 12.5px;
    color: var(--text-muted);
    flex: 1;
}

.key-capture-btn.is-listening span {
    color: var(--accent-bright);
    font-weight: 600;
}

/* PTT status indicator in voice strip */
.voice-strip.is-ptt-armed .voice-dot {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.voice-strip.is-ptt-talking .voice-dot {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    animation: pulse 0.8s ease-in-out infinite;
}

@media (max-width: 720px) {
    .voice-strip {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .voice-settings-chip {
        margin-left: 18px;
    }

    .voice-latency-chip {
        margin-left: 18px;
    }

    .voice-clear-chat-btn {
        margin-left: 18px;
    }

    .ptt-preset-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.mini-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-5);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.mini-row .mini-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mini-row strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-row small {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.mini-row-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mini-row .avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
}

.mini-row[data-kind="ban"] {
    background: rgba(248, 113, 113, 0.05);
    border-color: rgba(248, 113, 113, 0.15);
}

.mini-row[data-kind="pending"] {
    background: rgba(251, 191, 36, 0.04);
    border-color: rgba(251, 191, 36, 0.18);
}

/* Responsive */
@media (max-width: 560px) {
    .modal-card { max-height: 95vh; }
    .modal-body { padding: 16px; }
    .modal-head { padding: 16px; }
    .modal-tabs { padding: 8px 8px 0; }
    .modal-tab { padding: 8px 10px 10px; }
    .mini-row { grid-template-columns: 30px 1fr; }
    .mini-row-actions { grid-column: 1 / -1; margin-top: 4px; }
}

/* ==========================================================================
   Responsive refinements
   ========================================================================== */

@media (max-width: 640px) {
    .chat-header-actions .state-chip { display: none; }
    .chat-header { padding: 10px 12px; }
    .composer { padding: 10px 12px 14px; }
    .message-list { padding: 12px 4px 12px 0; }
    .message-item { padding-right: 12px; grid-template-columns: 48px 1fr; }
}










