:root {
    --bg-color: #050505;
    --primary-color: #00ff41; /* Classic Matrix Green */
    --primary-glow: rgba(0, 255, 65, 0.5);
    --secondary-color: #6100ff; /* Cyber Purple */
    --accent-color: #00d4ff; /* Tech Cyan */
    --text-color: #e0e0e0;
    --error-color: #ff003c;
    --font-mono: 'Fira Code', monospace;
    --font-heading: 'Orbitron', sans-serif;

    /* Files-style palette (post-login phases) */
    --void-files-bg: #1e1c22;
    --void-files-header: #3d3846;
    --void-files-chrome: #2b2733;
    --void-files-sidebar: #25222c;
    --void-files-text: #f6f5f4;
    --void-files-muted: #9b99a0;
    --void-files-dim: #6e6c75;
    --void-files-border: rgba(255, 255, 255, 0.08);
    --void-files-accent: #e95420;
    --void-files-accent-soft: #ffc89a;
    --void-files-code: #78a893;
    --void-files-code-dim: #5a8a72;
    --void-files-ui: 'Ubuntu', 'Cantarell', sans-serif;
    --void-files-mono: 'Ubuntu Mono', 'Fira Code', monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
}

body {
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-family: var(--font-mono);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Scanlines & Effects */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 100;
    pointer-events: none;
    opacity: 0.15;
}

.vignette {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
    z-index: 101;
    pointer-events: none;
    opacity: 0; /* Hidden on PC by default */
    transition: opacity 0.5s ease;
}

.mobile-view ~ .vignette, #app-container.mobile-view ~ .vignette {
    opacity: 1; /* Shown when in mobile simulation */
}

@keyframes flicker {
    0% { opacity: 0.27861; }
    5% { opacity: 0.34769; }
    10% { opacity: 0.23604; }
    /* ... shortened for brevity but I'll add a few more ... */
    100% { opacity: 0.23604; }
}

body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 102;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

#app-container {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 100%;
    border: 1px solid var(--primary-glow);
    background: rgba(0, 20, 0, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.1);
    position: relative;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

@media (min-width: 769px) and (min-height: 700px) {
    #app-container {
        width: 95vw;
        height: 90vh;
        height: 90dvh;
    }
}

.header-btn {
    background: rgba(0, 255, 65, 0.05);
    border: 1px solid var(--primary-glow);
    color: var(--primary-color);
    padding: 2px 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 10px;
    border-radius: 2px;
}

.header-btn:hover {
    background: rgba(0, 255, 65, 0.15);
    box-shadow: 0 0 10px var(--primary-glow);
}

.phase {
    display: none;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.phase.active {
    display: flex;
}

/* Identity Glitch & Scramble Effects */
.identity-glitch {
    position: relative;
    display: inline-block;
    animation: glitch-skew 1s infinite linear alternate-reverse;
}

.identity-glitch::before,
.identity-glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.identity-glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--accent-color);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.identity-glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--secondary-color);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

.resolving {
    text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-glow);
    transition: all 0.2s ease;
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); }
    5% { clip: rect(70px, 9999px, 71px, 0); }
    10% { clip: rect(29px, 9999px, 83px, 0); }
    100% { clip: rect(67px, 9999px, 62px, 0); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(10px, 9999px, 50px, 0); }
    100% { clip: rect(80px, 9999px, 20px, 0); }
}

@keyframes glitch-skew {
    0% { transform: skew(3deg); }
    10% { transform: skew(-1deg); }
    100% { transform: skew(0deg); }
}

/* Phase 1: Nickname */
.glitch {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 900;
    text-transform: uppercase;
    position: relative;
    text-shadow: 0.05em 0 0 var(--secondary-color), -0.05em -0.025em 0 var(--accent-color);
    animation: glitch 1s infinite;
}

@keyframes glitch {
    0% { text-shadow: 0.05em 0 0 var(--secondary-color), -0.05em -0.025em 0 var(--accent-color); }
    14% { text-shadow: 0.05em 0 0 var(--secondary-color), -0.05em -0.025em 0 var(--accent-color); }
    15% { text-shadow: -0.05em -0.025em 0 var(--secondary-color), 0.025em 0.025em 0 var(--accent-color); }
    49% { text-shadow: -0.05em -0.025em 0 var(--secondary-color), 0.025em 0.025em 0 var(--accent-color); }
    50% { text-shadow: 0.025em 0.05em 0 var(--secondary-color), 0.05em 0 0 var(--accent-color); }
    99% { text-shadow: 0.025em 0.05em 0 var(--secondary-color), 0.05em 0 0 var(--accent-color); }
    100% { text-shadow: -0.025em 0 0 var(--secondary-color), -0.025em -0.025em 0 var(--accent-color); }
}

.multi-input-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 40px;
    width: 100%;
    max-width: 500px;
    transition: opacity 0.5s ease;
}

.input-row {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding: 5px 10px;
}

.input-row .prompt {
    font-size: 1.1rem;
    margin-right: 15px;
    opacity: 0.8;
}

#nickname-input, #node-id-input {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-size: 1.2rem;
    outline: none;
    flex-grow: 1;
}

#execute-link-btn {
    background: var(--primary-color);
    border: none;
    color: var(--bg-color);
    font-family: var(--font-heading);
    font-size: 1rem;
    padding: 15px 25px;
    cursor: pointer;
    margin-top: 10px;
    font-weight: bold;
    transition: all 0.2s ease;
    text-transform: uppercase;
    position: relative;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
    align-self: center;
}

#execute-link-btn:hover {
    box-shadow: 0 0 25px var(--primary-glow);
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.sub-text {
    margin-top: 25px;
    font-size: 0.9rem;
    opacity: 0.6;
    letter-spacing: 2px;
}

/* Post-login: terminal access shell (not file manager) */
body.sc-access-ui {
    background: #1a1a1a;
    color: #d8d8d8;
}

body.sc-access-ui .scanlines { opacity: 0.06; }
body.sc-access-ui::after { display: none; }
body.sc-access-ui #void-bg-canvas { opacity: 0.12 !important; }

body.sc-access-ui #app-container {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 8px;
    max-width: 100%;
}

/* Messenger chat — gray UI + code rain */
body.messenger-chat-ui {
    background: #3d3d40;
    color: #ececec;
    font-family: 'Ubuntu', 'Segoe UI', sans-serif;
}

body.messenger-chat-ui .scanlines,
body.messenger-chat-ui::after { display: none; }
body.messenger-chat-ui #void-bg-canvas { display: none !important; }

body.messenger-chat-ui #app-container {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

body.sc-access-ui .phase.sc-stage {
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* --- SC Terminal windows (access flow) --- */
.sc-window {
    width: 100%;
    max-width: 720px;
    background: #2a2a2a;
    border: 1px solid rgba(0, 255, 65, 0.25);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 255, 65, 0.03);
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
    min-height: 0;
}

.sc-window--wide {
    max-width: 960px;
    height: min(92%, 560px);
    max-height: 560px;
}

.sc-window--compact { max-width: 520px; }

.sc-window-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(0, 255, 65, 0.08);
    border-bottom: 1px solid rgba(0, 255, 65, 0.2);
    font: 600 11px/1 var(--font-heading);
    letter-spacing: 1.5px;
    color: var(--primary-color);
}

.sc-window-sub {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: #242424;
}

.sc-hint {
    margin: 0 0 8px;
    font-size: 11px;
    color: #9a9a9a;
}

.sc-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sc-counter {
    font: 500 11px/1 var(--font-mono);
    color: var(--primary-color);
    flex-shrink: 0;
}

.sc-window-body {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: #1e1e1e;
}

.sc-window-body--center {
    align-items: center;
    justify-content: center;
    padding: 28px 24px;
}

.sc-window-body--split {
    flex-direction: row;
}

.sc-window-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #242424;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font: 400 11px/1 var(--font-mono);
    color: #888;
}

.sc-tag {
    font: 600 10px/1 var(--font-mono);
    color: #888;
    letter-spacing: 0.08em;
}

.sc-tag--accent {
    color: var(--primary-color);
}

.sc-steps {
    width: 140px;
    flex-shrink: 0;
    background: #242424;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 8px;
}

.sc-steps-label {
    font: 600 10px/1 var(--font-mono);
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 8px 8px;
}

.sc-main-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sc-packet-col {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #242424;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.sc-load-block,
.void-load-block {
    width: 100%;
    max-width: 420px;
}

.sc-progress-bar,
.void-progress-bar {
    height: 6px;
    background: #111;
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-radius: 999px;
    overflow: hidden;
    flex: 1;
}

.loading-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.status-text {
    font: 500 13px/1.3 var(--font-mono);
    color: #e0e0e0;
}

.percentage {
    font: 500 12px/1 var(--font-mono);
    color: var(--primary-color);
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 999px;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--primary-glow);
}

#phase-loading .sc-window-foot #loading-step { color: #888; }

.void-diag-list {
    width: 100%;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}

.void-diag-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font: 500 12px/1.4 var(--font-mono);
    animation: void-diag-in 0.25s ease-out both;
}

@keyframes void-diag-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.void-diag-name { color: #ccc; }

.void-diag-status {
    font: 600 10px/1 var(--font-mono);
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 5px;
}

.void-diag-status.ok {
    color: var(--primary-color);
    background: rgba(0, 255, 65, 0.1);
}

#phase-diagnostics .sc-window-body {
    flex-direction: column;
    overflow-y: auto;
    min-height: 180px;
}

.pulse {
    animation: pulse-text 1.2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.void-step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font: 500 11px/1.3 var(--font-mono);
    color: #999;
}

.void-step-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font: 600 10px/1 var(--font-mono);
    color: #666;
    flex-shrink: 0;
}

.void-step-item.is-active {
    background: rgba(0, 255, 65, 0.1);
    color: var(--primary-color);
}

.void-step-item.is-active .void-step-icon {
    background: rgba(0, 255, 65, 0.2);
    color: var(--primary-color);
}

.void-step-item.is-done { color: #7a9a82; }

.void-step-item.is-done .void-step-icon {
    background: rgba(0, 255, 65, 0.12);
    color: #7a9a82;
}

/* Phase 3: Terminals (legacy) */
.terminal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    height: 100%;
}

.terminal-wrapper {
    background: rgba(0,0,0,0.8);
    border: 1px solid var(--primary-glow);
    display: flex;
    flex-direction: column;
}

.terminal-header {
    background: rgba(0, 255, 65, 0.2);
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: bold;
    color: #fff;
}

.terminal-content {
    flex-grow: 1;
    overflow-y: hidden;
    padding: 10px;
    font-size: 0.75rem;
    line-height: 1.2;
    color: var(--primary-color);
    text-shadow: 0 0 5px var(--primary-color);
}

.log-line {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInLog 0.1s forwards;
}

@keyframes fadeInLog {
    to { opacity: 1; transform: translateY(0); }
}

.glitch-wrapper {
    text-align: center;
    margin-bottom: 10px;
}

.input-container {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding: 5px 10px;
    font-size: 1.1rem;
    margin-top: 30px;
    width: 100%;
    max-width: 500px;
}

.input-container .prompt {
    font-size: 1.1rem;
    margin-right: 10px;
    opacity: 0.8;
    white-space: nowrap;
}

.cursor {
    width: 10px;
    height: 1.2em;
    background: var(--primary-color);
    margin-left: 4px;
    animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
    50% { opacity: 0; }
}

/* Phase 4: Chat */
#phase-chat {
    align-items: stretch;
    justify-content: flex-start;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--primary-glow);
    background: rgba(0, 255, 65, 0.05);
    flex-shrink: 0;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 15px;
    transition: all 0.5s ease;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.status-indicator.online {
    background: #00ff00;
    box-shadow: 0 0 15px #00ff00;
}

.status-indicator.offline {
    background: #ff0000;
    box-shadow: 0 0 15px #ff0000;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.chat-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    flex-grow: 1;
}

#online-nodes {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-right: 20px;
    letter-spacing: 1px;
    background: rgba(0, 212, 255, 0.1);
    padding: 4px 10px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    cursor: help;
    min-width: 28px;
    text-align: center;
}

.system-time {
    font-size: 0.8rem;
    opacity: 0.8;
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.2);
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
    border-radius: 3px;
}

.typing-indicator {
    position: absolute;
    bottom: 5px;
    left: 20px;
    font-size: 0.7rem;
    color: var(--primary-color);
    font-style: italic;
    opacity: 0.8;
    pointer-events: none;
    z-index: 5;
    height: 1.2em;
}

#jump-to-bottom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--bg-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 15px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.2);
}

.hidden { display: none !important; }

.system-msg { color: var(--accent-color); font-size: 0.8rem; opacity: 0.7; }

.message {
    padding: 8px 12px;
    border-left: 2px solid var(--primary-color);
    background: rgba(0, 255, 65, 0.02);
    animation: fadeIn 0.3s ease-out;
    align-self: flex-start;
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.message.remote {
    border-left-color: var(--accent-color);
    background: rgba(0, 212, 255, 0.02);
}

.msg-user {
    font-weight: bold;
    margin-bottom: 2px;
    color: var(--primary-color);
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.msg-meta { font-size: 0.6rem; opacity: 0.5; font-weight: normal; }

.msg-text a { color: var(--accent-color); text-decoration: underline; }

#exit-chat-btn {
    background: transparent;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    font-family: var(--font-heading);
    font-size: 0.7rem;
    padding: 2px 10px;
    cursor: pointer;
    margin-left: 15px;
}

.clearing-text {
    color: var(--error-color) !important;
    font-family: var(--font-mono);
}

#chat-input-form {
    display: flex;
    align-items: center;
    padding: 15px;
    border-top: 1px solid var(--primary-glow);
    flex-shrink: 0;
}

.chat-prompt {
    color: var(--primary-color);
    margin-right: 8px;
    opacity: 0.8;
}

#message-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 1rem;
    outline: none;
}

/* Floating Terminal Windows (DevBlog) */
.terminal-window {
    position: absolute;
    top: 100px;
    right: 50px;
    width: 450px;
    height: 500px;
    background: rgba(0, 5, 0, 0.98);
    border: 1px solid var(--primary-glow);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.9);
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.window-header {
    background: rgba(0, 255, 65, 0.1);
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    border-bottom: 1px solid var(--primary-glow);
    user-select: none;
}

.window-title {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    color: var(--primary-color);
    letter-spacing: 1.5px;
}

.win-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
}

.window-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-color);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.blog-post {
    margin-bottom: 25px;
    border-left: 1px solid rgba(0, 255, 65, 0.2);
    padding-left: 15px;
}

.blog-date {
    display: block;
    font-size: 0.65rem;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.blog-title {
    display: block;
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.blog-item {
    display: block;
    margin-bottom: 8px;
    position: relative;
    padding-left: 15px;
}

.blog-item::before {
    content: ">>";
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-size: 0.7rem;
}

@media screen and (max-width: 768px) {
    .terminal-window {
        width: 90%;
        height: 70%;
        top: 15% !important;
        right: 5% !important;
        left: 5% !important;
    }
}

.clearing-text {
    color: var(--error-color) !important;
    font-family: var(--font-mono);
}

#chat-input-form {
    display: flex;
    padding: 15px;
    border-top: 1px solid var(--primary-glow);
}

#message-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 1rem;
    outline: none;
}

/* Premium Mobile Adaptation */
@media screen and (max-width: 768px) {
    #app-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        padding: 0;
        border: none;
        background: var(--bg-color);
    }

    .vignette { opacity: 1; }

    #toggle-view-btn {
        opacity: 0.8;
        padding: 8px;
        font-size: 1.1rem;
        background: rgba(0, 255, 65, 0.15);
    }

    .glitch { font-size: 2rem; word-break: break-word; }

    .input-container { font-size: 1.1rem; flex-direction: column; align-items: stretch; width: 90%; margin: 20px auto; padding: 15px; }

    #nickname-input { width: 100%; font-size: 1.3rem; padding: 10px 0; text-align: center; }

    .terminal-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 15px; }

    .terminal-content { font-size: 0.75rem; letter-spacing: 0.5px; }

    .diagnostic-window { width: 100%; font-size: 0.85rem; }

    .chat-header { padding: 12px 10px; gap: 12px; }

    .chat-title { font-size: 0.9rem; }

    #exit-chat-btn { margin-left: auto; padding: 6px 12px; font-size: 0.7rem; }

    #chat-messages { padding: 15px 10px; }

    .message { font-size: 1rem; padding: 12px; margin-bottom: 8px; }

    #chat-input-form { padding: 15px 10px; }

    #message-input { font-size: 1rem; }
}

/* Force mobile view via class */
.mobile-view#app-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    padding: 0;
    border: none;
    background: var(--bg-color);
    z-index: 1000;
}

.mobile-view .phase { padding: 20px; }
.mobile-view #phase-chat.phase { padding: 0; }
.mobile-view #toggle-view-btn { opacity: 0.8; padding: 8px; font-size: 1.1rem; background: rgba(0, 255, 65, 0.15); }
.mobile-view .glitch { font-size: 2rem; word-break: break-word; }
.mobile-view .input-container { font-size: 1.1rem; flex-direction: column; align-items: stretch; width: 90%; margin: 20px auto; padding: 15px; }
.mobile-view #nickname-input { width: 100%; font-size: 1.3rem; padding: 10px 0; text-align: center; }
.mobile-view .terminal-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 15px; padding: 10px; }
.mobile-view .terminal-content { font-size: 0.75rem; letter-spacing: 0.5px; }
.mobile-view .diagnostic-window { width: 100%; font-size: 0.85rem; }
.mobile-view .chat-header { padding: 12px 10px; gap: 12px; }
.mobile-view .chat-title { font-size: 0.9rem; }
.mobile-view #exit-chat-btn { margin-left: auto; padding: 6px 12px; font-size: 0.7rem; }
.mobile-view #chat-messages { padding: 15px 10px; }
.mobile-view .message { font-size: 1rem; padding: 12px; margin-bottom: 8px; }
.mobile-view #chat-input-form { padding: 15px 10px; }
.mobile-view #message-input { font-size: 1rem; }

/* Attachment Button Styles */
.attach-btn {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    color: var(--primary-color);
    text-shadow: 0 0 5px var(--primary-color);
}

.attach-btn:hover { opacity: 1; transform: scale(1.1); text-shadow: 0 0 10px var(--primary-glow); }

.msg-text img {
    display: block;
    max-width: 300px;
    max-height: 200px;
    border: 1px solid var(--primary-glow);
    border-radius: 4px;
    margin-top: 8px;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
    cursor: zoom-in;
}

@media screen and (max-width: 768px) {
    .msg-text img { max-width: 100%; max-height: 250px; }
}

/* Profanity Scramble Effect */
.scrambled-word {
    color: var(--error-color);
    font-weight: bold;
    text-shadow: 0 0 5px var(--error-color);
    display: inline-block;
    padding: 0 2px;
}

.scrambled-word::before {
    content: attr(data-scramble);
    animation: scramble-text 0.15s infinite alternate;
}

@keyframes scramble-text {
    0% { content: "}@#?!-"; }
    20% { content: "$*?&{"; }
    40% { content: "@!+%="; }
    60% { content: "#?$<>"; }
    80% { content: "!&*%{"; }
    100% { content: "?@+-="; }
}

.scrambled-word.revealed { animation: blink-error 0.5s ease; }

@keyframes blink-error {
    0% { opacity: 0; }
    50% { opacity: 1; text-shadow: 0 0 15px var(--error-color); }
    100% { opacity: 1; }
}

/* Phase 5: Locked Portal UI (Global Tokens) */
.locked-container {
    max-width: 600px;
    padding: 40px;
    border: 1px solid var(--error-color);
    background: rgba(20, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 0 50px rgba(255, 0, 60, 0.3);
    text-align: center;
    border-radius: 4px;
    animation: fadeIn 0.5s ease-out;
}

.locked-msg {
    color: var(--error-color);
    font-family: var(--font-heading);
    font-size: 3rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 4px;
    animation: glitch 1s infinite alternate;
}

.ban-text {
    font-size: 1.1rem;
    color: #fff;
    opacity: 0.8;
    margin: 20px 0;
}

.ban-countdown {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 0, 65, 0.1);
    border: 1px solid rgba(255, 0, 60, 0.3);
    border-radius: 4px;
}

.countdown-label {
    display: block;
    font-size: 0.7rem;
    color: var(--error-color);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.countdown-value {
    display: block;
    font-size: 4rem;
    font-weight: bold;
    color: var(--error-color);
    text-shadow: 0 0 20px var(--error-color);
    font-family: var(--font-heading);
}

.locked-logs {
    margin-top: 30px;
    height: 120px;
    overflow-y: auto;
    font-size: 0.7rem;
    color: var(--error-color);
    opacity: 0.5;
    text-align: left;
    border-top: 1px solid rgba(255, 0, 60, 0.2);
    padding-top: 15px;
    scrollbar-width: none;
}

.locked-logs::-webkit-scrollbar { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- VOID_THEME_ENGINE: MULTI-STYLE OVERRIDES --- */

/* 1. NEON_CYBER THEME */
body.theme-neon {
    --primary-color: #ff007f; /* Neon Pink */
    --primary-glow: rgba(255, 0, 127, 0.6);
    --accent-color: #00f3ff; /* Neon Cyan */
    --secondary-color: #9d00ff; /* Deep Purple */
    --bg-color: #0a000a;
}
body.theme-neon #app-container {
    background: rgba(40, 0, 20, 0.1);
    border-color: var(--primary-glow);
}
body.theme-neon .chat-header { background: rgba(255, 0, 127, 0.05); }
body.theme-neon .message { border-left-color: var(--primary-color); background: rgba(255, 0, 127, 0.02); }

/* 2. CLASSIC_SILVER THEME */
body.theme-gray {
    --primary-color: #e0e0e0; /* Silver/Slate */
    --primary-glow: rgba(255, 255, 255, 0.1);
    --accent-color: #888888;
    --secondary-color: #444444;
    --bg-color: #1a1a1a;
}
body.theme-gray #app-container {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}
body.theme-gray .chat-header { background: rgba(255, 255, 255, 0.05); }
body.theme-gray .message { border-left-color: #888; background: rgba(255, 255, 255, 0.01); }

/* 3. STYLING_PANEL INTERFACE */
#styling-panel {
    position: absolute;
    top: 65px;
    right: -320px;
    width: 260px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid var(--primary-color);
    padding: 20px;
    z-index: 2005;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#styling-panel.open {
    right: 20px;
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.panel-label {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-glow);
    padding-bottom: 8px;
    letter-spacing: 2px;
}

.theme-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-option {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--primary-glow);
    color: var(--primary-color);
    padding: 12px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-option:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px var(--primary-glow);
}

.theme-option.active {
    background: var(--primary-color);
    color: var(--bg-color);
    font-weight: bold;
}

.preview-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-matrix { background: #00ff41; box-shadow: 0 0 5px #00ff41; }
.dot-neon { background: #ff007f; box-shadow: 0 0 5px #ff007f; }
.dot-gray { background: #e0e0e0; box-shadow: 0 0 5px #e0e0e0; }

@media screen and (max-width: 768px) {
    #styling-panel.open {
        right: 0;
        width: 100%;
        top: 60px;
    }
}

/* --- VOID_ANIMATION_ENGINE: CANVAS BACKGROUND --- */

#void-bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    display: block;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#void-bg-canvas.visible {
    opacity: 1;
}

/* Red Core Theme */
body.theme-red {
    --primary-color: #ff2525;
    --primary-glow: rgba(255, 37, 37, 0.6);
    --accent-color: #ff8800;
    --secondary-color: #880000;
    --bg-color: #0a0000;
}
body.theme-red #app-container {
    background: rgba(30, 0, 0, 0.1);
    border-color: rgba(255, 37, 37, 0.4);
}
body.theme-red .chat-header { background: rgba(255, 0, 0, 0.05); }
body.theme-red .message { border-left-color: var(--primary-color); background: rgba(255, 37, 37, 0.02); }

.dot-red { background: #ff2525; box-shadow: 0 0 5px #ff2525; }

/* --- VOID_BG_ACTIVE: Glassmorphic Overlay when animation is running --- */

body.bg-active #app-container {
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.8s ease, backdrop-filter 0.8s ease;
}

body.bg-active .chat-header {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

body.bg-active #chat-input-form {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

body.bg-active .message {
    background: rgba(0, 0, 0, 0.55) !important;
}

body.bg-active .terminal-wrapper,
body.bg-active .diagnostic-window {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Custom Exit Confirmation Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 1, 4, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #020104;
    border: 1px solid var(--error-color);
    box-shadow: 0 0 30px rgba(255, 0, 60, 0.2);
    width: 90%;
    max-width: 450px;
    padding: 25px;
    font-family: var(--font-mono);
    position: relative;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
    animation: modal-slide-in 0.3s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes modal-slide-in {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    border-bottom: 1px solid rgba(255, 0, 60, 0.3);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.warning-blink {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--error-color);
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.6);
    animation: blink-fast 1s infinite steps(2);
}

@keyframes blink-fast {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.modal-body {
    margin-bottom: 25px;
    line-height: 1.5;
}

.warning-text {
    color: var(--text-color);
    font-size: 0.95rem;
}

.warning-sub {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 10px;
    font-weight: bold;
    letter-spacing: 1px;
}

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

.modal-btn {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: bold;
    padding: 8px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    outline: none;
}

.modal-btn.confirm {
    background: rgba(255, 0, 60, 0.1);
    border-color: var(--error-color);
    color: var(--error-color);
    text-shadow: 0 0 5px rgba(255, 0, 60, 0.5);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}

.modal-btn.confirm:hover {
    background: var(--error-color);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 60, 0.5);
}

.modal-btn.cancel {
    background: rgba(0, 255, 65, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.5);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}

.modal-btn.cancel:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
}

/* --- SOCIAL CHAT: Realistic Messenger --- */
#phase-chat.active {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.msg-app {
    display: flex;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    background: #e8eaed;
    overflow: hidden;
}

.msg-sidebar {
    width: 280px;
    min-width: 240px;
    background: #f7f8fa;
    border-right: 1px solid #dce0e6;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.msg-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e4e7ec;
}

.msg-app-title {
    margin: 0;
    font: 600 16px/1.2 'Ubuntu', sans-serif;
    color: #1c1c1e;
}

.msg-online-badge {
    font: 500 11px/1 'Ubuntu Mono', monospace;
    color: #5f6368;
    background: #eef0f3;
    border: 1px solid #dce0e6;
    border-radius: 999px;
    padding: 4px 10px;
}

.msg-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 8px 10px;
}

.msg-nav-btn {
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #5f6368;
    font: 500 12px/1 'Ubuntu', sans-serif;
    padding: 8px 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.msg-nav-btn:hover {
    background: #eef0f3;
    color: #1c1c1e;
}

.msg-nav-btn.active,
.sidebar-tab.msg-nav-btn.active {
    background: #3584e4;
    color: #fff;
    box-shadow: none;
    border: none;
}

.msg-sidebar-actions {
    display: flex;
    gap: 6px;
    padding: 0 10px 8px;
}

.msg-action-btn {
    flex: 1;
    border: 1px solid #dce0e6;
    border-radius: 8px;
    background: #fff;
    color: #3c4043;
    font: 500 11px/1 'Ubuntu', sans-serif;
    padding: 7px 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.msg-action-btn:hover {
    background: #f0f2f5;
    border-color: #c8ccd2;
}

.msg-chat-list,
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 10px;
}

.msg-chat-list::-webkit-scrollbar,
.msg-thread::-webkit-scrollbar { width: 6px; }
.msg-chat-list::-webkit-scrollbar-thumb,
.msg-thread::-webkit-scrollbar-thumb { background: #c8ccd2; border-radius: 4px; }

.sidebar-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #1c1c1e;
    padding: 10px 12px;
    margin-bottom: 2px;
    cursor: pointer;
    font-family: 'Ubuntu', sans-serif;
    transition: background 0.15s;
}

.sidebar-item:hover {
    background: #eef0f3;
}

.sidebar-item.active {
    background: #dbeafe;
    border: none;
    box-shadow: none;
}

.si-title {
    font-size: 13px;
    font-weight: 500;
    color: #1c1c1e;
}

.si-sub {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    color: #9aa0a6;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 10px 8px 4px;
}

.sidebar-empty {
    font-size: 12px;
    color: #9aa0a6;
    padding: 12px 8px;
    line-height: 1.45;
}

.sidebar-request {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e4e7ec;
    margin-bottom: 6px;
    font-size: 12px;
    color: #1c1c1e;
}

.mini-btn {
    background: #f0f2f5;
    border: 1px solid #dce0e6;
    color: #3584e4;
    cursor: pointer;
    padding: 3px 8px;
    font-size: 12px;
    border-radius: 6px;
}

.mini-btn:hover { background: #e8eaed; }

.msg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #3d3d40;
}

.msg-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #f7f8fa;
    border-bottom: 1px solid #dce0e6;
    flex-shrink: 0;
}

.msg-topbar-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3584e4, #1a5fb4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: #fff;
}

.msg-channel-name {
    font: 600 15px/1.25 'Ubuntu', sans-serif;
    color: #1c1c1e;
}

.msg-channel-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font: 400 12px/1 'Ubuntu', sans-serif;
    color: #6b7280;
}

.msg-topbar .status-indicator {
    width: 8px;
    height: 8px;
    margin: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.msg-topbar .status-indicator.online {
    background: #34a853;
    box-shadow: none;
}

.msg-topbar .status-indicator.offline {
    background: #ea4335;
    animation: none;
    opacity: 0.85;
}

.msg-topbar-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.msg-tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
    opacity: 0.7;
    transition: background 0.15s, opacity 0.15s;
}

.msg-tool-btn:hover {
    background: #eef0f3;
    opacity: 1;
}

.msg-exit-btn {
    border: 1px solid #dce0e6;
    border-radius: 8px;
    background: #fff;
    color: #c5221f;
    font: 500 12px/1 'Ubuntu', sans-serif;
    padding: 7px 12px;
    cursor: pointer;
    margin-left: 4px;
}

.msg-exit-btn:hover {
    background: #fce8e6;
    border-color: #f5c2c0;
}

.msg-thread-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #38383b;
}

.msg-thread,
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: #5a5a5f transparent;
    background: #38383b;
}

.msg-bubble {
    max-width: 72%;
    padding: 8px 12px 6px;
    border-radius: 14px;
    font: 400 14px/1.45 'Ubuntu', sans-serif;
    animation: msg-in 0.2s ease-out;
    word-break: break-word;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-bubble.message {
    border-left: none;
}

.msg-bubble--in {
    align-self: flex-start;
    background: #48484c;
    color: #ececec;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.msg-bubble--out {
    align-self: flex-end;
    background: #3584e4;
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(53, 132, 228, 0.25);
}

.msg-bubble-author {
    font: 600 11px/1.2 'Ubuntu', sans-serif;
    color: #3584e4;
    margin-bottom: 4px;
}

.msg-bubble-body a { color: inherit; text-decoration: underline; }
.msg-bubble--out .msg-bubble-body a { color: #dbeafe; }

.msg-bubble-time {
    display: block;
    font: 400 10px/1 'Ubuntu Mono', monospace;
    margin-top: 4px;
    opacity: 0.55;
    text-align: right;
}

.msg-bubble--in .msg-bubble-time { color: #9aa0a6; }
.msg-bubble--out .msg-bubble-time { color: rgba(255, 255, 255, 0.75); }

.msg-bubble-body img,
.msg-text img {
    display: block;
    max-width: 260px;
    max-height: 200px;
    border-radius: 10px;
    margin-top: 6px;
    cursor: zoom-in;
    border: none;
    box-shadow: none;
}

.system-msg {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font: 400 12px/1.4 'Ubuntu', sans-serif;
    color: #a8a8ad;
    background: rgba(56, 56, 59, 0.85);
    border: 1px solid #5a5a5f;
    border-radius: 999px;
    padding: 6px 14px;
    opacity: 1;
}

.msg-typing,
.typing-indicator {
    position: absolute;
    bottom: 8px;
    left: 18px;
    font: 400 12px/1 'Ubuntu', sans-serif;
    font-style: normal;
    color: #6b7280;
    opacity: 0.9;
    pointer-events: none;
    z-index: 5;
}

.msg-jump,
#jump-to-bottom {
    position: absolute;
    bottom: 12px;
    right: 16px;
    background: #fff;
    color: #3584e4;
    border: 1px solid #dce0e6;
    border-radius: 999px;
    padding: 8px 14px;
    font: 500 11px/1 'Ubuntu', sans-serif;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.msg-jump:hover,
#jump-to-bottom:hover {
    background: #f0f2f5;
}

.msg-composer,
#chat-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 12px;
    background: #f7f8fa;
    border-top: 1px solid #dce0e6;
    flex-shrink: 0;
}

.msg-composer-attach,
.attach-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.65;
    color: #5f6368;
    text-shadow: none;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}

.msg-composer-attach:hover,
.attach-btn:hover {
    opacity: 1;
    background: #eef0f3;
    transform: none;
    box-shadow: none;
}

#message-input {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid #dce0e6;
    border-radius: 20px;
    color: #1c1c1e;
    font: 400 14px/1.4 'Ubuntu', sans-serif;
    padding: 10px 16px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#message-input:focus {
    border-color: #3584e4;
    box-shadow: 0 0 0 2px rgba(53, 132, 228, 0.15);
}

#message-input::placeholder { color: #9aa0a6; }

.msg-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #3584e4;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.msg-send-btn:hover {
    background: #1a5fb4;
}

.msg-send-btn:active {
    transform: scale(0.96);
}

/* SecureChat gray theme + code rain */
body.messenger-chat-ui {
    --msg-bg: #3d3d40;
    --msg-panel: #48484c;
    --msg-sidebar: #424246;
    --msg-border: #5a5a5f;
    --msg-text: #ececec;
    --msg-muted: #a8a8ad;
    --msg-accent: #6ba3e0;
    --msg-accent-dark: #4a7fb8;
}

body.messenger-chat-ui .msg-app {
    background: var(--msg-bg);
}

body.messenger-chat-ui .msg-sidebar,
body.messenger-chat-ui .msg-topbar,
body.messenger-chat-ui .msg-composer {
    background: var(--msg-panel);
    border-color: var(--msg-border);
}

body.messenger-chat-ui .msg-main {
    background: var(--msg-bg);
}

body.messenger-chat-ui .msg-app-title {
    color: var(--msg-text);
}

body.messenger-chat-ui .msg-app-title::before {
    background: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 255, 65, 0.15);
}

body.messenger-chat-ui .msg-online-badge {
    background: rgba(0, 255, 65, 0.1);
    border-color: rgba(0, 255, 65, 0.25);
    color: var(--primary-color);
}

body.messenger-chat-ui .msg-nav-btn {
    color: var(--msg-muted);
}

body.messenger-chat-ui .msg-nav-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--msg-text);
}

body.messenger-chat-ui .msg-nav-btn.active,
body.messenger-chat-ui .sidebar-tab.msg-nav-btn.active {
    background: var(--msg-accent);
    color: #fff;
    box-shadow: none;
}

body.messenger-chat-ui .msg-action-btn {
    background: #55555a;
    border-color: var(--msg-border);
    color: var(--msg-text);
}

body.messenger-chat-ui .msg-action-btn:hover {
    background: #5f5f64;
}

body.messenger-chat-ui .sidebar-item {
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 10px;
    color: var(--msg-text);
}

body.messenger-chat-ui .sidebar-item::before {
    content: attr(data-avatar);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    font: 700 12px/1 'Ubuntu', sans-serif;
    background: var(--msg-accent);
}

body.messenger-chat-ui .sidebar-item[data-channel^="global"]::before { content: "#"; }
body.messenger-chat-ui .sidebar-item[data-channel^="clan"]::before {
    content: "⚑";
    background: #c45a20;
}

body.messenger-chat-ui .sidebar-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

body.messenger-chat-ui .sidebar-item.active {
    background: rgba(107, 163, 224, 0.18);
    box-shadow: inset 3px 0 0 var(--msg-accent);
}

body.messenger-chat-ui .si-title { color: var(--msg-text); }
body.messenger-chat-ui .si-sub { color: var(--msg-muted); }

body.messenger-chat-ui .msg-channel-name { color: var(--msg-text); }
body.messenger-chat-ui .msg-channel-meta { color: var(--msg-muted); }

body.messenger-chat-ui .msg-avatar {
    border-radius: 12px;
    background: var(--msg-accent);
    box-shadow: none;
}

body.messenger-chat-ui .msg-tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.messenger-chat-ui .msg-exit-btn {
    background: #55555a;
    border-color: var(--msg-border);
    color: #f28b82;
}

body.messenger-chat-ui .msg-thread-wrap {
    position: relative;
    background: #38383b;
}

#msg-code-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#msg-code-canvas.is-active {
    opacity: 1;
}

body.messenger-chat-ui .msg-thread {
    position: relative;
    z-index: 1;
    background: #38383b;
    padding: 18px 20px 10px;
}

body.messenger-chat-ui .msg-bubble--in {
    background: rgba(72, 72, 76, 0.92);
    color: var(--msg-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.messenger-chat-ui .msg-bubble--out {
    background: linear-gradient(135deg, var(--msg-accent), var(--msg-accent-dark));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

body.messenger-chat-ui .msg-bubble-author {
    color: var(--msg-accent);
}

body.messenger-chat-ui .system-msg {
    background: rgba(56, 56, 59, 0.85);
    color: var(--msg-muted);
    border: 1px solid var(--msg-border);
}

body.messenger-chat-ui .msg-typing,
body.messenger-chat-ui .typing-indicator {
    color: var(--msg-muted);
    z-index: 2;
}

body.messenger-chat-ui .msg-jump,
body.messenger-chat-ui #jump-to-bottom {
    background: var(--msg-panel);
    color: var(--msg-accent);
    border-color: var(--msg-border);
    z-index: 3;
}

body.messenger-chat-ui #message-input {
    background: #55555a;
    border-color: var(--msg-border);
    color: var(--msg-text);
}

body.messenger-chat-ui #message-input::placeholder {
    color: #888;
}

body.messenger-chat-ui #message-input:focus {
    border-color: var(--msg-accent);
    box-shadow: 0 0 0 2px rgba(107, 163, 224, 0.2);
}

body.messenger-chat-ui .msg-send-btn {
    background: var(--msg-accent);
}

body.messenger-chat-ui .msg-send-btn:hover {
    background: var(--msg-accent-dark);
}

body.messenger-chat-ui .msg-composer-attach {
    color: var(--msg-muted);
}

body.messenger-chat-ui .sidebar-section-title {
    color: var(--msg-muted);
}

body.messenger-chat-ui .sidebar-empty {
    color: var(--msg-muted);
}

body.messenger-chat-ui .msg-sidebar-head {
    border-color: var(--msg-border);
}

body.messenger-chat-ui .msg-chat-list::-webkit-scrollbar-thumb,
body.messenger-chat-ui .msg-thread::-webkit-scrollbar-thumb {
    background: #5a5a5f;
}

body.messenger-chat-ui .mini-btn {
    background: #55555a;
    border-color: var(--msg-border);
    color: var(--msg-accent);
}

body.messenger-chat-ui .mini-btn:hover {
    background: #5f5f64;
}

body.messenger-chat-ui .theme-option.active {
    background: rgba(107, 163, 224, 0.2);
    border-color: var(--msg-accent);
    color: var(--msg-text);
}

@media (prefers-reduced-motion: reduce) {
    .msg-bubble,
    .msg-bubble:hover,
    .msg-send-btn,
    .sidebar-item {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
    #msg-code-canvas { display: none !important; }
}

/* Modals in messenger mode */
body.messenger-chat-ui .social-modal-content,
body.messenger-chat-ui #shred-confirm-modal .modal-content {
    background: #48484c;
    border: 1px solid #5a5a5f;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    color: #ececec;
}

body.messenger-chat-ui #social-modal-title {
    color: #ececec;
    font-family: 'Ubuntu', sans-serif;
    text-shadow: none;
}

body.messenger-chat-ui .social-form-input {
    background: #55555a;
    border-color: #5a5a5f;
    color: #ececec;
}

body.messenger-chat-ui #styling-panel {
    background: #48484c;
    border-color: #5a5a5f;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

body.messenger-chat-ui .theme-option {
    color: #ccc;
    border-color: #5a5a5f;
}

@media (max-width: 768px), #app-container.mobile-view {
    .msg-app { flex-direction: column; }
    .msg-sidebar {
        width: 100%;
        max-height: 38%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #dce0e6;
    }
    .msg-bubble { max-width: 88%; }
}

.social-modal-content {
    max-width: 420px;
    border-color: var(--primary-color);
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.15);
}

.social-modal-content .modal-header {
    border-bottom-color: rgba(0, 255, 65, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#social-modal-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

#social-modal-close {
    background: transparent;
    border: 1px solid rgba(0, 255, 65, 0.3);
    color: var(--primary-color);
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    transition: all 0.2s ease;
}

#social-modal-close:hover {
    opacity: 1;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.social-form-desc {
    color: var(--text-color);
    font-size: 0.82rem;
    opacity: 0.85;
    margin-bottom: 18px;
    line-height: 1.5;
}

.social-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.social-form-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    letter-spacing: 2px;
    color: var(--accent-color);
}

.social-form-input {
    background: rgba(0, 255, 65, 0.04);
    border: 1px solid rgba(0, 255, 65, 0.25);
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
}

.social-form-input::placeholder {
    color: rgba(0, 255, 65, 0.25);
}

.social-form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

.social-form-hint {
    font-size: 0.65rem;
    color: #666;
    letter-spacing: 0.5px;
}

.modal-btn.social-submit {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 255, 65, 0.08);
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.4);
}

.modal-btn.social-submit:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
}

#social-modal.open { display: flex; }

@media (max-width: 768px), #app-container.mobile-view {
    .chat-layout { flex-direction: column; }
    .chat-sidebar { width: 100%; max-height: 35%; border-right: none; border-bottom: 1px solid rgba(0,255,65,0.2); }
}

/* --- Breach terminal (inside void-panel) --- */
#phase-breach.phase {
    overflow: hidden;
}

.void-breach-progress-bar {
    height: 3px;
    background: #1a1722;
    border-radius: 999px;
    overflow: hidden;
}

#void-breach-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    transition: width 0.15s ease;
    box-shadow: 0 0 8px var(--primary-glow);
}

.void-breach-terminal {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #1a1722;
    cursor: text;
    position: relative;
}

.void-breach-term-head {
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font: 500 11px/1 var(--void-files-mono);
    color: var(--void-files-dim);
    background: #25222c;
    flex-shrink: 0;
}

.void-breach-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    font: 400 11px/1.55 var(--void-files-mono);
    min-height: 0;
}

.void-breach-output::-webkit-scrollbar { width: 5px; }
.void-breach-output::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.void-breach-line {
    margin-bottom: 3px;
    word-break: break-all;
}

.void-breach-prompt {
    color: var(--void-files-dim);
    margin-right: 6px;
}

.void-breach-line--done { color: #b8c9bf; }
.void-breach-line--auto { color: #8ec4d8; }
.void-breach-line--sys {
    color: var(--void-files-muted);
    font-size: 10px;
    letter-spacing: 0.04em;
    margin: 6px 0;
}
.void-breach-line--pin {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 255, 65, 0.35);
    background: rgba(0, 255, 65, 0.08);
    color: var(--primary-color);
    font: 500 11px/1.4 var(--font-mono);
    border-radius: 6px;
}

.void-breach-active {
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.25);
    font: 400 11px/1.4 var(--void-files-mono);
    white-space: nowrap;
    overflow: hidden;
    min-height: 28px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.void-breach-typed { color: #d6d4db; }
.void-breach-ghost { color: rgba(255, 255, 255, 0.22); }

.void-breach-caret {
    display: inline-block;
    width: 6px;
    height: 13px;
    background: var(--void-files-accent-soft);
    animation: void-breach-cursor 0.75s step-end infinite;
    margin-left: 1px;
    vertical-align: middle;
}

@keyframes void-breach-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.void-breach-input {
    position: absolute;
    left: 12px;
    bottom: 8px;
    width: calc(100% - 24px);
    height: 24px;
    opacity: 0;
    border: none;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    outline: none;
}

.void-breach-packet-head {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font: 600 10px/1 var(--void-files-ui);
    letter-spacing: 0.06em;
    color: var(--void-files-dim);
    text-transform: uppercase;
    flex-shrink: 0;
}

.void-breach-packets {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    font: 400 10px/1.4 var(--void-files-mono);
    min-height: 0;
}

.void-breach-packets::-webkit-scrollbar { width: 4px; }
.void-breach-packets::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); }

.void-breach-packet-line {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    animation: void-breach-packet-in 0.2s ease-out both;
}

@keyframes void-breach-packet-in {
    from { opacity: 0; transform: translateX(4px); }
    to { opacity: 1; transform: translateX(0); }
}

.void-breach-packet-wait {
    color: var(--void-files-dim);
    font-style: italic;
}

.void-breach-packet-cmd {
    color: #9b99a0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.void-breach-packet-status {
    color: var(--void-files-code-dim);
    flex-shrink: 0;
}

.void-breach-packet-line--ok .void-breach-packet-status {
    color: var(--void-files-code);
}

.void-breach-live {
    color: #c44a1a;
    font-size: 11px;
}

#phase-breach.is-complete .void-breach-terminal {
    box-shadow: inset 0 0 0 1px rgba(233, 84, 32, 0.25);
}

@media (max-width: 768px), #app-container.mobile-view {
    .void-panel--wide {
        height: auto;
        max-height: none;
    }
    .void-panel-body { flex-direction: column; }
    .void-panel-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 6px;
    }
    .void-sidebar-section { flex-direction: row; gap: 4px; }
    .void-sidebar-label { display: none; }
    .void-step-item { white-space: nowrap; padding: 5px 8px; }
    .void-panel-aside {
        width: 100%;
        max-height: 120px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }
    .void-breach-output { max-height: 180px; }
}

