:root {
    --bg-main: #090a0f;
    --bg-sidebar: #0d0f16;
    --bg-surface: #12151f;
    --bg-surface-elevated: #181c2b;
    --bg-card: #141824;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-active: rgba(79, 107, 254, 0.08);
    
    --primary: #4f6bfe;
    --primary-hover: #637efe;
    --primary-subtle: rgba(79, 107, 254, 0.12);
    --primary-border: rgba(79, 107, 254, 0.25);
    
    --accent-emerald: #10b981;
    --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-subtle: #475569;
    
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(79, 107, 254, 0.45);
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(100% 100% at 50% 0%, rgba(79, 107, 254, 0.04) 0%, transparent 60%),
        radial-gradient(80% 60% at 100% 100%, rgba(16, 185, 129, 0.02) 0%, transparent 50%);
    background-attachment: fixed;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Header */
.app-header {
    height: 60px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 20;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #4f6bfe 0%, #3b52d4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(79, 107, 254, 0.3);
}

.brand-logo svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--primary-subtle);
    color: #93a5ff;
    border: 1px solid var(--primary-border);
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.profile-name {
    font-weight: 500;
    color: var(--text-primary);
}

.profile-key-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 10px rgba(79, 107, 254, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-hover);
}

/* Main Layout */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.app-sidebar {
    width: 290px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.peer-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.peer-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
}

.peer-card:hover {
    background: var(--bg-hover);
}

.peer-card.active {
    background: var(--bg-active);
    border-color: rgba(79, 107, 254, 0.2);
}

.peer-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #1e2333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    position: relative;
    border: 1px solid var(--border-subtle);
}

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

.status-online { background: var(--accent-emerald); }
.status-away { background: var(--accent-amber); }
.status-busy { background: var(--accent-rose); }
.status-offline { background: var(--text-muted); }

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

.peer-name {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.peer-preview {
    font-size: 0.74rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden;
}

.chat-header {
    height: 54px;
    padding: 0 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    background: var(--accent-emerald-subtle);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--accent-emerald);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.security-badge:hover {
    background: rgba(16, 185, 129, 0.2);
}

/* Messages Stream */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.encryption-notice {
    text-align: center;
    padding: 8px 16px;
    margin: 4px auto 14px;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 60%;
}

.message-bubble-wrapper.outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-bubble-wrapper.incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-sender-name {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
    padding: 0 4px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
}

.message-bubble-wrapper.outgoing .message-bubble {
    background: #1f273d;
    color: #ffffff;
    border: 1px solid rgba(79, 107, 254, 0.25);
    border-bottom-right-radius: 2px;
}

.message-bubble-wrapper.incoming .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    padding: 0 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.e2ee-check {
    color: var(--accent-emerald);
    font-size: 0.68rem;
}

/* File Transfer Card */
.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface-elevated);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    max-width: 400px;
    box-shadow: var(--shadow-subtle);
}

.file-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    background: rgba(79, 107, 254, 0.15);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.progress-bar-container {
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.2s ease;
}

/* Input Area */
.chat-input-area {
    padding: 14px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
}

.input-box-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 5px 8px 5px 12px;
    transition: border-color 0.15s ease;
}

.input-box-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px var(--primary-border);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

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

.modal-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.key-fingerprint-box {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: #93a5ff;
    word-break: break-all;
    user-select: all;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
}

.form-input:focus {
    border-color: var(--border-focus);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Auth & Lock Screens */
.auth-page-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    padding: 20px;
    background-image: 
        radial-gradient(80% 60% at 50% 20%, rgba(79, 107, 254, 0.08) 0%, transparent 60%),
        radial-gradient(60% 50% at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 28px 24px;
    box-shadow: var(--shadow-modal);
}

.auth-header {
    text-align: center;
    margin-bottom: 20px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 18px;
    gap: 3px;
}

.auth-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all 0.15s ease;
}

.auth-tab-btn:hover {
    color: var(--text-primary);
}

.auth-tab-btn.active {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-error-badge {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
    font-size: 0.78rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    text-align: center;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0;
    color: var(--text-subtle);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.auth-divider span {
    padding: 0 10px;
}

.auth-security-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}
