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

:root {
    --primary-color: #07C160;
    --secondary-color: #576B95;
    --bg-color: #EDEDED;
    --sidebar-bg: #2C2C2E;
    --text-primary: #191919;
    --text-secondary: #888888;
    --bubble-self: #95EC69;
    --bubble-other: #FFFFFF;
    --error-color: #FF3B30;
    --success-color: #34C759;
    --border-color: #E5E5E5;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary-color: #07C160;
    --secondary-color: #576B95;
    --bg-color: #1a1a1a;
    --sidebar-bg: #121212;
    --text-primary: #E5E5E5;
    --text-secondary: #888888;
    --bubble-self: #4A9C5D;
    --bubble-other: #2C2C2E;
    --border-color: #3A3A3A;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-color);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
    position: relative;
}

.hidden {
    display: none !important;
}

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

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #07C160 0%, #576B95 100%);
}

.login-container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow);
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .login-container {
    background: #2C2C2E;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    width: 80px;
    height: 80px;
    background: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--bubble-other);
    color: var(--text-primary);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
    transform: scale(1.01);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.error-message {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 12px;
    text-align: center;
    min-height: 18px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#main-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    background: var(--sidebar-bg);
    color: white;
    flex-shrink: 0;
    -webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-left, .nav-right {
    width: 60px;
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: rotate(15deg);
}

.nav-btn:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.9);
}

.nav-title {
    font-size: 18px;
    font-weight: 600;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hamburger {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    position: relative;
    transition: var(--transition);
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: white;
    left: 0;
    transition: var(--transition);
}

.hamburger::before {
    top: -6px;
}

.hamburger::after {
    bottom: -6px;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    touch-action: manipulation;
}

.user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.user-avatar:active {
    transform: scale(1.05);
}

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

.user-avatar::after {
    content: '📷';
    position: absolute;
    font-size: 12px;
    opacity: 0;
    transition: var(--transition);
}

.user-avatar:hover::after {
    opacity: 1;
    background: rgba(0,0,0,0.5);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .username {
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-details .status {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.user-details .status.online {
    color: var(--primary-color);
}

.search-box {
    padding: 12px 16px;
}

.search-box input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    transition: var(--transition);
    -webkit-appearance: none;
}

.search-box input::placeholder {
    color: #888;
}

.search-box input:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
    transform: scale(1.02);
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.contacts-list::-webkit-scrollbar {
    width: 6px;
}

.contacts-list::-webkit-scrollbar-track {
    background: transparent;
}

.contacts-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255,255,255,0.1);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.contact-item:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(4px);
}

.contact-item:active {
    background: rgba(255,255,255,0.15);
}

.contact-item.active {
    background: rgba(255,255,255,0.15);
    border-left: 3px solid var(--primary-color);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.contact-avatar:hover {
    transform: rotate(5deg) scale(1.05);
}

.contact-avatar .online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

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

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    color: white;
    font-weight: 500;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.contact-preview {
    color: #888;
    font-size: 12px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 8px;
}

.contact-time {
    color: #666;
    font-size: 11px;
}

.contact-badge {
    background: var(--error-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 4px;
    min-width: 18px;
    text-align: center;
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-add-contact {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.btn-add-contact:hover {
    background: #06AD56;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.btn-add-contact:active {
    transform: translateY(0);
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    overflow: hidden;
    transition: var(--transition);
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bubble-other);
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-contact-info {
    display: flex;
    align-items: center;
}

.chat-contact-info .contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 12px;
}

.contact-details .contact-name {
    color: var(--text-primary);
    font-weight: 600;
}

.contact-details .contact-status {
    color: var(--text-secondary);
    font-size: 12px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    touch-action: manipulation;
}

.chat-action-btn:hover {
    background: var(--bg-color);
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-color);
    -webkit-overflow-scrolling: touch;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

.message-wrapper {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-wrapper.sent {
    flex-direction: row-reverse;
    animation: messageSlideRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideRight {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.message-wrapper.received {
    flex-direction: row;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin: 0 8px;
    overflow: hidden;
    transition: var(--transition);
}

.message-avatar:hover {
    transform: scale(1.1) rotate(5deg);
}

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

.message-content {
    max-width: 70%;
    min-width: 60px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
    transition: var(--transition);
    animation: bubblePop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bubblePop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.message-wrapper.sent .message-bubble {
    background: var(--bubble-self);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message-wrapper.received .message-bubble {
    background: var(--bubble-other);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-bubble:hover {
    transform: scale(1.02);
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 4px;
    gap: 6px;
}

.message-wrapper.sent .message-meta {
    justify-content: flex-end;
}

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

.message-status {
    font-size: 12px;
    transition: var(--transition);
}

.message-status.sending {
    opacity: 0.7;
    animation: pulse 1s ease-in-out infinite;
}

.message-status.failed {
    color: var(--error-color);
    animation: shake 0.5s ease-in-out;
}

.message-status.read {
    color: var(--primary-color);
}

.chat-input-area {
    background: var(--bubble-other);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.input-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.toolbar-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    touch-action: manipulation;
}

.toolbar-btn:hover {
    background: var(--bg-color);
    transform: scale(1.2) rotate(10deg);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.input-container textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.5;
    background: var(--bg-color);
    color: var(--text-primary);
    transition: var(--transition);
    -webkit-appearance: none;
}

.input-container textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
    transform: scale(1.01);
}

.send-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.send-btn:hover::before {
    left: 100%;
}

.send-btn:hover {
    background: #06AD56;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.send-btn:active {
    transform: translateY(0) scale(0.98);
}

.emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    background: var(--bubble-other);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}

.emoji-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    background: none;
    border: none;
    touch-action: manipulation;
}

.emoji-btn:hover {
    background: var(--bg-color);
    transform: scale(1.3) rotate(15deg);
    border-radius: 50%;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal {
    background: var(--bubble-other);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
    touch-action: manipulation;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-row input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-primary);
    transition: var(--transition);
    -webkit-appearance: none;
}

.form-row input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
}

.form-row textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    min-height: 80px;
    background: var(--bg-color);
    color: var(--text-primary);
    -webkit-appearance: none;
}

.avatar-upload {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
    transition: var(--transition);
    touch-action: manipulation;
}

.avatar-preview:hover {
    transform: scale(1.1) rotate(5deg);
}

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

.avatar-upload-btn {
    padding: 8px 16px;
    background: var(--bg-color);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.avatar-upload-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.btn-cancel {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.btn-confirm {
    background: var(--primary-color);
    color: white;
    border: none;
}

.btn-confirm:hover {
    background: #06AD56;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.btn-danger {
    background: var(--error-color);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #E0342A;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 2000;
    animation: toastSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 90%;
    text-align: center;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 30px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.connection-status {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #FF9500;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1500;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.connection-status.error {
    background: var(--error-color);
    animation: shake 0.5s ease-in-out;
}

.connection-status.success {
    background: var(--success-color);
}

.status-icon {
    font-size: 14px;
}

.theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    touch-action: manipulation;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.1);
    transform: rotate(180deg);
}

.theme-toggle:active {
    background: rgba(255,255,255,0.2);
    transform: rotate(180deg) scale(0.9);
}

.theme-selector {
    display: flex;
    gap: 12px;
}

.theme-btn {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.theme-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.media-bubble {
    padding: 4px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.media-bubble:hover {
    transform: scale(1.02);
}

.media-content {
    max-width: 280px;
    max-height: 280px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    transition: var(--transition);
}

.media-content:hover {
    opacity: 0.9;
}

.media-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 70vh;
    overflow: hidden;
    margin-bottom: 16px;
}

.preview-content {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    object-fit: contain;
}

.context-menu {
    position: fixed;
    background: var(--bubble-other);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 4px;
    min-width: 140px;
    z-index: 3000;
    animation: fadeIn 0.15s ease-in;
}

.context-item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: var(--transition);
    color: var(--text-primary);
}

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

.context-item:active {
    background: var(--border-color);
    transform: scale(0.98);
}

.audio-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 280px;
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.audio-icon {
    font-size: 24px;
}

.audio-details {
    flex: 1;
    min-width: 0;
}

.audio-name {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-player {
    width: 100%;
    margin-top: 8px;
    border-radius: 8px;
    outline: none;
}

.audio-player::-webkit-media-controls-panel {
    background: var(--bg-color);
    border-radius: 8px;
}

@media (max-width: 480px) {
    .audio-bubble {
        max-width: 240px;
        padding: 8px 12px;
    }
    
    .audio-icon {
        font-size: 20px;
    }
    
    .audio-name {
    font-size: 13px;
}
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    background: var(--bubble-other);
    color: var(--text-primary);
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
}

.search-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
}

.search-clear:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text-primary);
}

.search-results-info {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.highlight {
    background: #FFEB3B;
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
}

.search-match {
    background: rgba(7, 193, 96, 0.15);
    border-left: 3px solid var(--primary-color);
}

@media (max-width: 480px) {
    .search-bar {
        padding: 8px 12px;
    }
    
    .search-bar input {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .search-results-info {
        font-size: 11px;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (max-width: 768px) {
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
        -webkit-backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        -webkit-box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .sidebar.open {
        transform: translateX(0);
        animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .chat-area {
        width: 100%;
    }

    .message-content {
        max-width: 85%;
    }

    .modal {
        width: 95%;
        max-height: 90vh;
        margin: 10px;
    }

    .message-wrapper {
        margin-bottom: 12px;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .input-container textarea {
        padding: 8px 12px;
    }

    .send-btn {
        padding: 8px 16px;
    }

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

    .contact-avatar {
        width: 40px;
        height: 40px;
    }

    .nav-title {
        font-size: 16px;
        max-width: 120px;
    }

    .top-nav {
        height: 50px;
    }

    .emoji-picker {
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 30px 20px;
        margin: 10px;
    }

    .login-header .logo {
        width: 60px;
        height: 60px;
        font-size: 30px;
    }

    .login-header h1 {
        font-size: 20px;
    }

    .top-nav {
        height: 50px;
        padding: 0 12px;
    }

    .nav-left, .nav-right {
        width: 50px;
    }

    .nav-btn {
        padding: 6px;
        font-size: 18px;
    }

    .sidebar {
        width: 100%;
        top: 50px;
    }

    .sidebar-header {
        padding: 12px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
    }

    .search-box {
        padding: 10px 12px;
    }

    .contact-item {
        padding: 10px 12px;
    }

    .contact-avatar {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }

    .contact-name {
        font-size: 13px;
    }

    .contact-preview {
        font-size: 11px;
    }

    .sidebar-footer {
        padding: 12px;
    }

    .btn-add-contact {
        padding: 10px;
    }

    .chat-messages {
        padding: 12px;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
        margin: 0 6px;
    }

    .message-bubble {
        padding: 8px 12px;
        font-size: 14px;
    }

    .message-time {
        font-size: 9px;
    }

    .input-toolbar {
        gap: 10px;
        margin-bottom: 6px;
    }

    .toolbar-btn {
        font-size: 18px;
        padding: 6px;
    }

    .send-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .input-container textarea {
        padding: 8px 10px;
        font-size: 14px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-header h3 {
        font-size: 15px;
    }

    .form-row {
        margin-bottom: 12px;
    }

    .form-row input {
        padding: 10px 12px;
    }

    .avatar-preview {
        width: 56px;
        height: 56px;
    }

    .modal-actions {
        margin-top: 16px;
    }

    .modal-actions button {
        padding: 10px;
        font-size: 13px;
    }

    .toast {
        bottom: 80px;
        padding: 10px 20px;
        font-size: 13px;
    }

    .emoji-picker {
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
        padding: 10px;
    }

    .emoji-btn {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }

    .theme-selector {
        gap: 8px;
    }

    .theme-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .login-container {
        padding: 24px 16px;
    }

    .login-header .logo {
        width: 50px;
        height: 50px;
        font-size: 26px;
    }

    .login-header h1 {
        font-size: 18px;
    }

    .login-form input {
        padding: 12px 14px;
        font-size: 13px;
    }

    .btn-primary {
        padding: 12px;
        font-size: 14px;
    }

    .contact-item {
        padding: 8px 10px;
    }

    .contact-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .message-wrapper {
        margin-bottom: 10px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .message-bubble {
        padding: 6px 10px;
        font-size: 13px;
    }

    .chat-input-area {
        padding: 8px 10px;
    }

    .input-container textarea {
        padding: 6px 8px;
    }

    .send-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}