
:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --secondary: #10b981;
    --border: #d1d5db;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Inter, system-ui, sans-serif;
    background: radial-gradient(circle at top, #e0efff, var(--bg));
    color: var(--text);
    min-height: 100%;
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.app-header h1 {
    margin: 0;
    font-size: 28px;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
}

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

.hidden {
    display: none !important;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    color: var(--muted);
}

.tab.active {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

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

.auth-form.active {
    display: flex;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 15px;
}

button {
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
}

.primary-button {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
}

.secondary-button {
    background: var(--secondary);
    color: white;
    padding: 10px 14px;
    margin-right: 10px;
}

.status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
}

#main-status {
    display: none !important;
}

.group-members {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.group-members-title {
    font-weight: 700;
}

.group-members-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
}

.group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.status.info {
    background: #eff6ff;
    color: #1d4ed8;
}

.status.success {
    background: #ecfdf5;
    color: #047857;
}

.status.error {
    background: #fee2e2;
    color: var(--danger);
}

.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-top: 20px;
    min-height: calc(100vh - 220px);
    height: calc(100vh - 220px);
}

.sidebar {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: 100%;
    min-height: 0;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
}

.contact-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    grid-auto-rows: max-content;
}

.contact-item {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-item.active {
    background: #e0efff;
    border-color: var(--primary);
}

.contact-item .type {
    color: var(--muted);
    font-size: 12px;
}

.chat-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
}

.message-list {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    gap: 10px;
    grid-auto-rows: max-content;
}

.message {
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    max-width: 80%;
}

.message.you {
    background: #dbeafe;
    margin-left: auto;
}

.message-header {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.composer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.composer input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-size: 15px;
}

@media (max-width: 960px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 16px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }
}
