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

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #0a0a0a;
    background-image: 
        radial-gradient(at 20% 30%, rgba(40, 40, 40, 0.3) 0px, transparent 50%),
        radial-gradient(at 80% 70%, rgba(50, 50, 50, 0.2) 0px, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    position: relative;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 480px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.glass-card {
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 24px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.glass-card::-webkit-scrollbar {
    width: 4px;
}

.glass-card::-webkit-scrollbar-track {
    background: transparent;
}

.glass-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.glass-card::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12);
}

.logo {
    text-align: center;
    margin-bottom: 48px;
    margin-top: 32px;
    flex-shrink: 0;
}

.logo h1 {
    font-size: 56px;
    font-weight: 300;
    color: #ffffff;
    letter-spacing: 12px;
    margin-bottom: 12px;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
}

.logo p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    letter-spacing: 3px;
    font-weight: 300;
}

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

label {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    color: #ffffff;
    font-size: 15px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 300;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.02);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 300;
}

.btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:not(:disabled):active {
    transform: scale(0.98);
}

.btn-text {
    display: inline-block;
}

.btn-loader {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-primary .loader {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #0a0a0a;
}

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

.btn-primary {
    background: rgba(255, 255, 255, 0.95);
    color: #0a0a0a;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.btn-primary:hover:not(:disabled) {
    background: #ffffff;
    box-shadow: 0 6px 24px rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-small {
    width: auto;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 0;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon.btn-small {
    width: 40px;
    height: 40px;
}

.btn-icon.btn-small, 
#searchBtn,
#backupBtn,
#logoutBtn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-icon.btn-small:hover,
#searchBtn:hover,
#backupBtn:hover,
#logoutBtn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-back {
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.btn-small .icon {
    width: 18px;
    height: 18px;
}

.divider {
    text-align: center;
    margin: 32px 0;
    position: relative;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.divider span {
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(20px);
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

.message {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 300;
}

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

.message.error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.message.success {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.hidden {
    display: none !important;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.top-bar h2 {
    color: #ffffff;
    font-size: 36px;
    letter-spacing: 8px;
    margin-bottom: 4px;
    font-weight: 300;
}

.subtitle {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    letter-spacing: 0.5px;
    font-weight: 300;
}

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

.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    min-width: 0;
}

.section-title {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

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

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.chat-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

.chat-item strong {
    color: #ffffff;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.unread-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.9);
    color: #0a0a0a;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 10px;
    min-width: 20px;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.3);
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 300;
}

.empty-state small {
    font-size: 13px;
    opacity: 0.7;
    font-weight: 300;
}

.chat-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

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

.chat-header h3 {
    color: #ffffff;
    font-size: 20px;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
}

.chat-subtitle {
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    letter-spacing: 0.5px;
    font-weight: 300;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    margin-bottom: 16px;
    min-height: 0;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

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

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

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.message-bubble-container {
    margin-bottom: 12px;
    display: flex;
    animation: messageSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-bubble-container.sent {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    word-break: break-word;
}

.message-bubble-container.sent .message-bubble {
    background: rgba(255, 255, 255, 0.95);
    color: #0a0a0a;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

.message-bubble-container.received .message-bubble {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.message-text {
    margin-bottom: 6px;
    line-height: 1.5;
    font-size: 14px;
    font-weight: 300;
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-time {
    font-size: 10px;
    opacity: 0.5;
    font-weight: 300;
}

.read-status {
    font-size: 11px;
    opacity: 0.6;
    font-weight: 400;
}

.message-input {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

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

@media (min-width: 601px) {
    .container {
        padding: 20px;
        height: auto;
        max-height: 92vh;
    }

    .glass-card {
        border-radius: 28px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        padding: 40px;
        height: auto;
        max-height: 88vh;
    }

    body {
        overflow: auto;
    }
}

@media (max-width: 600px) {
    .logo h1 {
        font-size: 42px;
        letter-spacing: 8px;
    }

    .top-bar h2 {
        font-size: 28px;
        letter-spacing: 6px;
    }
}