/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Variables */
    --bg-primary: #202225;
    --bg-secondary: #2f3136;
    --bg-tertiary: #36393f;
    --bg-quaternary: #40444b;
    --bg-accent: #5865f2;
    --bg-modifier-hover: rgba(79, 84, 92, 0.16);
    --bg-modifier-active: rgba(79, 84, 92, 0.24);
    --bg-modifier-selected: rgba(79, 84, 92, 0.32);
    
    --text-normal: #dcddde;
    --text-muted: #72767d;
    --text-link: #00aff4;
    --text-positive: #43b581;
    --text-warning: #faa61a;
    --text-danger: #f04747;
    
    --interactive-normal: #b9bbbe;
    --interactive-hover: #dcddde;
    --interactive-active: #fff;
    --interactive-muted: #4f545c;
    
    --border-color: #42454a;
    --scrollbar-thin-thumb: #202225;
    --scrollbar-thin-track: transparent;
    --scrollbar-auto-thumb: #202225;
    --scrollbar-auto-track: #2f3136;
    
    --font-primary: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    
    /* Animation */
    --transition-fast: 0.1s;
    --transition-normal: 0.2s;
    --transition-slow: 0.3s;
}

[data-theme="dark"] {
    color-scheme: dark;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-normal);
    overflow: hidden;
    height: 100vh;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
}

/* Utility Classes */
.mobile-only {
    display: none !important;
}

.mobile-hidden {
    display: flex !important;
}

/* Servers Sidebar */
.servers-sidebar {
    width: 72px;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
    overflow-y: auto;
    scrollbar-width: none;
    flex-shrink: 0;
    z-index: 100;
}

.servers-sidebar::-webkit-scrollbar {
    display: none;
}

.server-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.server-item {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    position: relative;
    background-color: var(--bg-secondary);
    color: var(--text-normal);
    font-weight: 600;
    font-size: 16px;
    user-select: none;
}

.server-item:hover {
    border-radius: 16px;
    background-color: var(--bg-accent);
}

.server-item.active {
    border-radius: 16px;
    background-color: var(--bg-accent);
}

.server-item.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background-color: white;
    border-radius: 0 4px 4px 0;
    animation: slideIn var(--transition-slow) ease forwards;
}

@keyframes slideIn {
    to { height: 40px; }
}

.server-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.add-server {
    background-color: #36393f;
    color: #3ba55c;
    font-size: 20px;
}

.add-server:hover {
    background-color: #3ba55c;
    color: white;
}

.server-separator {
    width: 32px;
    height: 2px;
    background-color: var(--border-color);
    border-radius: 1px;
    margin: 8px 0;
}

/* Channels Sidebar */
.channels-sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal) ease;
    z-index: 90;
}

.server-header {
    height: 48px;
    min-height: 48px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    user-select: none;
}

.server-header:hover {
    background-color: var(--bg-modifier-hover);
}

.server-name {
    font-size: 16px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.dropdown-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 3px;
    transition: all var(--transition-fast);
    font-size: 16px;
}

.dropdown-btn:hover {
    color: var(--text-normal);
    background-color: var(--bg-modifier-hover);
}

.channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thin-thumb) var(--scrollbar-thin-track);
}

.channels-list::-webkit-scrollbar {
    width: 8px;
}

.channels-list::-webkit-scrollbar-track {
    background: var(--scrollbar-thin-track);
}

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

.category {
    margin-bottom: 24px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.add-channel {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    font-size: 12px;
    transition: color var(--transition-fast);
    line-height: 1;
}

.add-channel:hover {
    color: var(--text-normal);
    background-color: var(--bg-modifier-hover);
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    margin: 1px 0;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    font-size: 16px;
    user-select: none;
}

.channel-item i {
    width: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.channel-item:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.channel-item.active {
    background-color: var(--bg-modifier-selected);
    color: white;
}

.voice-users {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.online-users {
    margin-top: 24px;
}

.user-panel {
    height: 52px;
    min-height: 52px;
    background-color: var(--bg-primary);
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background-color: var(--bg-accent);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}

.status-indicator.online {
    background-color: var(--text-positive);
}

.status-indicator.idle {
    background-color: var(--text-warning);
}

.status-indicator.dnd {
    background-color: var(--text-danger);
}

.status-indicator.offline {
    background-color: var(--text-muted);
}

.user-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.username {
    display: block;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-id {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-controls {
    display: flex;
    gap: 4px;
}

.control-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    background-color: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 16px;
}

.control-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    height: 48px;
    min-height: 48px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    z-index: 1;
    flex-shrink: 0;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 18px;
}

.mobile-menu-btn:hover {
    background-color: var(--bg-modifier-hover);
}

.channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.channel-header i {
    color: var(--text-muted);
    font-size: 20px;
    flex-shrink: 0;
}

.channel-name {
    font-weight: 600;
    font-size: 16px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-topic {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.channel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    background-color: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition-fast);
    font-size: 16px;
}

.header-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--text-danger);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.member-count {
    font-size: 12px;
    margin-left: 4px;
    font-weight: 600;
}

.search-box {
    position: relative;
    margin: 0 8px;
}

.search-box input {
    width: 144px;
    height: 28px;
    padding: 0 8px 0 28px;
    background-color: var(--bg-primary);
    border: none;
    border-radius: 4px;
    color: var(--text-normal);
    font-size: 14px;
    transition: width var(--transition-normal);
}

.search-box input:focus {
    width: 200px;
    outline: none;
}

.search-box i {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    scrollbar-width: auto;
    scrollbar-color: var(--scrollbar-auto-thumb) var(--scrollbar-auto-track);
    min-height: 0;
}

.messages-container::-webkit-scrollbar {
    width: 16px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-auto-thumb);
    border-radius: 8px;
    border: 4px solid var(--scrollbar-auto-track);
}

.welcome-message {
    text-align: center;
    padding: 40px 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    background-color: var(--bg-quaternary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
    color: var(--text-muted);
}

.welcome-message h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.welcome-message p {
    color: var(--text-muted);
    font-size: 14px;
}

.message {
    display: flex;
    padding: 4px 16px;
    position: relative;
    transition: background-color var(--transition-fast);
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 16px;
    flex-shrink: 0;
    background-color: var(--bg-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    position: relative;
}

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

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

.message-username {
    font-weight: 600;
    font-size: 16px;
    color: white;
}

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

.message-content {
    font-size: 16px;
    line-height: 1.375;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.typing-indicator {
    padding: 0 16px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 14px;
    height: 24px;
    min-height: 24px;
}

.message-input-container {
    padding: 16px;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-attachments {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-quaternary);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}

.attach-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background-color: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
}

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

.input-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
}

#message-input {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-normal);
    font-size: 16px;
    padding: 10px 0;
    outline: none;
    font-family: inherit;
}

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

.input-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.input-action-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 16px;
}

.input-action-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background-color: var(--bg-accent);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color var(--transition-fast);
}

.send-btn:hover {
    background-color: #4752c4;
}

.send-btn:disabled {
    background-color: var(--bg-modifier-active);
    cursor: not-allowed;
}

.mobile-input-actions {
    display: none;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.mobile-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.mobile-action-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

/* Members Sidebar */
.members-sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal) ease;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 80;
    transform: translateX(100%);
}

.members-header {
    height: 48px;
    min-height: 48px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.members-header input {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    background-color: var(--bg-primary);
    border: none;
    border-radius: 4px;
    color: var(--text-normal);
    font-size: 14px;
}

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

.close-members-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.close-members-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

.members-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 8px;
    scrollbar-width: thin;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background-color var(--transition-fast);
    user-select: none;
}

.member-item:hover {
    background-color: var(--bg-modifier-hover);
}

.member-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background-color: var(--bg-accent);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.member-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-normal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-activity {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Search Overlay */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    z-index: 1000;
    display: none;
    flex-direction: column;
}

.search-header {
    height: 60px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.search-header input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 4px;
    color: var(--text-normal);
    font-size: 16px;
}

.close-search-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    font-size: 20px;
    transition: all var(--transition-fast);
}

.close-search-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--text-normal);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 32px 32px 0;
    text-align: center;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.modal-header p {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.4;
}

.modal-body {
    padding: 32px;
}

.avatar-preview {
    text-align: center;
    margin-bottom: 32px;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--bg-accent);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 32px;
}

.change-avatar-btn {
    background: none;
    border: none;
    color: var(--text-link);
    cursor: pointer;
    font-size: 14px;
    transition: color var(--transition-fast);
    padding: 4px 8px;
    border-radius: 4px;
}

.change-avatar-btn:hover {
    text-decoration: underline;
    background-color: var(--bg-modifier-hover);
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #b9bbbe;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-normal);
    font-size: 16px;
    transition: border-color var(--transition-normal);
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--bg-accent);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--bg-accent);
    border: none;
    border-radius: 3px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color var(--transition-normal);
    margin-bottom: 16px;
}

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

.modal-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.modal-footer p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .members-sidebar {
        position: absolute;
        transform: translateX(100%);
    }
    
    .members-sidebar.active {
        transform: translateX(0);
    }
    
    .channel-topic {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Utility classes for mobile */
    .mobile-only {
        display: flex !important;
    }
    
    .mobile-hidden {
        display: none !important;
    }
    
    /* App container adjustments */
    .app-container {
        overflow: hidden;
    }
    
    /* Servers sidebar */
    .servers-sidebar {
        width: 60px;
    }
    
    .server-item {
        width: 44px;
        height: 44px;
        font-size: 14px;
    }
    
    /* Channels sidebar */
    .channels-sidebar {
        position: absolute;
        left: 60px;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 100;
    }
    
    .channels-sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }
    
    /* Chat area */
    .chat-area {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .channel-header i {
        font-size: 18px;
    }
    
    .channel-name {
        font-size: 14px;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .messages-container {
        padding: 12px 8px;
    }
    
    .message {
        padding: 4px 8px;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        margin-right: 12px;
        font-size: 14px;
    }
    
    .message-username {
        font-size: 14px;
    }
    
    .message-content {
        font-size: 14px;
    }
    
    .welcome-message {
        padding: 20px 12px;
    }
    
    .welcome-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .welcome-message h3 {
        font-size: 20px;
    }
    
    .welcome-message p {
        font-size: 12px;
    }
    
    /* Message input */
    .message-input-container {
        padding: 12px;
    }
    
    .input-attachments {
        gap: 8px;
        padding: 6px;
    }
    
    .attach-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 16px;
    }
    
    #message-input {
        font-size: 14px;
        padding: 8px 0;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 14px;
    }
    
    .mobile-input-actions {
        display: flex;
    }
    
    /* Members sidebar */
    .members-sidebar {
        width: 280px;
    }
    
    /* Modal */
    .modal-content {
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 24px 24px 0;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-header p {
        font-size: 14px;
    }
    
    .modal-body {
        padding: 24px;
    }
    
    .avatar-large {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .form-group input {
        padding: 10px;
        font-size: 14px;
    }
    
    .login-btn {
        padding: 12px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    /* Hide servers sidebar on very small screens */
    .servers-sidebar {
        display: none;
    }
    
    .channels-sidebar {
        left: 0;
        width: 100%;
    }
    
    .chat-area {
        margin-left: 0;
    }
    
    .server-item {
        width: 40px;
        height: 40px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 12px;
    }
    
    .username {
        font-size: 12px;
    }
    
    .user-id {
        font-size: 10px;
    }
    
    .control-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 14px;
    }
    
    .channel-header {
        gap: 6px;
    }
    
    .channel-name {
        font-size: 13px;
    }
    
    .header-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 14px;
    }
    
    .messages-container {
        padding: 8px 4px;
    }
    
    .message {
        padding: 4px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        margin-right: 8px;
    }
    
    .message-header {
        gap: 4px;
    }
    
    .message-username {
        font-size: 13px;
    }
    
    .message-timestamp {
        font-size: 10px;
    }
    
    .message-content {
        font-size: 13px;
    }
    
    .message-input-container {
        padding: 8px;
    }
    
    .input-attachments {
        margin-bottom: 4px;
    }
    
    .attach-btn,
    .send-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .mobile-action-btn {
        font-size: 18px;
        padding: 8px 12px;
    }
    
    .members-sidebar {
        width: 100%;
    }
    
    /* Modal adjustments */
    .modal-header {
        padding: 20px 20px 0;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-header p {
        font-size: 13px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .server-item,
    .channel-item,
    .member-item,
    .control-btn,
    .header-btn,
    .input-action-btn,
    .mobile-action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .attach-btn,
    .send-btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    input,
    button {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .message-content {
        font-size: 16px;
        line-height: 1.5;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        color-scheme: dark;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --text-normal: #ffffff;
        --text-muted: #aaaaaa;
        --border-color: #666666;
    }
    
    .server-item.active::before {
        background-color: #ffffff;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}