*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --border: rgba(255, 255, 255, 0.1);
    --text: #fafafa;
    --muted: #a1a1aa;
    --accent: #fafafa;
    --accent-2: #d4d4d8;
    --accent-glow: rgba(255, 255, 255, 0.12);
    --accent-on: #09090b;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 64px;
    --composer-h: 76px;
    --scrollbar-size: 6px;
    --scrollbar-thumb: rgba(255, 255, 255, 0.16);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
    --scrollbar-thumb-active: rgba(255, 255, 255, 0.38);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.messages,
.dm-section,
.members-section,
.sidebar-panels,
.sidebar-panel,
.mention-picker,
.emoji-grid,
.profile-modal-body,
.profile-body,
.profile-panel,
.auth-page,
.legal-main,
.admin-sidebar-nav,
.admin-main {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.messages::-webkit-scrollbar,
.dm-section::-webkit-scrollbar,
.members-section::-webkit-scrollbar,
.sidebar-panels::-webkit-scrollbar,
.sidebar-panel::-webkit-scrollbar,
.mention-picker::-webkit-scrollbar,
.emoji-grid::-webkit-scrollbar,
.profile-modal-body::-webkit-scrollbar,
.profile-body::-webkit-scrollbar,
.profile-panel::-webkit-scrollbar,
.auth-page::-webkit-scrollbar,
.legal-main::-webkit-scrollbar,
.admin-sidebar-nav::-webkit-scrollbar,
.admin-main::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

.messages::-webkit-scrollbar-track,
.dm-section::-webkit-scrollbar-track,
.members-section::-webkit-scrollbar-track,
.sidebar-panels::-webkit-scrollbar-track,
.sidebar-panel::-webkit-scrollbar-track,
.mention-picker::-webkit-scrollbar-track,
.emoji-grid::-webkit-scrollbar-track,
.profile-modal-body::-webkit-scrollbar-track,
.profile-body::-webkit-scrollbar-track,
.profile-panel::-webkit-scrollbar-track,
.auth-page::-webkit-scrollbar-track,
.legal-main::-webkit-scrollbar-track,
.admin-sidebar-nav::-webkit-scrollbar-track,
.admin-main::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb,
.dm-section::-webkit-scrollbar-thumb,
.members-section::-webkit-scrollbar-thumb,
.sidebar-panels::-webkit-scrollbar-thumb,
.sidebar-panel::-webkit-scrollbar-thumb,
.mention-picker::-webkit-scrollbar-thumb,
.emoji-grid::-webkit-scrollbar-thumb,
.profile-modal-body::-webkit-scrollbar-thumb,
.profile-body::-webkit-scrollbar-thumb,
.profile-panel::-webkit-scrollbar-thumb,
.auth-page::-webkit-scrollbar-thumb,
.legal-main::-webkit-scrollbar-thumb,
.admin-sidebar-nav::-webkit-scrollbar-thumb,
.admin-main::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.messages::-webkit-scrollbar-thumb:hover,
.dm-section::-webkit-scrollbar-thumb:hover,
.members-section::-webkit-scrollbar-thumb:hover,
.sidebar-panels::-webkit-scrollbar-thumb:hover,
.sidebar-panel::-webkit-scrollbar-thumb:hover,
.mention-picker::-webkit-scrollbar-thumb:hover,
.emoji-grid::-webkit-scrollbar-thumb:hover,
.profile-modal-body::-webkit-scrollbar-thumb:hover,
.profile-body::-webkit-scrollbar-thumb:hover,
.profile-panel::-webkit-scrollbar-thumb:hover,
.auth-page::-webkit-scrollbar-thumb:hover,
.legal-main::-webkit-scrollbar-thumb:hover,
.admin-sidebar-nav::-webkit-scrollbar-thumb:hover,
.admin-main::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
}

.messages::-webkit-scrollbar-thumb:active,
.dm-section::-webkit-scrollbar-thumb:active,
.members-section::-webkit-scrollbar-thumb:active,
.sidebar-panels::-webkit-scrollbar-thumb:active,
.sidebar-panel::-webkit-scrollbar-thumb:active,
.mention-picker::-webkit-scrollbar-thumb:active,
.emoji-grid::-webkit-scrollbar-thumb:active,
.profile-modal-body::-webkit-scrollbar-thumb:active,
.profile-body::-webkit-scrollbar-thumb:active,
.profile-panel::-webkit-scrollbar-thumb:active,
.auth-page::-webkit-scrollbar-thumb:active,
.legal-main::-webkit-scrollbar-thumb:active,
.admin-sidebar-nav::-webkit-scrollbar-thumb:active,
.admin-main::-webkit-scrollbar-thumb:active {
    background-color: var(--scrollbar-thumb-active);
}

.messages::-webkit-scrollbar-corner,
.dm-section::-webkit-scrollbar-corner,
.members-section::-webkit-scrollbar-corner,
.sidebar-panels::-webkit-scrollbar-corner {
    background: transparent;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.03), transparent 55%),
        radial-gradient(ellipse 60% 40% at 50% 100%, rgba(255, 255, 255, 0.02), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100dvh;
    max-height: 100dvh;
}

/* ── Accessibility & SEO helpers ── */
.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;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--accent-on);
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 16px;
}

.noscript-banner {
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 300;
    width: 100%;
    padding: 14px 20px;
    background: #7f1d1d;
    color: #fecaca;
    text-align: center;
    font-size: 0.9rem;
}

/* ── Auth landing page ── */
.auth-page {
    --landing-bg: #09090b;
    --landing-surface: #111113;
    --landing-border: rgba(255, 255, 255, 0.1);
    --landing-muted: #a1a1aa;
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--landing-bg);
    color: #fafafa;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.auth-page.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px clamp(20px, 4vw, 48px);
    border-bottom: 1px solid var(--landing-border);
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 2;
}

.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.landing-logo {
    display: block;
    height: 44px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}

.landing-logo-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--landing-border);
    border-radius: 8px;
    background: var(--landing-surface);
    color: #fafafa;
    flex-shrink: 0;
}

.landing-logo-mark svg { width: 20px; height: 20px; }

.landing-header-link {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--landing-muted);
    text-decoration: none;
    padding: 8px 14px;
    border: 1px solid var(--landing-border);
    border-radius: 8px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.landing-header-link:hover {
    color: #fafafa;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
}

.landing-main {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px);
    gap: clamp(32px, 5vw, 72px);
    align-items: start;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 48px);
}

.landing-intro {
    padding-top: 12px;
    max-width: 560px;
}

.landing-kicker {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--landing-muted);
    margin-bottom: 18px;
}

.landing-headline {
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.12;
    margin-bottom: 20px;
}

.landing-lead {
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--landing-muted);
    margin-bottom: 36px;
    max-width: 48ch;
}

.landing-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--landing-border);
}

.landing-features li {
    display: grid;
    gap: 4px;
    padding: 18px 0;
    border-bottom: 1px solid var(--landing-border);
}

.landing-feature-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.landing-feature-desc {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--landing-muted);
}

.auth-panel {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12px;
}

.auth-card {
    width: 100%;
    padding: 28px 26px 30px;
    background: var(--landing-surface);
    border: 1px solid var(--landing-border);
    border-radius: 12px;
}

.auth-card-header {
    margin-bottom: 22px;
}

.auth-card-title {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.auth-card-subtitle {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--landing-muted);
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--landing-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 22px;
}

.auth-tab {
    padding: 11px 14px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--landing-muted);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-tab + .auth-tab {
    border-left: 1px solid var(--landing-border);
}

.auth-tab svg { width: 16px; height: 16px; flex-shrink: 0; }

.auth-tab.active {
    background: rgba(255, 255, 255, 0.06);
    color: #fafafa;
}

.landing-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px clamp(20px, 4vw, 48px) calc(18px + var(--safe-bottom));
    border-top: 1px solid var(--landing-border);
    font-size: 0.8rem;
    color: var(--landing-muted);
}

.landing-footer-copy {
    margin: 0;
}

.landing-footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.landing-footer-links a {
    color: var(--landing-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.landing-footer-links a:hover {
    color: #fafafa;
}

.cookie-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + var(--safe-bottom));
    z-index: 120;
    max-width: 720px;
    margin: 0 auto;
    animation: fadeSlideIn 0.28s ease;
}

.cookie-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--landing-border);
    border-radius: 14px;
    background: rgba(17, 17, 19, 0.96);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

.cookie-banner-text {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--landing-muted);
}

.cookie-banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.cookie-banner-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fafafa;
    text-decoration: none;
    white-space: nowrap;
}

.cookie-banner-link:hover {
    text-decoration: underline;
}

.cookie-banner-accept {
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: #09090b;
    background: #fafafa;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.cookie-banner-accept:hover {
    background: #fff;
}

@media (max-width: 640px) {
    .cookie-banner-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .cookie-banner-actions {
        justify-content: flex-end;
    }
}

body.age-gate-open {
    overflow: hidden;
}

.age-gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(9, 9, 11, 0.92);
    backdrop-filter: blur(8px);
}

.age-gate-overlay[hidden] {
    display: none;
}

.age-gate-modal {
    width: min(100%, 420px);
    padding: 28px 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #18181b 0%, #111113 100%);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.age-gate-title {
    margin: 0 0 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fafafa;
}

.age-gate-message,
.age-gate-deny {
    margin: 0 0 20px;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--landing-muted);
}

.age-gate-deny {
    color: #fca5a5;
}

.age-gate-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.age-gate-actions .btn-secondary,
.age-gate-actions .btn-primary {
    flex: 1;
    min-width: 0;
}

@media (max-width: 480px) {
    .age-gate-actions {
        flex-direction: column-reverse;
    }
}

.auth-form .field-icon-wrap { margin-top: 12px; }
.auth-form .field-icon-wrap:first-child { margin-top: 0; }

.auth-page .field-icon-wrap input,
.auth-page .field-icon-wrap textarea,
.auth-page .field-icon-wrap select {
    background: #0c0c0e;
    border-color: var(--landing-border);
    border-radius: 8px;
}

.auth-page .field-icon-wrap input:focus,
.auth-page .field-icon-wrap textarea:focus,
.auth-page .field-icon-wrap select:focus {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.auth-password-wrap {
    position: relative;
}

.auth-password-wrap input {
    padding-right: 44px;
}

.auth-toggle-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: var(--landing-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

.auth-toggle-pw:hover {
    color: #fafafa;
    background: rgba(255, 255, 255, 0.05);
}

.auth-toggle-pw svg { width: 18px; height: 18px; }

.auth-error {
    padding: 11px 14px;
    margin-bottom: 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 0.85rem;
    line-height: 1.4;
}

.auth-footer-hint {
    text-align: center;
    margin-top: 22px;
    font-size: 0.75rem;
    color: var(--landing-muted);
}

.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--landing-muted);
    cursor: pointer;
}

.auth-terms input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #fafafa;
}

.auth-terms a {
    color: #fafafa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-terms a:hover {
    color: #fff;
}

html:has(body.legal-page) {
    height: auto;
    overflow: auto;
}

body.legal-page {
    --landing-bg: #09090b;
    --landing-surface: #111113;
    --landing-border: rgba(255, 255, 255, 0.1);
    --landing-muted: #a1a1aa;
    height: auto;
    min-height: 100%;
    overflow: auto;
    background: var(--landing-bg);
    color: #fafafa;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.legal-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px clamp(20px, 4vw, 48px) 72px;
}

.legal-kicker {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--landing-muted);
}

.legal-main h1 {
    margin: 0 0 8px;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    line-height: 1.15;
}

.legal-updated {
    margin: 0 0 28px;
    font-size: 0.85rem;
    color: var(--landing-muted);
}

.legal-main h2 {
    margin: 28px 0 10px;
    font-size: 1.05rem;
}

.legal-main p,
.legal-main li,
.legal-content p,
.legal-content li {
    color: var(--landing-muted);
    line-height: 1.65;
}

.legal-content h2,
.legal-content h3 {
    margin: 28px 0 10px;
    font-size: 1.05rem;
    color: #fafafa;
}

.legal-content h3 {
    font-size: 0.95rem;
}

.legal-content ul,
.legal-content ol {
    margin: 0;
    padding-left: 1.2rem;
}

.legal-content li + li {
    margin-top: 8px;
}

.legal-content a {
    color: #fafafa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-content a:hover {
    color: #fff;
}

.legal-main ul {
    margin: 0;
    padding-left: 1.2rem;
}

.legal-main li + li {
    margin-top: 8px;
}

.legal-links {
    margin-top: 32px;
}

.legal-main a {
    color: #fafafa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-main a:hover {
    color: #fff;
}

.auth-page .btn-primary {
    background: #fafafa;
    color: #09090b;
    box-shadow: none;
    border-radius: 8px;
}

.auth-page .btn-primary:hover {
    background: #fff;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    width: 100%;
    margin-top: 16px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-on);
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    box-shadow: none;
}

.btn-primary:hover { background: #fff; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-primary span { flex: 1; text-align: center; }

/* ── Icon system ── */
.ui-icon {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    color: currentColor;
}

.ui-icon svg { width: 18px; height: 18px; display: block; }
.ui-icon.sm svg { width: 15px; height: 15px; }

.field-icon-wrap {
    position: relative;
    margin-top: 10px;
}

.field-icon-wrap:first-child { margin-top: 0; }

.field-icon-wrap .field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
    z-index: 1;
    display: grid;
    place-items: center;
}

.field-icon-wrap .field-icon svg { width: 16px; height: 16px; }

.field-icon-wrap--top .field-icon {
    top: 14px;
    transform: none;
}

.field-icon-wrap input,
.field-icon-wrap textarea,
.field-icon-wrap select,
.auth-form .field-icon-wrap input {
    width: 100%;
    padding: 13px 14px 13px 40px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field-icon-wrap textarea {
    resize: vertical;
    min-height: 80px;
}

.field-icon-wrap select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8ba3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
}

.field-icon-wrap input:focus,
.field-icon-wrap textarea:focus,
.field-icon-wrap select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-icon-wrap.auth-password-wrap input {
    padding-right: 44px;
}

.icon-action-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.icon-action-btn svg { width: 18px; height: 18px; }

.icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
}

.icon-action-btn.primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-on);
    box-shadow: none;
}

.icon-action-btn.primary:hover {
    background: #fff;
    transform: translateY(-1px);
}

.icon-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.icon-action-btn.sm {
    width: 36px;
    height: 36px;
}

.icon-action-btn.sm svg { width: 16px; height: 16px; }

.section-icon-title,
.section-icon-head {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--muted);
}

.section-icon-title svg,
.section-icon-head svg {
    width: 16px;
    height: 16px;
}

.section-icon-title {
    font-size: inherit;
    font-weight: 600;
}

.section-icon-head {
    font-size: inherit;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.palette-head { margin-top: 16px; }

.header-stats,
.header-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}





/* ── Sidebar ── */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    min-height: var(--header-h);
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.user-chip:hover { background: rgba(255, 255, 255, 0.05); }

.avatar {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.avatar.has-image {
    background: var(--surface-2) !important;
    display: block;
    padding: 0;
    line-height: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: inherit;
}

.user-meta { min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { display: block; font-size: 0.75rem; color: var(--muted); }

.user-status.connected { color: var(--success); }
.user-status.disconnected { color: var(--danger); }

.sidebar-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.sidebar-tab svg { width: 18px; height: 18px; }

.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
}

.tab-badge {
    position: absolute;
    top: 4px;
    right: 10px;
    background: var(--accent);
    color: var(--accent-on);
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 99px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
    line-height: 1.3;
}

.sidebar-panels {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.logout-btn {
    flex: 1;
    width: auto;
    height: 44px;
}

.sidebar-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.sidebar-panel[hidden] {
    display: none !important;
}

.sidebar-section {
    padding: 16px 14px;
    flex-shrink: 0;
}

.dm-section {
    flex: 0 0 auto;
    min-height: 0;
}

.blocked-section {
    flex-shrink: 0;
    padding: 10px 14px calc(10px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.14);
}

.blocked-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.blocked-section-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
}

.blocked-section-title svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.blocked-section-chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.blocked-section-toggle[aria-expanded="true"] .blocked-section-chevron {
    transform: rotate(180deg);
}

.blocked-panel {
    margin-top: 8px;
}

.blocked-empty {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 4px 2px 2px;
}

.blocked-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.blocked-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.blocked-item .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.72rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.blocked-item-name {
    flex: 1;
    min-width: 0;
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blocked-unblock-btn {
    flex-shrink: 0;
    padding: 6px 10px;
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: 8px;
    background: transparent;
    color: #4ade80;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.blocked-unblock-btn:hover {
    background: rgba(34, 197, 94, 0.1);
}

.profile-own-tools {
    padding-top: 4px;
}

.profile-own-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.profile-own-link:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.14);
}

.profile-own-link svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

.profile-own-link-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    font-size: 0.72rem;
    font-weight: 700;
}

.dm-empty {
    display: grid;
    place-items: center;
    padding: 28px 10px;
    color: var(--muted);
    opacity: 0.55;
}

.dm-empty svg { width: 36px; height: 36px; }

.dm-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.dm-row {
    display: flex;
    align-items: stretch;
    gap: 2px;
    position: relative;
}

.dm-row:has(.dm-menu-dropdown.open) {
    z-index: 2;
}

.dm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.dm-item:hover { background: rgba(255, 255, 255, 0.04); }
.dm-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.dm-item .avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.dm-item .avatar { width: 40px; height: 40px; font-size: 0.8rem; border-radius: 12px; flex-shrink: 0; }

.avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.avatar-online-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.55);
    pointer-events: none;
}

.dm-item-body { flex: 1; min-width: 0; }

.dm-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.dm-item-name {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-item-time { font-size: 0.7rem; color: var(--muted); flex-shrink: 0; }

.dm-row-menu {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.dm-menu-trigger {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.dm-menu-trigger:hover,
.dm-menu-trigger:focus-visible,
.dm-row:hover .dm-menu-trigger {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.dm-menu-trigger svg {
    width: 16px;
    height: 16px;
}

.dm-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 168px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 20;
}

.dm-menu-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dm-menu-item {
    width: 100%;
    display: block;
    padding: 9px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.dm-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.dm-menu-item.is-danger {
    color: #fca5a5;
}

.dm-menu-item.is-success {
    color: #4ade80;
}

.dm-item-preview {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-item-preview.unread { color: var(--text); font-weight: 500; }

.dm-unread {
    background: var(--accent);
    color: var(--accent-on);
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 99px;
    font-weight: 700;
    flex-shrink: 0;
}



.header-profile-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 12px;
    transition: opacity 0.15s;
}

.header-profile-btn:hover { opacity: 0.85; }

.header-avatar { width: 36px; height: 36px; font-size: 0.75rem; border-radius: 11px; }

.sidebar-section h2 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: var(--accent);
    color: var(--accent-on);
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 99px;
    font-weight: 700;
}

.room-list { display: flex; flex-direction: column; gap: 4px; }

.room-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.room-btn:hover { background: rgba(255,255,255,0.04); }
.room-btn.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.room-btn .room-icon { font-size: 1.1rem; flex-shrink: 0; }

.room-btn .room-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-btn .room-count {
    font-size: 0.65rem;
    min-width: 22px;
    padding: 2px 7px;
    text-align: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    color: var(--muted);
}

.room-btn.active .room-count {
    background: var(--accent);
    color: var(--accent-on);
}

.members-section { flex: 0 0 auto; }

.member-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    animation: fadeSlideIn 0.25s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: inherit;
    font: inherit;
    transition: background 0.15s;
}

.member-item:hover { background: rgba(255, 255, 255, 0.05); }

.member-item .avatar { width: 32px; height: 32px; font-size: 0.7rem; border-radius: 10px; }
.member-item .member-name-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.member-item .member-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-item .member-name-wrap .level-pill {
    flex-shrink: 0;
    transform: scale(0.95);
    transform-origin: center;
}

.icon-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.icon-btn:hover { background: rgba(255,255,255,0.06); }
.icon-btn svg { width: 20px; height: 20px; }

.sidebar-close { display: none; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    backdrop-filter: blur(4px);
}

/* ── Main chat ── */
.chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(20px);
    min-height: var(--header-h);
    flex-shrink: 0;
}

.menu-btn { display: none; }

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h1,
.chat-room-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
}
.chat-header-info p { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.header-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: opacity 0.25s, border-color 0.25s;
}

.header-logo--image {
    width: auto;
    height: 48px;
    max-width: min(200px, 38vw);
    min-width: 48px;
    padding: 0;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.header-logo--image img {
    display: block;
    height: 48px;
    width: auto;
    max-width: min(200px, 38vw);
    object-fit: contain;
}

.header-logo-mark {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: var(--text);
}

.header-logo-mark svg {
    width: 20px;
    height: 20px;
}

.header-logo.connected { opacity: 1; }

.header-logo:not(.header-logo--image).connected {
    border-color: rgba(255, 255, 255, 0.12);
}

.header-logo.disconnected { opacity: 0.7; }

.header-logo:not(.header-logo--image).disconnected {
    border-color: rgba(239, 68, 68, 0.35);
}

/* ── Messages ── */
.messages-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 14px 8px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.scroll-down-btn {
    position: absolute;
    right: 16px;
    bottom: 14px;
    z-index: 4;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(18, 18, 28, 0.94);
    color: var(--text);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.15s, border-color 0.15s, transform 0.15s, opacity 0.15s;
}

.scroll-down-btn:hover {
    background: rgba(28, 28, 40, 0.98);
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}

.scroll-down-btn svg {
    width: 18px;
    height: 18px;
}

.msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeSlideIn 0.2s ease;
}

.msg.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg .avatar { width: 34px; height: 34px; font-size: 0.7rem; border-radius: 10px; margin-top: 2px; }

.msg-body { min-width: 0; }

.msg-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.75rem;
}

.msg.self .msg-meta { flex-direction: row-reverse; }

.msg-author {
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    font-size: inherit;
    transition: color 0.15s;
}

.msg-author:hover { color: var(--accent); }
.msg-time { color: var(--muted); }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.45;
    word-break: break-word;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.msg.self .msg-bubble {
    background: #fafafa;
    color: #09090b;
    border-color: rgba(255, 255, 255, 0.2);
}

.msg.self .msg-mention {
    background: rgba(9, 9, 11, 0.08);
    color: #09090b;
}

.msg.self .msg-mention:hover {
    background: rgba(9, 9, 11, 0.14);
    color: #09090b;
}

.msg.mentioned-you {
    max-width: 90%;
}

.msg.mentioned-you .msg-bubble {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(16, 185, 129, 0.14));
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15), 0 8px 24px rgba(34, 197, 94, 0.12);
}

.msg.mentioned-you.mention-flash .msg-bubble {
    animation: mentionPulse 1.2s ease;
}

.msg-mentioned-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #86efac;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.35);
    padding: 2px 7px;
    border-radius: 999px;
}

.msg-mention {
    display: inline;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #d4d4d8;
    font: inherit;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
}

.msg-mention:hover {
    background: rgba(255, 255, 255, 0.28);
    color: #fafafa;
}

.msg-mention--you {
    background: rgba(34, 197, 94, 0.22);
    color: #86efac;
}

.msg-mention--you:hover {
    background: rgba(34, 197, 94, 0.32);
    color: #bbf7d0;
}

@keyframes mentionPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15), 0 8px 24px rgba(34, 197, 94, 0.12); }
    50% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35), 0 8px 28px rgba(34, 197, 94, 0.2); }
}

.msg.system {
    align-self: center;
    max-width: 100%;
}

.msg.system .msg-bubble {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.78rem;
    padding: 4px 0;
    text-align: center;
}

.msg.system-ephemeral {
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.msg.system-ephemeral.msg-ephemeral-out {
    opacity: 0;
    transform: translateY(-4px);
}

.msg.system-info .msg-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    max-width: min(520px, 100%);
    margin: 4px auto 0;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    color: #fafafa;
    font-size: 0.84rem;
    line-height: 1.45;
    text-align: center;
}

.msg-system-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #d4d4d8;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.typing-bar {
    padding: 6px 18px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--muted);
    flex-shrink: 0;
}

.typing-dots { display: flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px;
    background: var(--muted);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

.msg-bubble.has-image {
    padding: 6px;
    overflow: hidden;
    width: fit-content;
    max-width: 100%;
}

.msg-caption {
    padding: 8px 8px 4px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.msg-image-frame {
    display: block;
    width: 220px;
    height: 165px;
    max-width: 100%;
    padding: 0;
    border: none;
    font: inherit;
    text-align: left;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    background: rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s, transform 0.15s;
}

.msg-image-frame:hover {
    opacity: 0.92;
    transform: scale(1.01);
}

.msg-image-frame:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.msg-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.msg-bubble.emoji-only {
    font-size: 2rem;
    line-height: 1.2;
    padding: 8px 14px;
    background: transparent;
    border: none;
}

.msg.self .msg-bubble.emoji-only {
    background: transparent;
    border: none;
}

.mention-picker {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: calc(100% - 4px);
    max-height: 220px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(16, 16, 26, 0.96);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 30;
}

.mention-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.mention-picker-item .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.62rem;
    border-radius: 8px;
    flex-shrink: 0;
}

.mention-picker-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.mention-picker-item:hover,
.mention-picker-item.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
}

.mention-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(16, 16, 26, 0.95);
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    animation: fadeSlideIn 0.2s ease;
}

.mention-toast .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.7rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.mention-toast-body { min-width: 0; flex: 1; }

.mention-toast-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #86efac;
}

.mention-toast-preview {
    margin-top: 3px;
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-toast-close {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
}

.mention-toast.leaving {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s;
}

.admin-clear-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(16, 16, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    animation: fadeSlideIn 0.2s ease;
}

.admin-clear-toast.visible { opacity: 1; }

.admin-clear-toast.leaving {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s;
}

.admin-clear-icon { font-size: 1.1rem; }

.admin-clear-body {
    font-size: 0.84rem;
    color: var(--text);
}

/* ── Composer ── */
.composer {
    position: relative;
    padding: 12px 18px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.image-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: fadeSlideIn 0.2s ease;
}

.image-preview-thumb {
    position: relative;
    flex-shrink: 0;
}

.image-preview-thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}

.preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    background: var(--danger);
    border: 2px solid var(--bg);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    padding: 0;
}

.preview-remove svg { width: 12px; height: 12px; }

.image-preview-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.composer-inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tool-btn {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.tool-btn:hover,
.tool-btn.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border);
}

.tool-btn svg { width: 20px; height: 20px; }

.tool-btn.uploading {
    opacity: 0.5;
    pointer-events: none;
}

.tool-btn.is-locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.tool-btn.is-locked:hover {
    color: var(--muted);
    background: transparent;
    border-color: transparent;
}

.composer-inner:focus-within {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    outline: none;
    padding: 6px 0;
}

.send-btn {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    color: var(--accent-on);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, background 0.15s;
    flex-shrink: 0;
}

.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: #fff; transform: scale(1.05); }
.send-btn svg { width: 18px; height: 18px; }

/* ── Emoji picker ── */
.emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 18px;
    left: auto;
    width: min(360px, calc(100% - 36px));
    max-width: 360px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
    z-index: 30;
    animation: fadeSlideIn 0.2s ease;
    overflow: hidden;
}

.emoji-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

.emoji-picker-title svg { width: 18px; height: 18px; display: block; }

.emoji-close {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
}

.emoji-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.emoji-close svg { width: 16px; height: 16px; }

.emoji-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.emoji-tabs::-webkit-scrollbar { display: none; }

.emoji-tab {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.emoji-tab:hover { color: var(--text); }
.emoji-tab.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.emoji-item {
    width: 100%;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 1.35rem;
    cursor: pointer;
    transition: background 0.12s, transform 0.12s;
    padding: 0;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.15);
}

/* ── Lightbox ── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    animation: fadeIn 0.2s ease;
}

.lightbox[hidden] { display: none; }

.lightbox img {
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
}

.lightbox-close svg { width: 22px; height: 22px; }

/* ── Animations ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: min(300px, 85vw);
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: grid; }
    .sidebar-backdrop.visible { display: block; }
    .menu-btn { display: grid; }

    .messages { padding: 16px 14px 8px; }
    .msg { max-width: 92%; }
    .composer { padding: 10px 14px calc(10px + var(--safe-bottom)); }

    .emoji-picker { left: 14px; right: 14px; max-width: none; }
    .emoji-grid { grid-template-columns: repeat(7, 1fr); }
    .msg-image-frame {
        width: min(200px, 72vw);
        height: 150px;
    }
}

/* ── Toast notifications ── */
.toast-stack {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.dm-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    cursor: pointer;
    pointer-events: auto;
    animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transition: transform 0.2s, opacity 0.25s;
}

.dm-toast:hover { transform: translateY(-2px); }

.dm-toast.leaving {
    opacity: 0;
    transform: translateY(-12px);
}

.dm-toast .avatar {
    width: 38px;
    height: 38px;
    font-size: 0.75rem;
    border-radius: 11px;
    flex-shrink: 0;
}

.dm-toast-body { flex: 1; min-width: 0; }

.dm-toast-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.dm-toast-title span { color: var(--accent); }

.dm-toast-preview {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-toast-close {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.dm-toast-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.dm-toast-close svg { width: 14px; height: 14px; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Profile panel ── */
.profile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 55;
    backdrop-filter: blur(4px);
}

.profile-backdrop.visible { display: block; }

.profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 100vw);
    z-index: 60;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
    background: var(--surface);
    border-left: 1px solid var(--border);
    backdrop-filter: blur(24px);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}

.profile-panel.open { transform: translateX(0); }

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    min-height: var(--header-h);
    flex-shrink: 0;
}

.profile-header h2 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.profile-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.icon-btn--block {
    color: #fdba74;
}

.icon-btn--block:hover,
.icon-btn--block.is-active {
    background: rgba(249, 115, 22, 0.12);
    color: #fb923c;
}

.icon-btn--report {
    color: #fca5a5;
}

.icon-btn--report:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.profile-modal {
    width: min(420px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.profile-modal:modal,
.profile-modal[open] {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.profile-modal::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.profile-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.profile-modal h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.profile-modal-user {
    font-size: 0.88rem;
    color: var(--muted);
}

.profile-modal-hint {
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--muted);
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-field span {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.profile-field textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    resize: vertical;
    min-height: 96px;
}

.profile-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.profile-modal--danger h3 {
    color: #f87171;
}

.profile-modal-error {
    font-size: 0.8rem;
    color: #f87171;
}

.profile-field input,
.profile-field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
}

.profile-admin-section {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.profile-admin-status {
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--muted);
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
}

.profile-admin-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-admin-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.profile-admin-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.profile-admin-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.profile-admin-btn--danger {
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

.profile-admin-btn--danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.profile-admin-btn--success {
    border-color: rgba(34, 197, 94, 0.35);
    color: #4ade80;
}

.profile-admin-btn--success:hover {
    background: rgba(34, 197, 94, 0.1);
}

.profile-blocked-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    min-height: min(420px, 60vh);
    padding: 32px 20px;
}

.profile-blocked-icon {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.profile-blocked-icon svg {
    width: 34px;
    height: 34px;
}

.profile-blocked-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.profile-blocked-text {
    max-width: 280px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--muted);
}

.profile-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 14px 20px 18px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.profile-hero {
    text-align: center;
    margin-bottom: 24px;
}

.profile-avatar-wrap {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto 12px;
    flex-shrink: 0;
}

.profile-avatar-wrap--view {
    margin-bottom: 14px;
}

.profile-avatar-wrap--view::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    background: #6b7280;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 2;
}

.profile-avatar-wrap--view.is-online::after {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.55);
}

.profile-avatar-lg {
    width: 100%;
    height: 100%;
    border-radius: 24px;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.profile-avatar-lg.has-image {
    display: block;
    background: var(--surface-2) !important;
    padding: 0;
    line-height: 0;
}

.profile-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: inherit;
}

.avatar-upload-btn {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: var(--accent);
    border: 2px solid var(--surface);
    border-radius: 50%;
    color: var(--accent-on);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s, background 0.15s;
    z-index: 1;
}

.avatar-upload-btn:hover {
    transform: scale(1.06);
    background: #fff;
}

.avatar-upload-btn svg { width: 15px; height: 15px; }

.avatar-edit-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 2px;
    line-height: 1.2;
}

.btn-link:hover { text-decoration: underline; }
.btn-link:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-link.danger { color: #f87171; }

.profile-edit .profile-hero {
    margin-bottom: 4px;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.profile-status-text {
    margin-top: 6px;
    font-size: 0.88rem;
    color: var(--muted);
    min-height: 1.2em;
}

.profile-section {
    margin-bottom: 20px;
}

.profile-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 10px;
}

.profile-section-title svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.85;
}

.profile-section-title span {
    line-height: 1;
}

.profile-bio {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-detail {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.profile-detail-icon {
    color: var(--muted);
    margin-top: 2px;
}

.profile-detail-icon svg { width: 16px; height: 16px; display: block; }

.profile-detail-value {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text);
    word-break: break-word;
}

.profile-detail-value.multiline { white-space: pre-wrap; }

.profile-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px calc(14px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.profile-footer:not(:has(button:not([hidden]))) {
    display: none;
}

.profile-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-on);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.15s, background 0.15s;
}

.profile-action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.profile-action-btn:hover {
    transform: translateY(-1px);
    background: #fff;
}

.profile-action-btn--secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
}

.profile-action-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    box-shadow: none;
}

.profile-edit {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.profile-edit .field-icon-wrap {
    margin-top: 10px;
}

.profile-edit-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.profile-edit-section .profile-section-title {
    margin-bottom: 8px;
}

.profile-dm-hint {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.45;
    margin-bottom: 10px;
}

.dm-privacy-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-privacy-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.dm-privacy-option:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.06);
}

.dm-privacy-option.active {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.dm-privacy-option-title {
    font-size: 0.88rem;
    font-weight: 600;
}

.dm-privacy-option-desc {
    font-size: 0.76rem;
    color: var(--muted);
    line-height: 1.4;
}

.palette-head { margin-top: 16px; }

.profile-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 2px;
}

.profile-link-btn svg { width: 15px; height: 15px; }

.profile-link-btn:hover { text-decoration: underline; }
.profile-link-btn.danger { color: #f87171; }

.profile-edit-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.profile-edit-actions .btn-secondary,
.profile-edit-actions .btn-primary {
    flex: 1;
    margin-top: 0;
}

.field-hint {
    display: block;
    text-align: right;
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 4px;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}

.color-swatch:hover { transform: scale(1.1); }

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--accent);
}

#typingText {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-status .ui-icon { vertical-align: middle; }

.btn-secondary {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover { background: rgba(255, 255, 255, 0.05); }

.btn-sm { padding: 12px 16px; font-size: 0.9rem; }

.btn-block { width: 100%; }

@media (min-width: 1100px) {
    .app.profile-open {
        grid-template-columns: 300px 1fr 360px;
    }

    .app.profile-open .profile-panel {
        position: relative;
        transform: none;
        width: auto;
        height: 100%;
        min-height: 0;
        max-height: 100dvh;
        box-shadow: none;
    }

    .app.profile-open .profile-backdrop { display: none !important; }
}

@media (max-width: 900px) {
    .landing-main {
        grid-template-columns: 1fr;
        padding-top: 28px;
        padding-bottom: 40px;
    }

    .landing-intro {
        max-width: none;
    }

    .auth-panel {
        padding-top: 0;
    }
}

@media (max-width: 380px) {
    .auth-card { padding: 24px 20px; }
    .chat-header { padding: 10px 14px; }
}

/* ── Sidebar admin link ── */
.admin-link-btn {
    text-decoration: none;
    color: inherit;
}

.admin-link-btn:hover {
    color: var(--accent);
}

/* ── Admin panel ── */
body.admin-page {
    overflow: auto;
    min-height: 100%;
}

.admin-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    background: rgba(12, 12, 20, 0.92);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.admin-sidebar-brand strong {
    display: block;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
}

.admin-sidebar-brand span {
    font-size: 0.72rem;
    color: var(--muted);
}

.admin-sidebar-back {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}

.admin-sidebar-back:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--accent);
}

.admin-sidebar-back svg { width: 18px; height: 18px; }

.admin-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    padding-right: 4px;
}

.admin-sidebar-group-label {
    display: block;
    padding: 0 10px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.admin-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
}

.admin-sidebar-link.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
}

.admin-sidebar-link-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--surface-2);
    flex-shrink: 0;
}

.admin-sidebar-link.active .admin-sidebar-link-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #d4d4d8;
}

.admin-sidebar-link-icon svg { width: 17px; height: 17px; }

.admin-sidebar-link-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.admin-sidebar-link-text strong {
    font-size: 0.88rem;
    font-weight: 600;
}

.admin-sidebar-link-text small {
    font-size: 0.72rem;
    color: var(--muted);
}

.admin-content {
    min-width: 0;
    padding: 24px 28px 48px;
}

.admin-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.admin-topbar h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.admin-page-desc {
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.5;
    max-width: 62ch;
}

.admin-topbar-meta {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--muted);
}

.admin-refresh-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    flex-shrink: 0;
}

.admin-refresh-btn svg { width: 18px; height: 18px; }

.admin-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--accent);
}

.admin-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-panel,
.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(20px);
}

.admin-panel--flat { background: transparent; border-style: dashed; }

.admin-panel-head,
.admin-section-head,
.admin-panel-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.admin-panel-title,
.admin-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.admin-panel-head .admin-panel-title,
.admin-section-head .admin-section-title { margin-bottom: 0; }

.admin-panel-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.28);
    padding: 4px 10px;
    border-radius: 999px;
}

.admin-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-action-btn--muted {
    color: var(--muted);
}

.admin-panel-title svg,
.admin-section-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.admin-panel-toolbar,
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.admin-summary-card {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-summary-card span {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-summary-card strong {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.admin-error {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.88rem;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.admin-stat-card {
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.admin-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.admin-stat-hint {
    font-size: 0.75rem;
    color: var(--muted);
}

.admin-room-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-room-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.88rem;
}

.admin-room-bar-count {
    font-weight: 600;
    color: var(--muted);
}

.admin-room-bar-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    overflow: hidden;
}

.admin-room-bar-track span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: inherit;
    min-width: 4px;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: var(--surface-2);
}

.admin-table tbody tr:last-child td { border-bottom: none; }

.admin-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.admin-cell-muted { color: var(--muted); white-space: nowrap; }

.admin-cell-preview {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-cell-sub {
    font-size: 0.75rem;
    color: var(--muted);
}

.admin-empty {
    text-align: center;
    color: var(--muted);
    padding: 24px !important;
}

.admin-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    color: #d4d4d8;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.admin-user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.admin-you {
    font-style: normal;
    font-size: 0.75rem;
    color: var(--muted);
}

.admin-toggle-btn {
    padding: 5px 10px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-toggle-btn.is-admin {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: var(--success);
}

.admin-toggle-btn:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text);
}

.admin-toggle-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.admin-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-page-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
}

.admin-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.admin-page-info {
    font-size: 0.82rem;
    color: var(--muted);
}

.admin-link {
    color: var(--accent);
    text-decoration: none;
}

.admin-link:hover { text-decoration: underline; }

.admin-text-link {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
}

.admin-text-link:hover { text-decoration: underline; }

.admin-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.admin-quick-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}

.admin-quick-card strong { font-size: 0.95rem; }
.admin-quick-card span { font-size: 0.82rem; color: var(--muted); }

.admin-quick-card:hover {
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.admin-search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 360px;
}

.admin-search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted);
    pointer-events: none;
}

.admin-search-wrap input {
    width: 100%;
    padding: 11px 14px 11px 38px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
}

.admin-search-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.admin-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-filter-tab {
    padding: 8px 12px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.admin-filter-tab:hover { color: var(--text); }

.admin-filter-tab.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

.admin-select {
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}

.admin-result-count {
    font-size: 0.82rem;
    color: var(--muted);
}

.admin-status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-status-badge.active {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.admin-status-badge.admin {
    background: rgba(255, 255, 255, 0.15);
    color: #d4d4d8;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.admin-status-badge.banned {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.admin-type-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    text-transform: uppercase;
}

.admin-th-actions,
.admin-td-actions {
    width: 72px;
    text-align: right;
}

.admin-user-name {
    font-weight: 600;
}

.admin-row-menu {
    position: relative;
    display: inline-flex;
    justify-content: flex-end;
}

.admin-menu-trigger {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-menu-trigger:hover,
.admin-menu-trigger:focus-visible {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.35);
}

.admin-menu-trigger svg { width: 18px; height: 18px; }

.admin-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    min-width: 190px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: none;
}

.admin-menu-dropdown.open {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-menu-item {
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.admin-menu-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
}

.admin-menu-item.is-danger { color: #fca5a5; }
.admin-menu-item.is-success { color: var(--success); }
.admin-menu-item.is-muted { color: #d4d4d8; }
.admin-menu-item:disabled { opacity: 0.45; cursor: not-allowed; }

.admin-menu-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-action-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-action-btn:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.35);
}

.admin-action-btn.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
    color: #d4d4d8;
}

.admin-action-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.admin-action-btn.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.admin-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-table-users td { vertical-align: top; }

.admin-table tr.is-banned-row td {
    background: rgba(239, 68, 68, 0.04);
}

.admin-cell-sub.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
}

.admin-modal {
    width: min(420px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.admin-modal:modal,
.admin-modal[open] {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.admin-modal::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.admin-modal form,
.admin-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.admin-modal-error {
    font-size: 0.8rem;
    color: #fca5a5;
    margin: -6px 0 0;
}

.admin-modal h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.admin-modal-user {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.45;
}

.admin-modal-warning {
    font-size: 0.84rem;
    line-height: 1.5;
    color: #fca5a5;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.admin-field--confirm input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-field span {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.admin-field textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    resize: vertical;
    min-height: 80px;
}

.admin-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-danger {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover { opacity: 0.92; }

@media (max-width: 960px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 14px;
    }

    .admin-sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .admin-sidebar-group {
        display: contents;
    }

    .admin-sidebar-group-label { display: none; }

    .admin-sidebar-link-text small { display: none; }

    .admin-content { padding: 16px 16px 40px; }

    .admin-stats,
    .admin-summary { grid-template-columns: repeat(2, 1fr); }

    .admin-cell-preview { max-width: 140px; }

    .admin-panel-toolbar,
    .admin-toolbar { flex-direction: column; align-items: stretch; }

    .admin-search-wrap { max-width: none; }
}

/* ── Level & badges ── */
.user-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.user-level-slot { flex-shrink: 0; }

.level-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 5px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    background: linear-gradient(135deg, var(--level-color, var(--accent)), color-mix(in srgb, var(--level-color, var(--accent)) 65%, #000));
    border: 1px solid color-mix(in srgb, var(--level-color, var(--accent)) 50%, transparent);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--level-color, var(--accent)) 35%, transparent);
    vertical-align: middle;
}

.level-pill--compact {
    padding: 1px 6px 1px 4px;
    font-size: 0.62rem;
}

.level-pill-icon { font-size: 0.85em; line-height: 1; }

.level-pill-num { letter-spacing: 0.02em; }

.msg-meta .level-pill { margin-right: 2px; }



.profile-level-card {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.profile-level-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.profile-level-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--level-color, var(--accent)), color-mix(in srgb, var(--level-color, var(--accent)) 55%, #000));
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--level-color, var(--accent)) 40%, transparent);
    flex-shrink: 0;
}

.profile-level-icon { font-size: 1.6rem; line-height: 1; }

.profile-level-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-level-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.profile-level-rank {
    font-size: 0.78rem;
    color: var(--muted);
}

.profile-level-num {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
    flex-shrink: 0;
}

.profile-level-bar {
    height: 8px;
    border-radius: 99px;
    background: rgba(0, 0, 0, 0.25);
    overflow: hidden;
    margin-bottom: 8px;
}

.profile-level-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}

.profile-level-xp {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.profile-badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
}

.profile-badge-icon { font-size: 0.95em; }

.profile-badge-empty {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
}

.level-up-toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-width: min(320px, 92vw);
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--level-color, var(--accent)) 45%, var(--border));
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 30px color-mix(in srgb, var(--level-color, var(--accent)) 25%, transparent);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-up-toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.level-up-toast.leaving {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
}

.level-up-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, color-mix(in srgb, var(--level-color, var(--accent)) 25%, transparent), transparent 65%);
    pointer-events: none;
}

.level-up-icon {
    position: relative;
    z-index: 1;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--level-color, var(--accent)), color-mix(in srgb, var(--level-color, var(--accent)) 60%, #000));
    box-shadow: 0 6px 20px color-mix(in srgb, var(--level-color, var(--accent)) 40%, transparent);
}

.level-up-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.level-up-body strong {
    font-size: 0.95rem;
    color: var(--text);
}

.level-up-body span {
    font-size: 0.82rem;
    color: var(--muted);
}

.image-locked-toast.muted-toast {
    border-color: rgba(239, 68, 68, 0.35);
}

.image-locked-toast.muted-toast .image-locked-icon {
    background: rgba(239, 68, 68, 0.15);
}

.image-locked-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-width: min(340px, 92vw);
    background: var(--surface);
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-locked-toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.image-locked-toast.leaving {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
}

.image-locked-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    border-radius: 14px;
    background: rgba(249, 115, 22, 0.15);
    flex-shrink: 0;
}

.image-locked-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.image-locked-body strong {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
}

.image-locked-body span {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ── Admin settings ── */
.admin-settings-note {
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-settings-note.is-warning {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.admin-settings-note code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.admin-settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-settings-section { margin-bottom: 0; }

.admin-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.admin-settings-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.admin-field input,
.admin-field select,
.admin-field textarea {
    width: 100%;
    padding: 11px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
}

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.admin-field--narrow { max-width: 200px; }

.admin-field--icon { max-width: 100px; }

.admin-field--checkbox {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    cursor: pointer;
}

.admin-field--checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--accent, #fafafa);
}

.admin-field--checkbox span {
    font-weight: 500;
    color: var(--text, #e8e8ef);
}

.admin-pages-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.admin-pages-section-head .admin-section-title {
    margin-bottom: 0;
}

.admin-pages-preview {
    flex-shrink: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.admin-pages-preview:hover {
    text-decoration: underline;
}

.admin-landing-features {
    display: grid;
    gap: 12px;
    margin-top: 8px;
}

.admin-rooms-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-room-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr 80px 36px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-room-remove {
    width: 36px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.admin-room-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

.admin-settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.admin-settings-actions .btn-primary,
.admin-settings-actions .btn-secondary {
    flex: 0 1 auto;
    min-width: 140px;
}

.admin-settings-success {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
    font-size: 0.88rem;
}

.admin-branding-section {
    margin-bottom: 20px;
}

.admin-branding-name-field {
    max-width: 360px;
    margin-bottom: 10px;
}

.admin-branding-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.admin-branding-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-branding-label {
    font-size: 0.88rem;
    font-weight: 600;
}

.admin-branding-preview {
    display: grid;
    place-items: center;
    min-height: 88px;
    padding: 16px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.admin-branding-preview--favicon {
    min-height: 72px;
}

.admin-branding-placeholder {
    font-size: 0.82rem;
    color: var(--muted);
}

.admin-branding-logo-img {
    max-width: 100%;
    max-height: 64px;
    object-fit: contain;
}

.admin-branding-favicon-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.admin-branding-meta {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

.admin-branding-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-branding-remove {
    flex: 0 1 auto;
    min-width: 0;
    padding: 10px 14px;
}

.admin-branding-success {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
    font-size: 0.86rem;
}

/* ── Admin levels ── */
.admin-levels-table-wrap {
    overflow-x: auto;
    margin-bottom: 12px;
}

.admin-levels-table .admin-levels-input {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    outline: none;
}

.admin-levels-table .admin-levels-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.admin-levels-input--icon { max-width: 72px; text-align: center; }
.admin-levels-input--num { max-width: 90px; }
.admin-levels-input--color { max-width: 100px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.admin-levels-color-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-levels-color-picker {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
}

.admin-levels-remove {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.admin-levels-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

.admin-levels-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.admin-levels-preview-block h3 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .admin-room-row {
        grid-template-columns: 1fr 1fr;
    }
    .admin-room-remove {
        grid-column: 2;
        justify-self: end;
    }
}