:root {
    --bg: #f3f4f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #6b2d5c;
    --primary-dark: #4d1f42;
    --gold: #c9a227;
    --border: #e5e7eb;
    --danger: #b91c1c;
    --success: #047857;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: var(--primary);
    color: white;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    color: white;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: .2px;
}

.topbar nav a {
    color: white;
    text-decoration: none;
    margin-left: 14px;
    font-weight: 600;
}

.page {
    width: min(1050px, 94vw);
    margin: 22px auto;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(0,0,0,.06);
    padding: 20px;
}

h1, h2, h3 {
    margin-top: 0;
}

.form {
    display: grid;
    gap: 12px;
}

label {
    font-weight: 700;
}

input, textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font: inherit;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

button, .btn {
    background: var(--primary);
    color: white;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    display: inline-block;
}

button:hover, .btn:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #374151;
}

.notice {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 12px;
}

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

.notice.success {
    background: #d1fae5;
    color: var(--success);
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
}

.user-list {
    display: grid;
    gap: 10px;
}

.user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    background: white;
}

.user-row:hover {
    border-color: var(--gold);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    color: white;
    display: grid;
    place-items: center;
    font-weight: 900;
    flex: 0 0 auto;
}

.user-meta {
    flex: 1;
}

.muted {
    color: var(--muted);
    font-size: .9rem;
}

.badge {
    background: var(--gold);
    color: #111827;
    font-size: .78rem;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 900;
}

.chat-window {
    display: flex;
    flex-direction: column;
    min-height: 65vh;
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    display: grid;
    gap: 10px;
    padding: 10px 0;
}

.message {
    max-width: 72%;
    padding: 11px 13px;
    border-radius: 16px;
    line-height: 1.4;
}

.message.me {
    margin-left: auto;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.them {
    margin-right: auto;
    background: #eef2ff;
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: .72rem;
    opacity: .75;
    margin-top: 4px;
}

.chat-form {
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.chat-form textarea {
    min-height: 48px;
}

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 22px;
}

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

    .topbar {
        align-items: flex-start;
        gap: 10px;
        flex-direction: column;
    }

    .topbar nav a {
        margin-left: 0;
        margin-right: 12px;
    }

    .message {
        max-width: 88%;
    }

    .chat-form {
        flex-direction: column;
    }
}


/* Voice / Video Call UI */
.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 18px 0;
}
.video-grid video {
    width: 100%;
    min-height: 240px;
    background: #111827;
    border-radius: 16px;
    border: 3px solid var(--border);
    object-fit: cover;
}
.call-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
@media (max-width: 760px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
    .video-grid video {
        min-height: 200px;
    }
}


/* NAVAH AI */
.navah-hero { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; }
.ai-messages { min-height:360px; max-height:58vh; overflow:auto; display:grid; gap:12px; padding:10px; background:#f9fafb; border:1px solid var(--border); border-radius:14px; }
.ai-message { padding:12px 14px; border-radius:14px; line-height:1.45; white-space:normal; }
.ai-message.user { background:#e0ecff; margin-left:8%; }
.ai-message.assistant { background:#fff; border:1px solid var(--border); margin-right:8%; }
.ai-form { display:grid; grid-template-columns:1fr auto; gap:10px; margin-top:12px; align-items:end; }
.ai-form textarea { min-height:70px; }
.ai-sources { margin-top:12px; font-size:.92rem; }
.knowledge-row { padding:12px 0; border-bottom:1px solid var(--border); }
@media (max-width: 720px) { .ai-form { grid-template-columns:1fr; } .navah-hero { display:block; } }
