:root {
    --dark-primary: #36393f;
    --dark-secondary: #2f3136;
    --dark-tertiary: #202225;
    --text-normal: #dcddde;
    --text-muted: #72767d;
    --blurple: #6366f1;
    --green: #3ba55c;
    --red: #ed4245;
    --header-height: 48px;
    --footer-height: 68px;
    --sidebar-width: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--dark-primary);
    color: var(--text-normal);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

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

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--dark-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 0 rgba(4,4,5,0.2);
    z-index: 2;
    background: rgba(98, 102, 240);
    border-top-left-radius: 10px;
}

.logo {
    font-weight: 800;
    font-size: 20px;
    color: white;
    letter-spacing: -0.5px;
}

.rooms-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.rooms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px 4px;
}

.rooms-title {
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.add-room-btn {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 10px;
    transition: all 0.15s;
    background-color: rgba(79, 84, 92, 0.3);
    border-radius: 4px;
}

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

.room-list {
    list-style: none;
}

.room-item {
    padding: 8px 10px;
    margin: 3px 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s;
    font-size: 15px;
    color: var(--text-muted);
}

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

.room-item.active {
    background-color: rgba(79, 84, 92, 0.5);
    color: var(--text-normal);
}

.room-hash {
    margin-right: 6px;
    font-size: 18px;
}

.user-area {
    margin-top: auto;
    padding: 10px;
    background-color: var(--dark-tertiary);
    display: flex;
    align-items: center;
    height: 52px;
    border-bottom-left-radius: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.settings-icon {
    color: var(--text-muted);
    cursor: pointer;
    width: 20px;
    height: 20px;
    transition: all 0.15s;
}

.settings-icon:hover {
    color: var(--text-normal);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    background-color: var(--dark-primary);
}

.chat-header {
    height: var(--header-height);
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    box-shadow: 0 1px 0 rgba(4,4,5,0.2);
    z-index: 1;
    border-top-right-radius: 10px;
}

.header-hash {
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 24px;
}

.header-title {
    font-weight: 600;
    font-size: 16px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    background-color: var(--dark-primary);
    overflow-x: hidden;
}

.message-group {
    display: flex;
    padding: 2px 16px;
    margin-bottom: 16px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 16px;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.message-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 6px;
}

.message-author {
    font-weight: 500;
    font-size: 16px;
    margin-right: 8px;
    color: white;
}

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

.message-text {
    font-size: 15px;
    line-height: 1.375;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 2px;
}

.input-area {
    margin: 0 16px 16px;
    background-color: #40444b;
    border-radius: 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 16px;
    padding: 12px 0;
    outline: none;
}

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

.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(54, 57, 63, 0.8) 0%, rgba(32, 34, 37, 0.9) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    background-color: var(--dark-primary);
    border-radius: 12px;
    width: 440px;
    padding: 32px;
    box-shadow: 0 2px 10px 0 rgba(0,0,0,.2);
    animation: scaleIn 0.3s ease-out;
}

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

.login-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    background: rgba(98, 102, 240);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 24px;
    text-align: center;
}

.login-input {
    background-color: var(--dark-tertiary);
    border: 1px solid rgba(0,0,0,0.3);
    border-radius: 8px;
    color: var(--text-normal);
    font-size: 16px;
    height: 44px;
    padding: 10px 16px;
    margin-bottom: 20px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--blurple);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.login-button {
    background-color: var(--blurple);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    height: 48px;
    width: 100%;
    transition: background-color 0.2s;
}

.login-button:hover {
    background-color: #4752c4;
}

.login-button:active {
    transform: translateY(1px);
}

.join-room-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s;
}

.dialog-box {
    background-color: var(--dark-primary);
    border-radius: 12px;
    width: 440px;
    padding: 32px;
    animation: scaleIn 0.3s ease-out;
}

.dialog-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-normal);
}

.dialog-subtitle {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 20px;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
    gap: 12px;
}

.dialog-button {
    padding: 2px 16px;
    height: 38px;
    min-width: 96px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-button-cancel {
    background-color: transparent;
    color: var(--text-normal);
    border: none;
}

.dialog-button-cancel:hover {
    background-color: rgba(79, 84, 92, 0.16);
}

.dialog-button-confirm {
    background-color: var(--blurple);
    color: white;
    border: none;
}

.dialog-button-confirm:hover {
    background-color: #4752c4;
}

.dialog-button:active {
    transform: translateY(1px);
}

.settings-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s;
}

@media (max-width: 768px) {
    .sidebar {
        width: 72px;
    }
    
    .logo, .rooms-title, .user-name {
        display: none;
    }
    
    .sidebar-header {
        justify-content: center;
    }
    
    .room-name {
        display: none;
    }
    
    .room-hash {
        margin-right: 0;
        font-size: 24px;
    }
    
    .login-box, .dialog-box {
        width: 90%;
        max-width: 440px;
        padding: 24px;
    }
    
    .message-text {
        font-size: 14px;
    }
}
.char-counter {
    position: absolute;
    right: 20px;
    bottom: 45px;
    font-size: 12px;
    color: #888;
    transition: all 0.2s ease;
}

.char-counter.warning {
    color: #e67e22;
}

.char-counter.error {
    color: #e74c3c;
    font-weight: bold;
}

.message-input.error {
    border-color: #e74c3c;
}

.input-area {
    position: relative;
}
.char-counter {
    position: absolute;
    right: 20px;
    bottom: 45px;
    font-size: 12px;
    color: #888;
    transition: all 0.2s ease;
}

.char-counter.warning {
    color: #e67e22;
}

.char-counter.error {
    color: #e74c3c;
    font-weight: bold;
}

.message-input.error {
    border-color: #e74c3c;
}

.input-area {
    position: relative;
}

.admin-user {
    color: #e74c3c;
    font-weight: bold;
}

.admin-user::after {
    content: " (Admin)";
    font-size: 0.8em;
    opacity: 0.8;
}

.context-menu {
    display: none;
    position: absolute;
    z-index: 1000;
    min-width: 150px;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu li {
    padding: 8px 12px;
    cursor: pointer;
}

.context-menu li:hover {
    background-color: #f0f0f0;
}

#delete-message {
    color: #e74c3c;
}

.admin-mode .message-group:hover {
    background-color: rgba(231, 76, 60, 0.05);
    cursor: context-menu;
}
.loading-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 5px;
    z-index: 10000;
}
