:root {
    --bg-1: #1a1a2e;
    --bg-2: #16213e;
    --panel: rgba(22, 33, 62, 0.95);
    --panel-strong: rgba(15, 23, 42, 0.98);
    --panel-soft: rgba(255, 255, 255, 0.06);
    --border: #3a3a5c;
    --border-strong: #5a5a8c;
    --text: #e0e0ff;
    --muted: #8888aa;
    --muted-2: #666688;
    --accent: #00ffff;
    --accent-2: #55aaff;
    --danger: #ff5555;
    --danger-hover: #ff3333;
    --shadow: 4px 4px 0px #0a0a1a;
    --radius-xl: 0px;
    --radius-lg: 0px;
    --radius-md: 0px;
    --radius-sm: 0px;
    --pixel-border: 3px solid;
}

@font-face {
    font-family: 'PixelFont';
    src: url('https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nVivM.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Press Start 2P', 'PixelFont', monospace;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Press Start 2P', 'PixelFont', monospace;
    color: var(--text);
    background: var(--bg-1);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.015) 2px,
            rgba(255, 255, 255, 0.015) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.015) 2px,
            rgba(255, 255, 255, 0.015) 4px
        );
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

body::before,
body::after {
    content: '';
    position: fixed;
    pointer-events: none;
    z-index: 0;
}

body::before {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 255, 255, 0.06), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(85, 85, 255, 0.06), transparent 40%);
}

body::after {
    display: none;
}

/* ===== PIXEL BORDER UTILITY ===== */

.container {
    position: relative;
    z-index: 1;
    background: var(--panel);
    border: 4px solid var(--border-strong);
    box-shadow:
        6px 6px 0px #0a0a1a,
        inset 2px 2px 0px rgba(255, 255, 255, 0.08);
    max-width: 920px;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: min(92vh, 860px);
    overflow: hidden;
}

.header {
    padding: 16px 20px 14px;
    background: #1e2d50;
    border-bottom: 4px solid var(--border-strong);
}

#appContainer .header {
    --app-header-min-height: 88px;
    --app-header-max-height: 136px;
    min-height: var(--app-header-min-height);
    max-height: var(--app-header-max-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-badge {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    font-size: 20px;
    background: #2a2a5a;
    border: 3px solid var(--accent);
    box-shadow: 3px 3px 0px #0a0a1a;
}

.brand-badge-img {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    flex: 0 0 auto;
    display: block;
    object-fit: contain;
    object-position: center;
    border: none;
    image-rendering: pixelated;
}

.header-title {
    font-size: clamp(14px, 2.5vw, 18px);
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    color: var(--accent);
    text-shadow: 2px 2px 0px #0a0a1a;
}

.header-subtitle,
.username-display {
    color: var(--muted);
    font-size: 8px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #2a2a4a;
    border: 2px solid var(--border);
    box-shadow: 2px 2px 0px #0a0a1a;
    color: var(--text);
    font-size: 8px;
    font-weight: 400;
    max-width: min(100%, 320px);
    overflow: hidden;
}

.user-chip > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    box-shadow:
        0 0 0 2px #0a0a1a,
        0 0 8px var(--accent);
}

.username-control {
    margin-top: 8px;
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    width: fit-content;
    max-width: 100%;
}

/* ===== BUTTONS ===== */

.btn {
    border: 3px solid;
    font-size: 10px;
    font-weight: 400;
    cursor: pointer;
    transition: none;
    padding: 10px 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0px #0a0a1a;
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: 0.4;
    box-shadow: none;
    transform: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: #2a2a4a;
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: 2px 2px 0px #0a0a1a;
}

.btn-primary:hover {
    background: #3a3a5a;
    border-color: var(--accent);
    box-shadow: 4px 4px 0px #0a0a1a;
}

.btn-secondary {
    background: #2244aa;
    color: #ffffff;
    border-color: #5577ff;
    box-shadow: 3px 3px 0px #0a0a1a;
}

.btn-secondary:hover {
    background: #3355bb;
    box-shadow: 4px 4px 0px #0a0a1a;
}

.btn-danger {
    background: #3a1a1a;
    color: #ff8888;
    font-size: 10px;
    padding: 10px 14px;
    border-color: #ff5555;
    box-shadow: 2px 2px 0px #0a0a1a;
}

.btn-danger:hover {
    background: #4a2a2a;
    color: #ffaaaa;
    box-shadow: 4px 4px 0px #0a0a1a;
}

.btn-edit {
    background: #2a2a4a;
    color: #ffffff;
    font-size: 10px;
    padding: 10px 14px;
    border-color: #8888cc;
    box-shadow: 2px 2px 0px #0a0a1a;
}

.btn-edit:hover {
    background: #3a3a6a;
    box-shadow: 4px 4px 0px #0a0a1a;
}

.btn-small {
    font-size: 8px;
    padding: 7px 10px;
}

.btn img {
    width: 20px;
    height: 20px;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ===== CONTENT & MESSAGES ===== */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.messages-section {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #12122a;
    min-height: 0;
    max-height: 100%;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) #1a1a2e;
}

.messages-section::-webkit-scrollbar {
    width: 12px;
}

.messages-section::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-left: 2px solid var(--border);
}

.messages-section::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.message-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1a1a3a;
    border: 2px solid var(--border);
    padding: 12px 14px;
    box-shadow: 3px 3px 0px #0a0a1a;
    overflow: visible;
}

.message-item.is-new {
    animation: messageEnter 0.3s steps(6);
}

.message-item.is-pending {
    opacity: 0.7;
}

.message-item.is-pending .message-timestamp {
    color: var(--muted);
    font-style: italic;
}

@keyframes messageEnter {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    50% {
        opacity: 0.5;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-item::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}

.message-username {
    font-weight: 400;
    color: var(--accent-2);
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 1px 1px 0px #0a0a1a;
}

.message-username::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--presence-color, var(--accent-2));
    box-shadow: none;
    flex-shrink: 0;
}

.message-username.is-admin,
.profile-username.is-admin {
    color: #ff66c8;
    text-shadow: 2px 2px 0px #0a0a1a, 0 0 4px rgba(255, 102, 200, 0.32);
}

.message-username.is-mod,
.profile-username.is-mod {
    color: #a978ff;
    text-shadow: 2px 2px 0px #0a0a1a, 0 0 4px rgba(169, 120, 255, 0.3);
}

.message-username.is-owner,
.profile-username.is-owner {
    background: linear-gradient(90deg, #ff00ff 0%, #FF8000 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0 6px rgba(115, 0, 255, 0.5)) drop-shadow(0 0 6px rgba(255, 128, 0, 0.4));
}

.message-username.is-owner {
    flex: 0 0 auto;
    width: fit-content;
}

.message-role-badge-image {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    vertical-align: middle;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}


.message-username.is-guest {
    color: #777799;
    text-shadow: 1px 1px 0px #0a0a1a;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border: 2px solid var(--border-strong);
    background: #2a2a4a;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.message-content-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: -4px;
}

.message-username {
    flex: 1 1 auto;
    min-width: 0;
}

.message-text {
    color: var(--text);
    font-size: 10px;
    line-height: 1.8;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    flex: 1 1 auto;
    min-width: 0;
}

.message-text a,
.profile-bio a {
    color: var(--accent-2);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 400;
    word-break: break-word;
}

.message-text a:visited,
.message-text a:active,
.profile-bio a:visited,
.profile-bio a:active {
    color: var(--accent-2);
}

.message-text a:hover,
.profile-bio a:hover {
    color: var(--accent);
}

.chat-link {
    color: var(--accent-2);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 400;
    word-break: break-word;
}

.chat-link:visited,
.chat-link:active {
    color: var(--accent-2);
}

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

.message-text code {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 2px 6px;
    background: #0a0a2a;
    border: 1px solid var(--border);
}

.message-text pre {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: #0a0a1a;
    border: 2px solid var(--border);
    box-shadow: inset 2px 2px 0px rgba(0, 0, 0, 0.3);
    overflow-x: auto;
}

.message-text pre code {
    display: block;
    padding: 0;
    border: none;
    background: none;
    font-size: 9px;
    white-space: pre;
}

.blocked-message {
    border: 2px dashed var(--border);
    padding: 8px 10px;
    background: #12122a;
}

.blocked-message summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 9px;
    font-weight: 400;
    list-style: none;
}

.blocked-message summary::-webkit-details-marker {
    display: none;
}

.blocked-message-body {
    margin-top: 8px;
}

.message-timestamp {
    font-size: 8px;
    color: var(--muted-2);
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.2;
    padding-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
    margin-top: -2px;
}

.message-actions {
    display: inline-flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    flex: 0 0 auto;
    margin-left: 8px;
    flex-wrap: nowrap;
}

.message-actions:empty {
    display: none;
    margin-left: 0;
}

.message-actions.message-actions-placeholder {
    visibility: hidden;
    pointer-events: none;
}

.message-actions .btn-edit,
.message-actions .btn-danger {
    width: 44px;
    height: 44px;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-actions .btn img {
    width: 22px;
    height: 22px;
}

/* ===== EMPTY STATE ===== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    color: var(--muted);
    text-align: center;
    border: 3px dashed var(--border);
    background: #12122a;
    padding: 24px;
    font-size: 10px;
    line-height: 1.8;
}

.empty-state::before {
    content: '?';
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    font-size: 20px;
    color: var(--accent);
    background: #1a1a3a;
    border: 3px solid var(--accent);
    box-shadow: 3px 3px 0px #0a0a1a;
}

/* ===== COMPOSER ===== */

.composer-wrap {
    padding: 14px 16px 16px;
    border-top: 4px solid var(--border-strong);
    background: var(--panel-strong);
}

.input-section {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.message-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.mention-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 56px;
    background: #12122a;
    border: 3px solid var(--border-strong);
    box-shadow: 4px 4px 0px #0a0a1a;
    padding: 6px;
    display: none;
    z-index: 5;
}

.mention-suggestions.active {
    display: grid;
    gap: 4px;
}

.mention-suggestion-item {
    border: none;
    background: #1a1a3a;
    color: var(--text);
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
    font-size: 9px;
    font-weight: 400;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.mention-suggestion-item span {
    color: var(--muted);
    font-weight: 400;
    font-size: 8px;
}

.mention-suggestion-item.active {
    background: #2a2a5a;
    border: 2px solid var(--accent);
}

.message-input,
.field-input {
    width: 100%;
    padding: 12px 14px;
    border: 3px solid var(--border);
    font-size: 10px;
    font-family: 'Press Start 2P', monospace;
    background: #0e0e24;
    color: var(--text);
    transition: border-color 0.1s;
}

input[type="date"].field-input {
    color-scheme: dark;
}

select.field-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath fill='%2355aaff' d='M1 2h10v2H1zM2 4h8v2H2zM3 6h6v2H3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 10px;
    padding-right: 40px;
    cursor: pointer;
}

#avatarInput {
    display: none;
}

.btn-file-input {
    background: #2244aa;
    color: white;
    border: 3px solid #5577ff;
    box-shadow: 3px 3px 0px #0a0a1a;
    font-size: 10px;
    font-weight: 400;
    cursor: pointer;
    padding: 10px 14px;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
}

.btn-file-input:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px #0a0a1a;
}

.btn-file-input:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.message-input {
    resize: none;
    min-height: 48px;
    max-height: 140px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) #1a1a2e;
}

.message-input::-webkit-scrollbar {
    width: 12px;
}

.message-input::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.message-input::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.message-input:focus,
.field-input:focus,
.modal-text-area:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2), inset 0 0 8px rgba(0, 255, 255, 0.05);
    background: #101030;
}

.message-input::placeholder,
.field-input::placeholder,
.modal-text-area::placeholder {
    color: #444466;
}

.send-btn {
    min-width: 100px;
    height: 48px;
}

.send-btn:disabled,
.send-btn[disabled] {
    background: #1a1a2e;
    color: #444466;
    border: 3px solid var(--border);
    box-shadow: none;
}

/* ===== AUTH ===== */

.auth-shell {
    padding: 24px;
    display: grid;
    place-items: center;
    min-height: 0;
}

#authContainer {
    overflow-y: auto;
}

#authContainer .content {
    overflow-y: auto;
}

#authContainer .auth-shell {
    place-items: start center;
    align-content: start;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    padding: 24px;
    background: #1a1a3a;
    border: 3px solid var(--border-strong);
    box-shadow: 4px 4px 0px #0a0a1a;
}

.auth-title {
    color: var(--accent);
    margin-bottom: 8px;
    text-align: center;
    font-size: 16px;
    letter-spacing: 0.05em;
    text-shadow: 2px 2px 0px #0a0a1a;
}

.auth-subtitle {
    color: var(--muted);
    margin-bottom: 22px;
    text-align: center;
    font-size: 8px;
    line-height: 1.8;
}

.field-group {
    margin-bottom: 14px;
}

.field-label {
    color: var(--accent-2);
    font-size: 9px;
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    text-transform: uppercase;
}

.tos-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 8px;
    color: var(--muted);
    line-height: 1.8;
}

.tos-row input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid var(--border-strong);
    background: #0e0e24;
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
}

.tos-row input[type="checkbox"]::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    transform: scale(0);
    transition: transform 0.1s steps(2);
}

.tos-row input[type="checkbox"]:hover {
    border-color: var(--accent);
}

.tos-row input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: #1a2a2a;
}

.tos-row input[type="checkbox"]:checked::after {
    transform: scale(1);
}

.tos-row input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.3);
}

.tos-row a {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 400;
}

.tos-row a:hover,
.tos-row a:focus {
    text-decoration: underline;
    color: var(--accent);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== MODALS ===== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}


#profileModal {
    z-index: 2600;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #16163a;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 6px 6px 0px #0a0a1a;
    border: 3px solid var(--border-strong);
}

#settingsModal .modal-content {
    max-height: min(78vh, 640px);
    overflow-y: auto;
}

#settingsModal .modal-content::-webkit-scrollbar {
    width: 12px;
}

#settingsModal .modal-content::-webkit-scrollbar-track {
    background: #1a1a2e;
}

#settingsModal .modal-content::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.modal-title {
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 12px;
    color: var(--accent);
    text-shadow: 2px 2px 0px #0a0a1a;
    text-transform: uppercase;
}

.modal-text {
    color: var(--muted);
    margin-bottom: 18px;
    line-height: 1.8;
    font-size: 9px;
}

.modal-text-area {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 3px solid var(--border);
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    resize: vertical;
    margin-bottom: 16px;
    background: #0e0e24;
    color: var(--text);
    scrollbar-width: thin;
    scrollbar-color: var(--accent) #1a1a2e;
}

.modal-text-area::-webkit-scrollbar {
    width: 12px;
}

.modal-text-area::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.modal-text-area::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.bio-counter {
    font-size: 8px;
    color: var(--muted-2);
    text-align: right;
    margin-top: 6px;
}

/* ===== PROFILE ===== */

.profile-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-username-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.profile-presence {
    width: 8px;
    height: 8px;
    background: var(--presence-color, var(--accent-2));
    box-shadow: 0 0 6px var(--presence-color, var(--accent-2));
}

.profile-avatar {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border: 3px solid var(--border-strong);
    background: #2a2a4a;
    image-rendering: pixelated;
}

.avatar-preview {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border: 3px solid var(--border-strong);
    background: #2a2a4a;
    image-rendering: pixelated;
}

.avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-note {
    font-size: 8px;
    color: var(--muted-2);
}

.profile-username {
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    text-shadow: 2px 2px 0px #0a0a1a;
}

.profile-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.profile-badge,
.profile-badges .profile-badge {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
    flex: 0 0 32px;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.profile-age-line {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: var(--muted);
    text-align: center;
}
.profile-age-line.is-minor {
    color: #ff8888;
}

.profile-bio {
    width: 100%;
    height: clamp(120px, 24vh, 220px);
    overflow-y: auto;
    padding: 10px;
    border: 2px solid var(--border);
    background: #0e0e24;
    text-align: center;
    font-size: 9px;
    color: var(--muted);
    line-height: 1.8;
    white-space: pre-wrap;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) #1a1a2e;
}

.profile-bio::-webkit-scrollbar {
    width: 12px;
}

.profile-bio::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.profile-bio::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.profile-admin-section {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    background: #12122a;
    border: 2px solid var(--border);
    text-align: left;
}

.profile-admin-title {
    font-size: 10px;
    font-weight: 400;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.profile-punishment {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 2px solid var(--border);
    background: #0e0e24;
    margin-bottom: 8px;
}

.profile-punishment:last-child {
    margin-bottom: 0;
}

.profile-punishment-title {
    font-size: 10px;
    font-weight: 400;
    color: var(--text);
}

.profile-punishment-meta {
    font-size: 8px;
    color: var(--muted);
}

.profile-punishment-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ===== ADMIN PANEL ===== */

.reports-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reports-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.reports-toolbar-meta {
    font-size: 8px;
    color: var(--muted);
}

.admin-search-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-search-input {
    min-width: 180px;
    max-width: 300px;
    padding: 8px 10px;
    border: 2px solid var(--border);
    background: #0e0e24;
    color: var(--text);
    font-size: 9px;
    font-family: 'Press Start 2P', monospace;
}

.admin-search-input::placeholder {
    color: var(--muted-2);
}

.admin-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);
}

.reports-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.admin-panel-content {
    max-height: min(78vh, 680px);
    overflow-y: auto;
}

.admin-panel-content::-webkit-scrollbar {
    width: 12px;
}

.admin-panel-content::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.admin-panel-content::-webkit-scrollbar-thumb {
    background: #3a3a6a;
    border: 2px solid var(--border);
}

.admin-tabs {
    display: flex;
    gap: 6px;
    margin: 6px 0 14px;
    flex-wrap: wrap;
}

.admin-tab {
    display: inline-flex;
    align-items: center;
}

.admin-tab.active {
    opacity: 1;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

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

.report-card {
    padding: 10px;
    border: 2px solid var(--border);
    background: #0e0e24;
    display: grid;
    gap: 6px;
}

.report-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.report-user {
    font-size: 10px;
    font-weight: 400;
    color: var(--text);
}

.report-reason {
    font-size: 9px;
    color: var(--text);
    line-height: 1.8;
    white-space: pre-wrap;
}

.report-meta {
    font-size: 8px;
    color: var(--muted);
}

.reports-empty,
.reports-loading {
    font-size: 8px;
    color: var(--muted-2);
    padding: 8px 0;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: #16163a;
    border: 3px solid var(--border-strong);
    padding: 14px 16px;
    color: var(--text);
    font-size: 9px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
    box-shadow: 4px 4px 0px #0a0a1a;
    pointer-events: all;
    animation: toastSlide 0.2s steps(4);
}

@keyframes toastSlide {
    0% {
        opacity: 0;
        transform: translateX(100px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.exit {
    animation: toastSlideOut 0.15s steps(3) forwards;
}

@keyframes toastSlideOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(100px);
    }
}

.toast.success {
    border-color: var(--accent);
    background: #1a2a2a;
}

.toast.error {
    border-color: var(--danger);
    background: #2a1a1a;
}

.toast.info {
    border-color: #5555ff;
    background: #1a1a3a;
}

.toast-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
    line-height: 1.6;
}

.toast-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    font-family: 'Press Start 2P', monospace;
}

.toast-close:hover {
    color: var(--text);
}

/* ===== LOADING ===== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2800;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s steps(3);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-card {
    padding: 20px 24px;
    background: #16163a;
    border: 3px solid var(--border-strong);
    box-shadow: 4px 4px 0px #0a0a1a;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    font-size: 10px;
    font-weight: 400;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: spin 0.6s steps(8) infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== CONFIRMATION & PROMPT MODALS ===== */

.popup-overlay {
    background: rgba(0, 0, 0, 0.75);
    padding: 16px;
}

.popup-content {
    background: #16163a;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 6px 6px 0px #0a0a1a;
    border: 3px solid var(--border-strong);
}

.popup-title {
    font-size: 12px;
    font-weight: 400;
    margin-bottom: 10px;
    color: var(--accent);
    text-shadow: 2px 2px 0px #0a0a1a;
    text-transform: uppercase;
}

.popup-message {
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.8;
    font-size: 9px;
}

.popup-link {
    color: var(--text);
    margin: -8px 0 20px;
    padding: 8px 10px;
    font-size: 8px;
    font-family: 'Press Start 2P', monospace;
    background: #0e0e24;
    border: 2px solid var(--border);
    word-break: break-all;
}

.popup-input {
    width: 100%;
    padding: 10px 12px;
    border: 3px solid var(--border);
    font-size: 10px;
    font-family: 'Press Start 2P', monospace;
    background: #0e0e24;
    color: var(--text);
    margin-bottom: 16px;
}

.popup-quick-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.popup-quick-option {
    background: #2a2a4a;
    color: var(--text);
    border: 2px solid var(--border);
    padding: 6px 10px;
    font-size: 8px;
    font-weight: 400;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    text-transform: uppercase;
}

.popup-quick-option:hover {
    background: #3a3a6a;
    border-color: var(--accent);
    box-shadow: 2px 2px 0px #0a0a1a;
    transform: translate(-1px, -1px);
}

.popup-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);
    background: #101030;
}

.popup-input::placeholder {
    color: #444466;
}

.popup-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.popup-html {
    margin-bottom: 0;
}

/* ===== NOTIFICATION SETTINGS ===== */

.notification-preferences {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 10px;
    transition: background 0.1s;
}

.radio-option:hover {
    background: #1a1a3a;
}

.radio-option input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    background: var(--bg-1);
    transition: border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.radio-option input[type="radio"]:hover {
    border-color: var(--accent);
}

.radio-option input[type="radio"]:checked {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: inset 0 0 0 3px var(--bg-1);
}

.radio-option label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 9px;
    color: var(--text);
    margin-bottom: 0;
}

/* ===== SETTINGS SECTIONS ===== */

.settings-section {
    border: 2px solid var(--border);
    padding: 12px;
    margin-bottom: 12px;
    background: #12122a;
}

.settings-section.danger {
    border-color: var(--danger);
    background: #2a1218;
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
}

.settings-section-header:hover {
    opacity: 0.8;
}

.settings-section-title {
    font-size: 10px;
    font-weight: 400;
    color: var(--text);
    margin: 0;
    text-transform: uppercase;
}

.settings-section-title.danger {
    color: var(--danger);
}

.settings-section-toggle {
    font-size: 12px;
    color: var(--muted-2);
    transition: transform 0.1s steps(2);
}

.settings-section-toggle.collapsed {
    transform: rotate(-90deg);
}

.settings-section-content {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid var(--border);
}

.settings-section-content.open {
    display: block;
}

.settings-section-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* ===== CONTEXT MENU ===== */

.context-menu {
    display: none;
    position: fixed;
    background: #16163a;
    border: 3px solid var(--border-strong);
    box-shadow: 4px 4px 0px #0a0a1a;
    z-index: 2000;
    min-width: clamp(170px, 22vw, 236px);
    max-width: min(290px, 82vw);
    overflow: hidden;
    animation: contextMenuSlide 0.1s steps(3);
}

.context-menu.active {
    display: block;
}

@keyframes contextMenuSlide {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.context-menu-item {
    padding: clamp(10px, 1.2vw, 13px) clamp(12px, 1.5vw, 16px);
    color: var(--text);
    font-size: clamp(8px, 1.1vw, 10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'Press Start 2P', monospace;
    white-space: nowrap;
}

.context-menu-item:hover {
    background: #2a2a5a;
}

.context-menu-item:active {
    background: #3a3a6a;
}

.context-menu-item.danger:hover {
    background: #3a1a1a;
}

.context-menu-item.danger:active {
    background: #4a2a2a;
}

.context-menu-item.danger {
    color: #ff8888;
}

.context-menu-item-icon {
    width: clamp(18px, 1.6vw, 20px);
    height: clamp(18px, 1.6vw, 20px);
    opacity: 0.85;
    display: block;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.context-menu-divider {
    height: 5px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.28) 0 1px,
        transparent 1px 2px,
        rgba(0, 255, 255, 0.72) 2px 3px,
        transparent 3px 4px,
        rgba(255, 255, 255, 0.28) 4px 5px
    );
    margin: 7px 10px;
    display: none;
}

/* ===== MOBILE ===== */

@media (max-width: 760px) {
    body {
        padding: 0;
    }

    .container {
        height: 100dvh;
        max-height: 100dvh;
        border: none;
        box-shadow: none;
    }

    .header {
        padding: clamp(8px, 2vw, 10px) clamp(8px, 2.4vw, 10px);
    }

    #appContainer .header {
        --app-header-min-height: 74px;
        --app-header-max-height: 108px;
        min-height: var(--app-header-min-height);
        max-height: var(--app-header-max-height);
        gap: 6px;
    }

    .header-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .brand {
        gap: 8px;
        min-width: 0;
    }

    .brand-badge {
        width: clamp(34px, 9vw, 40px);
        height: clamp(34px, 9vw, 40px);
        font-size: clamp(12px, 3.4vw, 16px);
    }

    .brand-badge-img {
        width: clamp(34px, 9vw, 40px);
        height: clamp(34px, 9vw, 40px);
        min-width: clamp(34px, 9vw, 40px);
        min-height: clamp(34px, 9vw, 40px);
    }

    .header-title {
        font-size: clamp(10px, 3.6vw, 14px);
        margin-bottom: 0;
    }

    .user-chip {
        width: auto;
        max-width: min(52vw, 220px);
        justify-content: flex-start;
        gap: 6px;
        padding: 6px 8px;
        font-size: clamp(7px, 2.4vw, 8px);
        margin-top: 0;
        overflow: hidden;
    }

    .user-chip span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-dot {
        width: 7px;
        height: 7px;
    }

    .username-control {
        width: auto;
        max-width: none;
        margin-left: auto;
        margin-top: 0;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 4px;
        flex-shrink: 0;
    }

    .username-control .btn,
    .username-control .btn-small {
        font-size: clamp(7px, 2.2vw, 8px);
        padding: clamp(6px, 1.8vw, 8px) clamp(8px, 2.2vw, 10px);
        border-width: 2px;
    }

    .username-control .btn img,
    .username-control .btn-small img {
        width: 14px;
        height: 14px;
    }

    .messages-section,
    .composer-wrap,
    .auth-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .messages-section {
        padding-top: 12px;
    }

    .auth-card {
        padding: 18px 14px;
    }

    .auth-title {
        font-size: 12px;
    }

    .input-section {
        flex-direction: column;
        align-items: stretch;
    }

    .send-btn {
        width: 100%;
        min-width: 0;
    }

    .message-item {
        padding: 10px;
    }

    .message-text {
        font-size: 9px;
    }

    .toolbar {
        justify-content: stretch;
    }

    .toolbar > * {
        flex: 1 1 100%;
    }

    .toast-container {
        right: 8px;
        left: 8px;
        top: 8px;
    }

    .toast {
        max-width: 100%;
    }

    .popup-content {
        max-width: calc(100vw - 16px);
    }

    .modal-content {
        max-width: calc(100vw - 16px);
    }

    .notification-preferences {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .settings-section {
        margin-bottom: 10px;
    }
}

@media (max-width: 420px) {
    .header {
        padding: 8px;
    }

    #appContainer .header {
        --app-header-min-height: 70px;
        --app-header-max-height: 100px;
        min-height: var(--app-header-min-height);
        max-height: var(--app-header-max-height);
        gap: 4px;
    }

    .brand {
        gap: 6px;
    }

    .brand-badge-img {
        width: clamp(30px, 10vw, 36px);
        height: clamp(30px, 10vw, 36px);
        min-width: clamp(30px, 10vw, 36px);
        min-height: clamp(30px, 10vw, 36px);
    }

    .header-title {
        font-size: 10px;
    }

    .username-control .btn,
    .username-control .btn-small {
        padding: 6px 8px;
        font-size: 7px;
    }
}
