:root {
    --bg-primary: #36393f;
    --bg-secondary: #2f3136;
    --bg-tertiary: #202225;
    --bg-input: #40444b;
    --text-normal: #dcddde;
    --text-muted: #72767d;
    --text-link: #00aff4;
    --brand-color: #5865f2;
    --brand-color-hover: #4752c4;
    --danger: #ed4245;
    --scrollbar-thumb: #202225;
    --scrollbar-track: #2e3338;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-normal);
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--app-height, 100%);
    overflow: hidden;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
}

.hidden {
    display: none !important;
}

/* Auth Screen */
#auth-screen {
    background-image: url('https://w.wallhaven.cc/full/wq/wallhaven-wqp1x7.jpg');
    background-size: cover;
    background-position: center;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-box {
    background-color: var(--bg-primary);
    padding: 32px;
    border-radius: 5px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.auth-box h2 {
    color: #fff;
    font-size: 24px;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
    font-size: 15px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid rgba(0,0,0,0.3);
    border-radius: 3px;
    color: var(--text-normal);
    padding: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--text-link);
}

.btn-primary {
    width: 100%;
    background-color: var(--brand-color);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--brand-color-hover);
}

.error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 15px;
    min-height: 15px;
}

.auth-switch {
    margin-top: 15px;
    font-size: 14px;
}

.auth-switch span {
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--text-link);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Chat Screen */
.sidebar-wrapper {
    display: flex;
    height: 100%;
    z-index: 10;
}

.server-sidebar {
    width: 72px;
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
}

.server-icon {
    width: 48px;
    height: 48px;
    background-color: var(--bg-primary);
    border-radius: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: var(--text-normal);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.server-icon:hover, .server-icon.active {
    border-radius: 16px;
    background-color: var(--brand-color);
    color: #fff;
}

.server-separator {
    width: 32px;
    height: 2px;
    background-color: var(--bg-secondary);
    margin: 4px 0 12px 0;
}

.channel-sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.channel-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    font-weight: 600;
    color: #fff;
    z-index: 2;
}

.channel-list {
    flex: 1;
    padding: 16px 8px;
    overflow-y: auto;
}

.channel-item {
    padding: 6px 8px;
    margin-bottom: 2px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-item:hover {
    background-color: rgba(79,84,92,0.16);
    color: var(--text-normal);
}

.channel-item.active {
    background-color: rgba(79,84,92,0.32);
    color: #fff;
}

.hash {
    font-size: 20px;
    color: var(--text-muted);
}

.user-area {
    height: 52px;
    background-color: rgba(32,34,37,0.3);
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-wrapper {
    position: relative;
    cursor: pointer;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1/1;
    background-color: var(--brand-color);
}

.avatar-fallback {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 500;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-info .username {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-info .status {
    font-size: 12px;
    color: var(--text-muted);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background-color: rgba(79,84,92,0.32);
    color: var(--text-normal);
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    min-width: 0; /* Important for flex child truncation */
}

.chat-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    z-index: 2;
}

.channel-title {
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.messages {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-track {
    background-color: var(--scrollbar-track);
}

.message {
    padding: 4px 16px;
    display: flex;
    gap: 16px;
    margin-top: 16px;
    position: relative;
}

.message:hover {
    background-color: rgba(4,4,5,0.07);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1/1;
    background-color: var(--brand-color);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 500;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-username {
    font-weight: 500;
    color: #fff;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.msg-actions {
    display: none;
    gap: 12px;
    margin-left: auto;
}

.message:hover .msg-actions {
    display: flex;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

.action-btn:hover {
    color: var(--text-normal);
}

.action-btn.delete-btn:hover {
    color: var(--danger);
}

.message-text {
    line-height: 1.375rem;
    word-break: break-word;
}

.message-image {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    margin-top: 4px;
    cursor: zoom-in;
    object-fit: cover;
}

.input-container {
    padding: 0 16px 24px 16px;
}

.input-wrapper {
    background-color: var(--bg-input);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.attach-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-btn:hover {
    color: var(--text-normal);
}

.input-wrapper input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-normal);
    padding: 14px 10px;
    font-size: 16px;
    outline: none;
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    font-size: 18px;
}

.send-btn:hover {
    color: var(--brand-color);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 30px;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
}

/* Status View */
.status-container {
    padding: 20px 40px;
    color: var(--text-normal);
    font-family: monospace;
    font-size: 14px;
    line-height: 1.6;
}

.neofetch {
    display: flex;
    gap: 30px;
    align-items: center;
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.neofetch-logo {
    color: var(--brand-color);
    font-size: 12px;
    white-space: pre;
    line-height: 1.1;
}

.neofetch-info {
    flex: 1;
}

.nf-title {
    color: var(--brand-color);
    font-weight: bold;
    font-size: 16px;
}

.nf-sep {
    color: var(--text-muted);
    margin: 4px 0;
}

.nf-key {
    color: var(--brand-color);
    font-weight: bold;
    display: inline-block;
    width: 80px;
}

.nf-val {
    color: var(--text-normal);
}

.nf-bar-bg {
    display: inline-block;
    width: 150px;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 10px;
}

.nf-bar-fg {
    height: 100%;
    background: var(--brand-color);
}

/* Mobile & Responsive */
.mobile-only {
    display: none;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
    
    .sidebar-wrapper {
        position: fixed;
        left: -312px; /* 72 + 240 */
        top: 0;
        bottom: 0;
        transition: transform 0.3s ease;
    }

    .sidebar-wrapper.open {
        transform: translateX(312px);
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .input-container {
        padding: 0 8px calc(12px + env(safe-area-inset-bottom)) 8px;
    }
    
    .status-container {
        padding: 16px;
    }
    
    .neofetch {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    .msg-actions { 
        display: flex; 
        opacity: 0.8; 
    }
    .message-image { 
        max-width: 200px; 
        max-height: 200px; 
    }
}
