@import url('./messages.css');

/* --- CSS Variables --- */
:root {
    --green: #22c55e;
    --blue: #0ea5e9;
    --red: #ef4444;
    --purple: #8b5cf6;
    --amber: #f59e0b;
    --dark-bg: #000000;
    --theme-primary-color: var(--green); /* Default theme color */
    --theme-primary-rgb: 34, 197, 94; /* Default theme color in RGB */
    --theme-matrix-color: #22c55e; /* Default matrix color */
    --text-scale: 1; /* User-defined text scale */
    --mobile-nav-height: 80px; /* Space for the mobile navbar */
    --chat-input-height: 70px; /* Space for the chat input */
    --header-height: 65px; /* Approximate height of the header */
    --room-primary-color: var(--purple);
    --keyboard-offset: 0px;
    --red-rgb: 239, 68, 68;
    --blue-rgb: 14, 165, 233;
    --amber-rgb: 245, 158, 11;

    /* Base Theme Variables */
    --bg-base-100: #000000; /* Amoled Black */
    --bg-base-200: #0a0a0a;
    --bg-base-300: #1a1a1a;
    --bg-shell: rgba(0,0,0,0.7); /* Glassmorphic background for dark mode */
    --text-base: #e2e8f0;
    --text-muted: #94a3b8;
    --border-base: rgba(255, 255, 255, 0.1);
}

/* --- Base Styles --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll */
    background-color: #000;
}
body {
    font-family: 'Inter', sans-serif;
    color: var(--text-base);
    font-size: calc(16px * var(--text-scale));
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-size: calc(1em * var(--text-scale)); /* Scale headers */
}

body.theme-transition,
body.theme-transition * {
    transition: color 0.5s ease, background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease !important;
}

.font-mono {
    font-family: 'Share Tech Mono', monospace;
}

/* --- Thematic Scrollbar --- */
::-webkit-scrollbar {
    width: 12px;
    background-color: rgba(0, 0, 0, 0.3);
}
::-webkit-scrollbar-thumb {
    background: var(--theme-primary-color);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
    box-shadow: 0 0 10px var(--theme-primary-color);
}
::-webkit-scrollbar-track {
    background: transparent;
}


/* --- Main App Layout --- */
#app-container {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar page";
    height: 100vh; /* Full viewport height */
    width: 100vw; /* Full viewport width */
    background-color: transparent;
    position: relative;
    z-index: 2;
}

#app-container.app-enter {
    animation: app-fade-in 0.8s ease-out forwards;
}

@keyframes app-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

#sidebar-container, #header-container {
    background-color: var(--bg-shell);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-color: var(--border-base);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

#sidebar-container {
    grid-area: sidebar;
    width: 16rem;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    border-right-width: 1px;
}
@media (min-width: 1024px) {
    #sidebar-container {
        width: 18rem;
    }
}

#header-container {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom-width: 1px;
    z-index: 20;
}

#page-container {
    grid-area: page;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    display: flex; /* Use flex to allow content to grow */
    flex-direction: column;
    background-color: transparent;
    transition: background-color 0.5s ease;
}
@media (min-width: 1024px) {
    #page-container {
        padding: 2rem;
    }
}
@media (min-width: 1440px) {
    #page-container {
        padding: 2.5rem;
    }
}


#page-content-wrapper {
    width: 100%;
    margin: 0 auto; /* Center the content */
    flex-grow: 1; /* Allow the wrapper to grow */
    display: flex;
    flex-direction: column;
}


@media (max-width: 767px) {
    #app-container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr auto;
        grid-template-areas:
            "header"
            "page"
            "mobile-nav";
    }
    #sidebar-container { display: none; }
    #page-container { padding: 1rem; }
    #header-container { padding: 1rem; }
    #mobile-nav-container { grid-area: mobile-nav; }
}

/* --- Mobile Nav / Chat Input Padding --- */
body:not(.in-chat-view) #page-container {
    padding-bottom: calc(var(--mobile-nav-height) + 1rem);
}
body.in-chat-view #page-container {
    padding-bottom: calc(var(--chat-input-height) + 1rem);
}

#back-to-previous-page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}


/* --- UI Components --- */
.terminal-bg-post {
    background-color: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    padding: 0.25rem;
}

.terminal-bg-post:hover {
    border-color: rgba(var(--theme-primary-rgb), 0.5);
    box-shadow: 0 0 25px rgba(0,0,0,0.7), inset 0 0 20px rgba(var(--theme-primary-rgb), 0.2);
}

.terminal-bg-post:hover .scanline {
    top: 100%;
    opacity: 0;
}

.post-corner {
    position: absolute;
    width: 15px;
    height: 15px;
    border-color: var(--theme-primary-color);
    border-style: solid;
    opacity: 0.3;
    transition: opacity 0.4s ease;
}
.terminal-bg-post:hover .post-corner {
    opacity: 0.8;
}
.corner-top-left { top: 5px; left: 5px; border-width: 2px 0 0 2px; }
.corner-top-right { top: 5px; right: 5px; border-width: 2px 2px 0 0; }
.corner-bottom-left { bottom: 5px; left: 5px; border-width: 0 0 2px 2px; }
.corner-bottom-right { bottom: 5px; right: 5px; border-width: 0 2px 2px 0; }

.scanline {
    position: absolute;
    top: -10%;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--theme-primary-color);
    box-shadow: 0 0 10px var(--theme-primary-color);
    opacity: 0;
    transition: all 1.5s cubic-bezier(0.2, 1, 0.2, 1);
    z-index: 2;
}

.post-header { padding: 1rem 1.5rem; background: rgba(0,0,0,0.02); }
.post-header .font-bold { color: var(--theme-primary-color); }
.post-body {
    padding: 1.5rem;
    font-size: calc(clamp(0.9rem, 2.5vw, 1rem) * var(--text-scale));
}

.post-footer { padding: 0 1.5rem 1rem 1.5rem; }

.primary-glow {
    text-shadow: 0 0 8px var(--theme-primary-color);
}

.page-content {
    animation: fade-in-up-anim 0.5s ease-out;
    flex-grow: 1; /* Allow page content to fill remaining space in page-container */
    display: flex;
    flex-direction: column;
}
.page-content h3 {
    color: var(--theme-primary-color);
}

.themed-text, .echo-btn.echoed {
    color: var(--theme-primary-color);
}

.profile-callsign {
    color: var(--theme-primary-color);
    opacity: 0.7;
}

.custom-select-wrapper { position: relative; display: inline-block; }
.custom-select { appearance: none; -webkit-appearance: none; background-color: var(--bg-base-200); border: 1px solid var(--theme-primary-color); color: var(--theme-primary-color); padding: calc(0.5rem * var(--text-scale)) calc(2.5rem * var(--text-scale)) calc(0.5rem * var(--text-scale)) calc(1rem * var(--text-scale)); border-radius: 0.25rem; cursor: pointer; font-family: 'Share Tech Mono', monospace; font-size: calc(1em * var(--text-scale)); }
.custom-select-wrapper::after { content: '\f078'; font-family: 'Font Awesome 5 Free'; font-weight: 900; position: absolute; top: 50%; right: 1rem; transform: translateY(-50%); color: var(--theme-primary-color); pointer-events: none; }


/* --- Mobile Navigation --- */
.mobile-nav {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 400px;
    height: 65px;
    border-radius: 10px;
    padding: 0 calc(0.5rem * var(--text-scale));
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease;
}
.mobile-nav.hidden-nav {
    transform: translateX(-50%) translateY(120px);
    opacity: 0;
    pointer-events: none;
}
.mobile-nav .nav-button.active {
    color: var(--theme-primary-color);
    transform: scale(1.1);
}
.mobile-nav .nav-button .text-xs {
    font-size: calc(0.75rem * var(--text-scale));
}
.mobile-nav .nav-button .text-xl {
    font-size: calc(1.25rem * var(--text-scale));
}

body.in-chat-view #mobile-nav-container {
    display: none;
}

.glass-container-nav {
    background: var(--bg-shell);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-base);
}

.sidebar-logo-container {
    text-align: center;
    margin-bottom: 3rem;
    font-family: 'Share Tech Mono', monospace;
    font-weight: bold;
}

.logo-cyber-glitch, .logo-nexus-glitch {
    position: relative;
    color: var(--theme-primary-color);
    text-shadow: 0 0 8px var(--theme-primary-color);
    animation: flicker 3s infinite alternate;
}
.flicker-off .logo-cyber-glitch, .flicker-off .logo-nexus-glitch {
    animation: none;
}

.logo-cyber-glitch { font-size: 2.5rem; }
.logo-nexus-glitch { font-size: 1.8rem; letter-spacing: 0.5em; }

.logo-cyber-glitch::before, .logo-cyber-glitch::after,
.logo-nexus-glitch::before, .logo-nexus-glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: hidden;
}

.flicker-off .logo-cyber-glitch::before, .flicker-off .logo-cyber-glitch::after,
.flicker-off .logo-nexus-glitch::before, .flicker-off .logo-nexus-glitch::after {
    display: none;
}

.logo-cyber-glitch::before { left: 2px; text-shadow: -2px 0 var(--red); animation: glitch-anim-1 2s infinite linear alternate-reverse; }
.logo-cyber-glitch::after { left: -2px; text-shadow: -2px 0 var(--blue); animation: glitch-anim-2 2s infinite linear alternate-reverse; }
.logo-nexus-glitch::before { left: 1px; text-shadow: -1px 0 var(--red); animation: glitch-anim-2 3s infinite linear alternate-reverse; }
.logo-nexus-glitch::after { left: -1px; text-shadow: 1px 0 var(--blue); animation: glitch-anim-1 3s infinite linear alternate-reverse; }

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.sidebar-nav-list li {
    animation: nav-item-enter 0.5s ease-out forwards;
    opacity: 0;
    transform: translateX(-20px);
    animation-delay: calc(var(--animation-order) * 100ms + 300ms);
}
@keyframes nav-item-enter {
    to { opacity: 1; transform: translateX(0); }
}

.nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    overflow: hidden;
    background: transparent;
    border: 1px solid transparent;
}
.nav-button:hover {
    color: var(--text-base);
    background-color: rgba(var(--theme-primary-rgb), 0.05);
}
.nav-button.active {
    color: var(--theme-primary-color);
    background-color: rgba(var(--theme-primary-rgb), 0.1);
    border-color: var(--theme-primary-color);
}

.nav-button .nav-icon {
    font-size: 1.125rem; /* text-lg */
    width: 2rem; /* w-8 */
    text-align: center;
    transition: transform 0.3s ease;
}
.nav-button .nav-text {
    margin-left: 0.75rem; /* ml-3 */
    transition: letter-spacing: 0.3s ease;
}
.nav-button:hover .nav-icon {
    transform: scale(1.1);
}
.nav-button.active .nav-icon {
    animation: icon-pop 0.4s ease-out;
}
.nav-button:hover .nav-text {
    letter-spacing: 0.05em;
}
@keyframes icon-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2) rotate(-10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.notification-badge {
    position: absolute;
    top: 10px;
    right: 15px;
    background-color: var(--red);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: pulse-badge 1.5s infinite;
}

@keyframes pulse-badge {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.avatar-container {
    animation: avatar-enter 0.5s ease-out;
    border-radius: 50%;
    overflow: hidden;
}
.avatar {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

@keyframes avatar-enter {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

#matrix-background {
    z-index: 0;
    background-color: transparent;
}

.visual-filter-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: linear-gradient(rgba(18, 16, 16, 0.1) 50%, rgba(0, 0, 0, 0.35) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.08), rgba(0, 255, 0, 0.04), rgba(0, 0, 255, 0.08));
    background-size: 100% 3px, 5px 100%;
    z-index: 1;
    pointer-events: none;
    transition: background-image 0.5s ease;
}

#loading-screen {
    background: transparent;
    overflow: hidden;
}

#loading-screen.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.glass-container {
    font-family: 'Share Tech Mono', monospace;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.25);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 0 25px rgba(var(--theme-primary-rgb), 0.1);
    position: relative;
}

#boot-container {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 35px rgba(var(--theme-primary-rgb), 0.15);
    padding: 0;
    transition: transform 0.5s ease-in, opacity 0.5s ease-in;
}

#boot-container.boot-exit {
    transform: scale(0.9);
    opacity: 0;
}

#boot-container::before, #boot-container::after {
    content: '';
    position: absolute;
    width: 25px; height: 25px;
    border-color: var(--theme-primary-color);
    border-style: solid;
    opacity: 0.7;
}
#boot-container::before { top: -5px; left: -5px; border-width: 2px 0 0 2px; }
#boot-container::after { bottom: -5px; right: -5px; border-width: 0 2px 2px 0; }

#boot-header {
    border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.25);
}
#boot-title {
    font-size: 2rem;
    margin: 0;
    animation: flicker 3s infinite alternate;
    color: var(--theme-primary-color);
    text-shadow: 0 0 10px var(--theme-primary-color);
}
.boot-log-item {
    display: flex;
    justify-content: space-between;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}
.boot-log-item.visible {
    opacity: 1;
    transform: translateX(0);
}
.boot-log-status {
    font-weight: bold;
}
.boot-log-status.pending {
    color: var(--amber);
    animation: pulse-pending 1.5s infinite;
}
.boot-log-status.ok {
    color: var(--theme-primary-color);
}
.boot-log-status.failed {
    color: var(--red);
}
@keyframes pulse-pending {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.create-post-container {
    padding: 1rem;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
    position: relative;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.create-post-container #post-content-input {
    min-height: 48px;
    height: 48px; /* Initial height */
    overflow: hidden;
    color: var(--text-base);
}


.create-post-actions {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-in-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
}

.create-post-container.active {
    border-color: var(--theme-primary-color);
    box-shadow: 0 0 20px rgba(0,0,0,0.5), inset 0 0 15px rgba(var(--theme-primary-rgb), 0.5);
}

.create-post-container.active #post-content-input {
    height: 120px; /* Expanded height */
}

.create-post-container.active .create-post-actions {
    max-height: 100px;
    opacity: 1;
    transform: translateY(0);
    margin-top: 0.75rem;
}

.close-create-post-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #64748b;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: scale(0.8);
}
.create-post-container.active .close-create-post-btn {
    opacity: 1;
    transform: scale(1);
}
.close-create-post-btn:hover {
    color: var(--red);
    transform: scale(1.1) rotate(90deg);
}

.comments-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out, padding 0.5s ease-in-out;
    border-top: 1px solid var(--border-base);
    margin-top: 1rem;
}
.comments-section.open {
    max-height: 2000px; /* Increased max-height */
    opacity: 1;
}
.comments-list-wrapper {
    padding: 1.5rem;
}
.comment-container {
    animation: comment-appear-anim 0.4s ease-out forwards;
}
.comment-body {
    background-color: rgba(var(--theme-primary-rgb), 0.05);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.2);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.comment-container:hover .comment-body {
    background-color: rgba(var(--theme-primary-rgb), 0.1);
    border-color: rgba(var(--theme-primary-rgb), 0.4);
}

.load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem auto;
    font-family: 'Share Tech Mono', monospace;
    color: var(--theme-primary-color);
    background-color: transparent;
    border: 1px solid var(--theme-primary-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
    width: 150px;
    height: 40px;
}
.load-more-btn:hover {
    background-color: rgba(var(--theme-primary-rgb), 0.1);
    box-shadow: 0 0 10px rgba(var(--theme-primary-rgb), 0.5);
}
.load-more-btn.loading .load-more-text {
    transform: translateY(-150%);
}
.load-more-btn.loading .load-more-spinner {
    transform: translateY(0);
}
.load-more-text, .load-more-spinner {
    transition: transform 0.3s ease;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.load-more-spinner {
    transform: translateY(150%);
}


/* Chat Input Container */
.chat-input-form-container {
    position: fixed;
    bottom: var(--keyboard-offset); /* Responsive to keyboard */
    left: 16rem; /* Match sidebar width */
    right: 0;
    z-index: 10;
    padding: 0.75rem;
    background: linear-gradient(to top, var(--bg-base-100) 50%, transparent);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), bottom 0.3s ease-in-out;
    height: var(--chat-input-height);
    display: flex; /* Ensure it's a flex container for alignment */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
}

@media (min-width: 1024px) {
    .chat-input-form-container {
        left: 18rem; /* Match lg sidebar width */
    }
}
@media (max-width: 767px) {
    .chat-input-form-container {
        left: 0;
    }
}


.chat-input-form-container.hidden-nav {
    transform: translateY(120px);
}

body.keyboard-visible .chat-input-form-container {
    bottom: var(--keyboard-offset, 0px);
}

.chat-input-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-base-200);
    border: 1px solid var(--border-base);
    border-radius: 0.375rem;
    padding: 0.5rem;
    width: 100%; /* Ensure it takes full width of its container */
    max-width: 900px; /* Limit width on larger screens */
}
.chat-input-form.timed-out {
    border-color: var(--amber);
}
.chat-input-form.timed-out #chat-message-input::placeholder {
    color: var(--amber);
    opacity: 0.8;
}

.chat-input-prefix {
    font-family: 'Share Tech Mono', monospace;
    color: var(--theme-primary-color);
}
.in-room-theme .chat-input-prefix {
    color: var(--room-primary-color);
}

#chat-message-input {
    background: transparent;
    border: none;
    color: var(--text-base);
    flex-grow: 1;
    font-family: 'Share Tech Mono', monospace;
    caret-color: var(--theme-primary-color);
}

#chat-message-input:focus {
    outline: none;
    box-shadow: none;
    ring: 0;
}

.chat-input-submit-btn {
    background-color: var(--theme-primary-color);
    color: #000;
    border: none;
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.2s ease;
}
.in-room-theme .chat-input-submit-btn {
    background-color: var(--room-primary-color);
}

.chat-input-submit-btn:hover {
    filter: brightness(1.2);
}


.admin-badge {
    font-size: 0.65rem;
    font-weight: bold;
    color: #fff;
    background-color: var(--theme-primary-color);
    padding: 2px 5px;
    border-radius: 4px;
    text-shadow: none;
    margin-left: 0.5rem;
}
.in-room-theme .admin-badge {
    background-color: var(--room-primary-color);
}
.timeout-badge {
    font-size: 0.65rem;
    font-weight: bold;
    color: #fff;
    background-color: var(--amber);
    padding: 2px 5px;
    border-radius: 4px;
    text-shadow: none;
    margin-left: 0.5rem;
    position: relative;
}

.timeout-badge .timeout-details {
    visibility: hidden;
    width: 140px;
    background-color: var(--bg-base-300);
    color: var(--text-base);
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -70px;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    transform: translateY(10px);
}

.timeout-badge:hover .timeout-details {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.5s;
}


.system-log {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    text-align: center;
    color: var(--amber);
    opacity: 0.7;
    margin: 0.5rem 0;
    animation: chat-message-appear 0.4s ease-out;
}
.system-log .fa-sign-in-alt { color: var(--theme-primary-color); }
.system-log .fa-sign-out-alt { color: var(--red); }
.system-log .fa-user-slash { color: var(--red); }
.system-log .fa-user-shield { color: var(--theme-primary-color); }
.system-log .fa-user-clock { color: var(--amber); }

#scroll-to-bottom {
    position: fixed;
    bottom: calc(var(--chat-input-height) + 1.5rem);
    right: 1.5rem;
    width: 44px;
    height: 44px;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    color: var(--theme-primary-color);
    border: 1px solid var(--theme-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s, box-shadow 0.3s;
    transform: translateY(120px);
    opacity: 0;
    z-index: 15;
    box-shadow: 0 0 10px var(--theme-primary-color);
}
#scroll-to-bottom.visible {
    transform: translateY(0);
    opacity: 1;
}
#scroll-to-bottom:hover {
    background-color: var(--theme-primary-color);
    color: black;
    transform: scale(1.1);
}
#scroll-to-bottom i {
    transition: transform 0.3s;
}
#scroll-to-bottom:hover i {
    transform: translateY(2px);
    animation: bounce-arrow 1s infinite;
}

@keyframes bounce-arrow {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}



.profile-edit-input {
    width: 100%;
    background-color: var(--bg-base-300);
    border: 1px solid var(--border-base);
    color: var(--text-base);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease-in-out;
    font-size: calc(1em * var(--text-scale));
}
.profile-edit-input:focus {
    outline: none;
    border-color: var(--theme-primary-color);
    box-shadow: 0 0 10px var(--theme-primary-color);
}
.profile-edit-input:disabled {
    opacity: 0.6;
}
.profile-edit-input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.profile-edit-input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--theme-primary-color);
  border-radius: 4px;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

input[type="range"]:hover {
  opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--theme-primary-color);
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--theme-primary-color);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--theme-primary-color);
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--theme-primary-color);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    transform: scale(0.95);
    transition: transform 0.3s ease-in-out;
}
.modal-overlay.active .modal-content {
    transform: scale(1);
}

.delete-confirmation-progress {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 0, 0, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1rem;
    border: 1px solid rgba(255, 0, 0, 0.4);
}
.delete-confirmation-progress-bar {
    width: 0;
    height: 100%;
    background-color: var(--red);
    box-shadow: 0 0 10px var(--red);
    transition: width 1s linear;
}
@keyframes delete-progress {
    from { width: 0%; }
    to { width: 100%; }
}
.modal-overlay.active .delete-confirmation-progress-bar {
    animation: delete-progress 1s linear forwards;
}

.room-list-item {
    background-color: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 1rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.room-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    border-color: var(--theme-primary-color);
}
.room-list-item::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--theme-primary-color), transparent);
    transition: left 0.6s ease;
    opacity: 0.1;
}
.room-list-item:hover::before {
    left: 100%;
}
.room-list-item .room-name {
    color: var(--theme-primary-color);
    font-weight: bold;
}
.room-list-item .room-meta {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.25rem;
    font-family: 'Share Tech Mono', monospace;
}
.room-list-item .last-message {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-top: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* Adjust as needed */
}

.favorite-btn {
    color: #94a3b8;
    transition: color 0.2s ease-in-out;
}

.favorite-btn.favorited {
    color: var(--amber);
}

/* Inbox page redesign */
#inbox-page-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow it to take full height */
    min-height: calc(100vh - var(--mobile-nav-height) - 1rem - 64px); /* Full viewport height minus header and mobile nav/padding */
    padding-bottom: 1rem; /* Adjust padding as needed */
}

.inbox-tab-content {
    display: none;
    flex-grow: 1; /* Ensure tab content also grows to fill space */
    min-height: 100%; /* Important for swipe area when content is sparse */
    animation: fade-in-up-anim 0.5s ease-out forwards; /* Default entry animation */
}
.inbox-tab-content.active {
    display: flex; /* Use flex to ensure content fills vertically */
    flex-direction: column;
    animation: slide-in-from-right 0.3s ease-out forwards; /* Default entry animation */
}
/* Swipe Animations for Inbox Content */
@keyframes slide-in-from-right {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-in-from-left {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.inbox-tab-content.active.swipe-right-enter {
    animation: slide-in-from-left 0.3s ease-out forwards;
}
.inbox-tab-content.active.swipe-left-enter {
    animation: slide-in-from-right 0.3s ease-out forwards;
}


.inbox-tabs button {
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    padding-bottom: 0.5rem; /* Add padding for better visual */
}
.inbox-tabs button.active {
    color: var(--theme-primary-color);
    border-bottom-color: var(--theme-primary-color);
    font-weight: bold;
    text-shadow: 0 0 8px var(--theme-primary-color);
}

.inbox-item, .notification-item {
    background-color: var(--bg-base-200);
    border-left: 4px solid var(--theme-primary-color);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
    transition: all 0.2s ease-in-out;
    animation: fade-in-up-anim 0.5s ease-out forwards;
    opacity: 0;
    position: relative;
    overflow: hidden; /* For inner glow effect */
}
.inbox-item:hover, .notification-item:hover {
    background-color: var(--bg-base-300);
    border-left-color: var(--theme-primary-color);
}

/* Thematic border glow effect for inbox items */
.inbox-item::before, .notification-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0 4px 4px 0;
    pointer-events: none;
    animation: glitch-border-animation 3s infinite linear alternate-reverse;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid transparent;
}
.inbox-item:hover::before, .notification-item:hover::before {
    opacity: 0.3;
}

@keyframes glitch-border-animation {
    0% { border-color: rgba(var(--red-rgb), 0.2); transform: translateX(0px) translateY(0px); }
    25% { border-color: rgba(var(--blue-rgb), 0.2); transform: translateX(2px) translateY(-2px); }
    50% { border-color: rgba(var(--theme-primary-rgb), 0.2); transform: translateX(-2px) translateY(2px); }
    75% { border-color: rgba(var(--amber-rgb), 0.2); transform: translateX(1px) translateY(1px); }
    100% { border-color: rgba(var(--red-rgb), 0.2); transform: translateX(0px) translateY(0px); }
}

.notification-item {
    cursor: pointer;
}
.notification-item.unread {
    background-color: rgba(var(--theme-primary-rgb), 0.1);
    border-left-color: var(--theme-primary-color);
}
.notification-item.read {
    background-color: var(--bg-base-200);
    border-left-color: var(--text-muted);
    opacity: 0.7;
}
.notification-item.read:hover {
    opacity: 1;
}
.notification-content-wrapper .post-snippet {
    display: block;
    font-style: italic;
    padding-left: 1rem;
    border-left: 2px solid var(--text-muted);
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.delete-notification-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #64748b;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.notification-item:hover .delete-notification-btn {
    opacity: 1;
}
.delete-notification-btn:hover {
    color: var(--red);
}


#mobile-post-fab-hitbox {
    width: 60px;
    height: 60px;
    bottom: calc(var(--mobile-nav-height) + 1rem);
    transition: bottom 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s, transform 0.3s;
    pointer-events: auto;
}
@media (min-width: 768px) {
    #mobile-post-fab-hitbox {
        display: none;
    }
}
#mobile-post-fab-hitbox.hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}


#mobile-post-fab {
    --fab-size: 52px;
    width: var(--fab-size);
    height: var(--fab-size);
    background-color: var(--theme-primary-color);
    color: black;
    border: 2px solid black;
    box-shadow: 0 0 15px var(--theme-primary-color), inset 0 0 5px rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
}

#mobile-post-fab::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 0.3rem;
    border: 1px solid rgba(0,0,0,0.5);
}

#mobile-post-fab .fab-plus {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
    transition: transform 0.4s ease-in-out;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#mobile-post-fab:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 0 25px var(--theme-primary-color), inset 0 0 8px rgba(255, 255, 255, 0.6);
}

#mobile-post-fab:hover .fab-plus {
    transform: rotate(370deg) scale(1.2);
}

#mobile-post-fab:active {
    transform: scale(0.95) rotate(0deg) !important;
}

.fade-in-up { animation: fade-in-up-anim 0.5s ease-out forwards; }
@keyframes fade-in-up-anim {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.comment-appear { animation: comment-appear-anim 0.4s ease-out forwards; }
@keyframes comment-appear-anim {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.form-enter { animation: form-enter-anim 0.5s ease-out forwards; }
@keyframes form-enter-anim {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.shake { animation: shake-anim 0.4s ease-in-out; }
@keyframes shake-anim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.new-post-enter {
    animation: new-post-enter-anim 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    animation-delay: calc(var(--animation-order) * 100ms);
    opacity: 0;
}
@keyframes new-post-enter-anim {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
        border-color: transparent;
        box-shadow: 0 0 5px rgba(var(--theme-primary-rgb), 0);
    }
    50% {
        border-color: var(--theme-primary-color);
        box-shadow: 0 0 20px rgba(var(--theme-primary-rgb), 0.5);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        border-color: var(--border-base);
    }
}

.post-exit { transition: opacity 0.3s ease-out; opacity: 0; }

@keyframes flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% { text-shadow: 0 0 2px rgba(255,255,255,0.7), 0 0 6px rgba(255,255,255,0.5), 0 0 25px var(--theme-primary-color), 0 0 50px var(--theme-primary-color); opacity: 1; }
    20%, 24%, 55% { text-shadow: none; opacity: 0.8; }
}
@keyframes glitch-anim-1 {
    0% { clip-path: polygon(0 2%, 100% 2%, 100% 5%, 0 5%); } 10% { clip-path: polygon(0 75%, 100% 75%, 100% 75%, 0 75%); } 20% { clip-path: polygon(0 40%, 100% 40%, 100% 42%, 0 42%); } 100% { clip-path: polygon(0 50%, 100% 50%, 100% 55%, 0 55%); }
}
@keyframes glitch-anim-2 {
    0% { clip-path: polygon(0 60%, 100% 60%, 100% 65%, 0 65%); } 25% { clip-path: polygon(0 15%, 100% 15%, 100% 15%, 0 15%); } 50% { clip-path: polygon(0 90%, 100% 90%, 100% 85%, 0 85%); } 100% { clip-path: polygon(0 30%, 100% 30%, 100% 32%, 0 32%); }
}

.glitch-effect {
    font-weight: bold;
    text-shadow: 0 0 10px var(--theme-primary-color);
    animation: flicker 2s infinite alternate;
    position: relative;
    display: inline-block;
}
.glitch-effect::before, .glitch-effect::after {
    content: attr(data-text);
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background: transparent; overflow: hidden;
    color: var(--theme-primary-color);
}
.glitch-effect::before {
    left: 2px;
    text-shadow: -2px 0 var(--red);
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
}
.glitch-effect::after {
    left: -2px;
    text-shadow: -2px 0 var(--blue);
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

@keyframes flash-bg {
    from {
        background-color: rgba(var(--theme-primary-rgb), 0.2);
        box-shadow: 0 0 15px var(--theme-primary-color);
    }
    to {
        background-color: transparent;
        box-shadow: none;
    }
}
.flash {
    animation: flash-bg 1.5s ease-out;
}

.page-title-container {
    position: relative;
    display: inline-block;
    perspective: 500px;
    min-height: 28px;
    vertical-align: bottom;
}

.page-title-text {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.2, 1, 0.3, 1), opacity 0.4s ease;
    will-change: transform, opacity;
    transform-origin: center center;
}

.page-title-text.exiting {
    transform: translateY(-120%) rotateX(90deg);
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
}

.page-title-text.entering {
    transform: translateY(120%) rotateX(-90deg);
    opacity: 0;
}

.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.feed-card {
    background: var(--bg-base-200);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    animation: fade-in-up-anim 0.5s ease-out forwards;
    opacity: 0;
    background: rgba(0,0,0,0.6);
}

.feed-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 0, var(--theme-primary-color), transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.feed-card:hover::before {
    opacity: 0.1;
}

.feed-card-header {
    padding: 1rem 1.5rem;
    background: rgba(0,0,0,0.2);
    font-family: 'Share Tech Mono', monospace;
    color: var(--theme-primary-color);
}

.feed-card-body {
    padding: 1.5rem;
}

.feed-card-footer {
    padding: 0 1.5rem 1rem 1.5rem;
}

.message-actions {
    position: absolute;
    top: -10px;
    right: 10px;
    background-color: var(--bg-base-300);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border-base);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(10px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease-out;
}
.chat-message-item:hover .message-actions {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}
.message-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.message-action-btn:hover {
    background-color: rgba(var(--theme-primary-rgb),0.1);
    color: var(--text-base);
}
.message-action-btn.delete:hover {
    color: var(--red);
}

.in-room-theme .author-name {
    color: var(--room-primary-color) !important;
}

.form-checkbox {
    background-color: var(--bg-base-200);
    border-color: var(--theme-primary-color);
    color: var(--theme-primary-color);
}
.form-checkbox:checked {
    background-color: var(--theme-primary-color);
}

/* Chat Bootup Animation */
.chat-boot-screen {
    font-family: 'Share Tech Mono', monospace;
    color: var(--theme-primary-color);
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.3s ease-out;
    min-height: 150px; /* Maintain height during boot */
}
.chat-boot-screen.loaded {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}
.chat-boot-screen p {
    opacity: 0;
    animation: boot-line 0.5s forwards;
}
.chat-boot-screen p:nth-child(1) { animation-delay: 0.1s; }
.chat-boot-screen p:nth-child(2) { animation-delay: 0.3s; }
.chat-boot-screen p:nth-child(3) { animation-delay: 0.5s; }
.chat-boot-screen p:nth-child(4) { animation-delay: 0.7s; }
.chat-boot-screen p:nth-child(5) { animation-delay: 0.9s; }
.chat-boot-screen p:nth-child(6) { animation-delay: 1.1s; }
.chat-boot-screen p:nth-child(7) { animation-delay: 1.3s; }

.chat-boot-screen .boot-ok {
    color: var(--theme-primary-color);
}
.chat-boot-screen .boot-complete {
    animation-delay: 1.5s;
    text-shadow: 0 0 5px var(--theme-primary-color);
}

@keyframes boot-line {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.messages-inner-container {
    flex-grow: 1; /* Allow chat messages to take up remaining height */
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Keep messages at the bottom */
    transition: opacity 0.3s ease-in;
    min-height: 200px; /* Ensure chat messages container has a base height */
    overflow-y: auto; /* Ensure scrolling within this container */
    padding-bottom: 1rem; /* Padding before input */
}
.messages-inner-container:not(.loaded) .chat-message-item {
    display: none; /* Hide individual messages until loaded state is active */
}

/* Animations for individual chat messages */
.chat-message-item {
    animation: chat-message-enter 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; /* Smoother ease-out */
    opacity: 0;
    transform: translateY(20px); /* Start further down */
    position: relative; /* Needed for transform */
}

.chat-message-item.chat-message-remove {
    animation: chat-message-exit 0.3s ease-in forwards;
}

@keyframes chat-message-enter {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes chat-message-exit {
    from { opacity: 1; transform: translateY(0) scale(1); height: auto; padding: inherit;} /* Add height/padding to avoid sudden collapse */
    to { opacity: 0; transform: translateY(-20px) scale(0.98); height: 0; padding: 0;} /* Collapse and fade out */
}

@keyframes chat-message-update {
    0% { background-color: rgba(139, 92, 246, 0.1); } /* Brief highlight */
    100% { background-color: transparent; }
}



.loading-scanner {
    width: 100%;
    height: 150px;
    background-color: var(--bg-base-200);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--theme-primary-color);
    font-family: 'Share Tech Mono', monospace;
    border: 1px solid var(--theme-primary-color);
    background-color: rgba(0,0,0,0.3);
}

.loading-scanner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--theme-primary-color);
    box-shadow: 0 0 15px var(--theme-primary-color);
    animation: scan-anim 3s infinite cubic-bezier(0.5, 0, 0.5, 1);
}

.loading-scanner p {
    z-index: 1;
    text-shadow: 0 0 5px black;
    animation: flicker 2s infinite alternate;
}

@keyframes scan-anim {
    0% { top: 0; }
    50% { top: calc(100% - 5px); }
    100% { top: 0; }
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    transition: color 0.2s ease-in-out;
}
.action-btn .loading-spinner {
    display: none;
}
.action-btn.loading .icon {
    display: none;
}
.action-btn.loading .loading-spinner {
    display: inline-block;
}

/* New Echo Button Style */
.echo-btn {
    position: relative;
    color: var(--text-muted); /* Default color */
}
.echo-btn .icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.echo-btn .echo-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--theme-primary-color);
    transform: scale(0.5);
    opacity: 0;
}
.echo-btn.loading .echo-pulse {
    animation: echo-pulse-anim 0.8s ease-out;
}
@keyframes echo-pulse-anim {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}
.echo-btn:not(.echoed):hover {
    color: var(--theme-primary-color);
}
.share-btn:hover {
    color: var(--theme-primary-color);
}
.comment-btn:hover {
	color: var(--theme-primary-color);
}

.view-post-btn {
    margin-left: auto;
    color: var(--theme-primary-color);
    opacity: 0.6;
}
.view-post-btn .view-post-btn-icon {
    transition: transform 0.3s ease;
}
.view-post-btn:hover {
    color: var(--theme-primary-color);
    opacity: 1;
    text-shadow: 0 0 8px var(--theme-primary-color);
}
.view-post-btn:hover .view-post-btn-icon {
    transform: scale(1.2) rotate(15deg);
}

.post-view-expanded .post-footer {
    padding: 1rem 1.5rem;
}

.post-view-comments-section {
    margin-top: 2rem;
    background-color: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    animation: fade-in-up-anim 0.5s ease-out 0.2s forwards;
    opacity: 0;
}

.new-comment-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.2);
    padding-bottom: 1.5rem;
}
.new-comment-form .comment-input {
    flex-grow: 1;
    background-color: var(--bg-base-300);
    border: 1px solid var(--border-base);
    color: var(--text-base);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    resize: none;
    transition: all 0.2s ease;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid #4b5563;
}
.new-comment-form .comment-input:focus {
    border-color: var(--theme-primary-color);
    box-shadow: 0 0 10px rgba(var(--theme-primary-rgb), 0.5);
    background-color: rgba(0,0,0,0.5);
}
.new-comment-form .submit-comment-btn {
    background-color: var(--theme-primary-color);
    color: #000;
    border: none;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}
.new-comment-form .submit-comment-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

/* Post Creation Enhancements */
.transmit-button {
    font-family: 'Share Tech Mono', monospace;
    background-color: var(--theme-primary-color);
    color: #000;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}
.transmit-button:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 15px var(--theme-primary-color);
}
.transmit-button .transmit-button-text {
    transition: transform 0.3s ease;
}
.transmit-button:hover .transmit-button-text {
    transform: translateX(-200%);
}
.transmit-button .transmit-button-icon {
    position: absolute;
    right: 1rem;
    transform: translateX(200%);
    transition: transform 0.3s ease;
}
.transmit-button:hover .transmit-button-icon {
    transform: translateX(0);
}

.attachment-buttons {
    display: flex;
    gap: 0.5rem;
}
.attachment-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.attachment-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--theme-primary-color);
}

#attachment-preview-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.attachment-preview {
    position: relative;
    max-width: 150px;
    animation: fade-in-up-anim 0.3s;
}
.attachment-preview img, .attachment-preview video {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 2px solid var(--theme-primary-color);
}
.remove-attachment-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background-color: var(--red);
    color: #fff;
    border-radius: 50%;
    border: 2px solid var(--bg-base-100);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
/* Upload Status Overlay */
.upload-status-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.create-post-container.uploading .upload-status-overlay {
    opacity: 1;
    pointer-events: all;
}
.upload-status-content {
    font-family: 'Share Tech Mono', monospace;
    text-align: center;
}
.upload-status-content p {
    margin-top: 1rem;
    letter-spacing: 0.1em;
}
.uploading-state, .success-state, .failure-state {
    display: none;
}
.create-post-container.uploading .uploading-state { display: block; }
.create-post-container.success .success-state { display: block; }
.create-post-container.failure .failure-state { display: block; }

/* Loader Spinner */
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(var(--theme-primary-rgb), 0.3);
    border-top-color: var(--theme-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success/Failure Icons */
.success-checkmark, .failure-icon {
    width: 80px;
    height: 80px;
}
.success-checkmark-circle, .failure-icon-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: var(--theme-primary-color);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.failure-icon-circle {
    stroke: var(--red);
}
.success-checkmark-check, .failure-icon-cross {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-width: 3;
    stroke: var(--theme-primary-color);
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
.failure-icon-cross {
    stroke: var(--red);
    stroke-dasharray: 28;
    stroke-dashoffset: 28;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

/* --- Redesigned Profile Page --- */
.profile-page-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    animation: fade-in-up-anim 0.5s ease-out;
}

@media (min-width: 1024px) {
    .profile-page-grid {
        grid-template-columns: 350px 1fr;
        gap: 2rem;
        align-items: start;
    }
}

.profile-header-card {
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
    animation: profile-card-enter 0.6s ease-out;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-base);
}


.profile-banner {
    height: 120px;
    background: linear-gradient(45deg, rgba(var(--theme-primary-rgb), 0.2), rgba(var(--theme-primary-rgb), 0.05));
    position: relative;
}
#profile-banner-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
}

.profile-avatar-section {
    margin-top: -60px;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
}
.profile-avatar-container {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 6px solid var(--bg-base-100);
    box-shadow: 0 0 25px rgba(0,0,0,0.8);
    overflow: hidden;
    animation: avatar-pop-in 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.4s forwards;
    transform: scale(0);
}
@keyframes avatar-pop-in {
    to { transform: scale(1); }
}
.profile-avatar { width: 100%; height: 100%; object-fit: cover; }

.profile-info-content {
    text-align: center;
    padding: 1.5rem 2rem 2rem 2rem;
}
.profile-display-name {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-base);
    font-family: 'Inter', sans-serif;
    animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) 0.6s both;
}
.profile-username {
    font-family: 'Share Tech Mono', monospace;
    color: var(--theme-primary-color);
    margin-top: 0.25rem;
    animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) 0.8s both;
}
.profile-bio {
    margin-top: 1rem;
    color: var(--text-muted);
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
    animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) 1s both;
}
@keyframes text-focus-in {
  0% { filter: blur(12px); opacity: 0; }
  100% { filter: blur(0px); opacity: 1; }
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-base);
}
.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fade-in-up-anim 0.5s ease-out 1.2s forwards;
    opacity: 0;
}
.profile-stat:nth-child(2) { animation-delay: 1.3s; }
.profile-stat:nth-child(3) { animation-delay: 1.4s; }

.profile-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: var(--text-base);
}
.profile-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#profile-content-area {
    animation: fade-in-up-anim 0.5s ease-out 0.3s forwards;
    opacity: 0;
}

.profile-tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-base);
    margin-bottom: 2rem;
}
.profile-tab {
    font-family: 'Share Tech Mono', monospace;
    padding: 0.5rem 0.25rem 0.75rem 0.25rem;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}
.profile-tab:hover {
    color: var(--text-base);
}
.profile-tab.active {
    color: var(--theme-primary-color);
    border-bottom-color: var(--theme-primary-color);
    text-shadow: 0 0 8px var(--theme-primary-color);
}
.profile-tab-content { display: none; }
.profile-tab-content.active { display: block; animation: fade-in-up-anim 0.4s ease; }

.profile-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.profile-post-compact {
    background-color: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
    position: relative;
    overflow: hidden;
}
.profile-post-compact:hover {
    transform: translateY(-4px);
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    border-color: var(--theme-primary-color);
}
.profile-post-compact-exit {
    animation: profile-post-exit-anim 0.3s ease-in forwards;
}
@keyframes profile-post-exit-anim {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}


.profile-post-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}
.profile-post-compact-time {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--bg-base-300);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.5);
}

.profile-post-attachment-compact {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    background-color: rgba(var(--theme-primary-rgb), 0.1);
}
.post-image-compact {
    width: 100%; height: 100%; object-fit: cover;
}
.attachment-icon {
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-primary-color);
    font-size: 1.2rem;
}

.profile-post-compact-content {
    -webkit-box-orient: vertical;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.75rem 0;
    flex-grow: 1;
}

.profile-post-compact-footer {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Share Tech Mono', monospace;
    border-top: 1px solid var(--border-base);
    padding-top: 0.75rem;
}

.echo-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.2rem;
    color: var(--theme-primary-color);
    background: rgba(0,0,0,0.7);
    padding: 4px;
    border-radius: 50%;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px var(--theme-primary-color);
}

.profile-post-author-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.avatar-compact {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

/* --- Attachment Viewer --- */
.attachment-viewer {
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}
.attachment-viewer-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in-up-anim 0.4s ease;
}
.attachment-viewer-content img,
.attachment-viewer-content video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,0.7);
    border: 2px solid rgba(var(--theme-primary-rgb), 0.5);
}
.attachment-viewer-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 2.5rem;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    text-shadow: 0 0 10px #000;
    transition: transform 0.2s ease;
}
.attachment-viewer-close:hover {
    transform: scale(1.1) rotate(90deg);
    color: var(--red);
}
.post-attachment-container {
    margin-top: 1rem;
    max-height: 350px;
    overflow: hidden;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(var(--theme-primary-rgb), 0.2);
    transition: border-color 0.3s ease;
}
.post-attachment-container:not(.themed-audio-player):hover {
    border-color: rgba(var(--theme-primary-rgb), 0.6);
}

.post-attachment-container .post-image,
.post-attachment-container .post-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.post-attachment-container:not(.themed-audio-player):hover .post-image,
.post-attachment-container:not(.themed-audio-player):hover .post-video {
    transform: scale(1.05);
}
.post-attachment-container::after {
    content: '\f065'; /* fa-expand */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    color: white;
    background-color: rgba(0,0,0,0.6);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    transition: all 0.3s ease;
    text-shadow: 0 0 10px black;
}
.post-attachment-container:not(.themed-audio-player):not(.expanded):hover::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.attachment-type-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(0,0,0,0.7);
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 2;
}

/* --- New Themed Audio Player --- */
.themed-audio-player {
    background-color: var(--bg-base-100);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Share Tech Mono', monospace;
    position: relative;
    overflow: hidden;
    margin-top: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(0,0,0,0.65);
}

.themed-audio-player::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--theme-primary-color);
    box-shadow: 0 0 10px var(--theme-primary-color);
    opacity: 0.5;
}

.audio-play-pause-btn {
    background-color: var(--theme-primary-color);
    color: #000;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px rgba(var(--theme-primary-rgb), 0.5);
}
.audio-play-pause-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.audio-details {
    flex-grow: 1;
    min-width: 0;
}
.audio-title {
    color: var(--text-base);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.audio-artist {
    color: var(--text-muted);
    font-size: 0.8em;
}

.audio-progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.audio-time {
    font-size: 0.8em;
    color: var(--theme-primary-color);
}

.audio-progress-bar-wrapper {
    flex-grow: 1;
    height: 6px;
    background-color: rgba(var(--theme-primary-rgb), 0.15);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}

.audio-progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--theme-primary-color);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.audio-volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.audio-volume-btn {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.2s;
}
.audio-volume-btn:hover {
    color: var(--theme-primary-color);
}
.audio-volume-slider {
    width: 80px;
    height: 4px;
    background-color: rgba(var(--theme-primary-rgb), 0.15);
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.audio-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--theme-primary-color);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--theme-primary-color);
}


/* --- New Settings Page Styles --- */
.settings-section {
    opacity: 0;
    transform: translateY(20px);
    animation: fade-in-up-anim 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    animation-delay: calc(var(--animation-order) * 150ms);
}
.settings-section-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.5rem;
    color: var(--theme-primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-base);
}
.settings-card {
    background-color: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-base);
    transition: all 0.3s ease;
}
.settings-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* UI Scale Slider */
.ui-scale-slider-container {
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.ui-scale-slider-track {
    width: 100%;
    height: 6px;
    background-color: var(--bg-base-300);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.ui-scale-slider-progress {
    position: absolute;
    height: 100%;
    background-color: var(--theme-primary-color);
    border-radius: 3px;
    left: 0;
    width: var(--progress, 50%);
}
.ui-scale-slider {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    outline: none;
    margin: 0;
    padding: 0;
}
.ui-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: white;
    border: 2px solid var(--theme-primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 0 0 rgba(var(--theme-primary-rgb), 0.5);
}
.ui-scale-slider:hover::-webkit-slider-thumb {
    transform: scale(1.1);
}
.ui-scale-slider:active::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 0 8px rgba(var(--theme-primary-rgb), 0.3);
}

/* Toggle Switch */
.toggle-switch-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-base-300);
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
}
.toggle-switch-label .label-text {
    font-weight: 600;
    color: var(--text-base);
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-base-100);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch:checked {
    background-color: var(--theme-primary-color);
}
.toggle-switch:checked::before {
    transform: translateX(20px);
}