:root {
    --sidebar-bg: #3f0e40;
    --sidebar-hover: #542756;
    --sidebar-active: #1164a3;
    --sidebar-text: #d1c6d1;
    --pane-bg: #ffffff;
    --border: #ddd;
    --text: #1d1c1d;
    --text-muted: #616061;
    --accent: #1164a3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    overflow-y: auto;
}

.workspace-header {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    padding: 0 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.me-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #1164a3;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.me-info { flex: 1; min-width: 0; }
.me-name { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: #fff; }
.admin-tag { font-size: 10px; background: rgba(255,255,255,0.15); padding: 1px 5px; border-radius: 4px; font-weight: 400; }
.role-tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 400; text-transform: uppercase; }
.role-tag.role-admin { background: #f0997b33; color: #ffd7c4; }
.role-tag.role-guest { background: #85b7eb33; color: #cfe6fb; }
.guest-note { font-size: 11px; color: rgba(209,198,209,0.7); }

#statusInput {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 12px;
    padding: 0;
}
#statusInput::placeholder { color: rgba(209,198,209,0.6); }

.logout-link { color: var(--sidebar-text); font-size: 11px; text-decoration: none; white-space: nowrap; }
.logout-link:hover { color: #fff; }

.sidebar-section { padding: 12px 0; }

.sidebar-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 16px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
}
.sidebar-title button {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}

.nav-list { display: flex; flex-direction: column; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px;
    font-size: 14px;
    cursor: pointer;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .hash { opacity: 0.7; }

.text-link {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 13px;
    text-align: left;
    padding: 5px 16px;
    cursor: pointer;
}
.text-link:hover { color: #fff; }

/* Chat pane */
.chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--pane-bg);
    min-width: 0;
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.chat-header h1 { margin: 0; font-size: 17px; font-weight: 700; }
.chat-header p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-row { display: flex; gap: 10px; }
.message-row .avatar { width: 36px; height: 36px; border-radius: 6px; font-size: 14px; }
.message-body { min-width: 0; }
.message-meta { display: flex; align-items: baseline; gap: 8px; }
.message-author { font-size: 14px; font-weight: 700; }
.message-time { font-size: 11px; color: var(--text-muted); }
.message-text { font-size: 14px; margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }

.empty-pane { color: var(--text-muted); font-size: 13px; padding: 20px; }

.message-form {
    display: flex;
    gap: 8px;
    padding: 12px 20px 18px;
    border-top: 1px solid var(--border);
}
.message-form input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
}
.message-form button {
    border: none;
    background: #007a5a;
    color: #fff;
    padding: 0 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.message-form button:hover { background: #148567; }

/* Modal (create channel / browse / add member) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    width: 380px;
    max-width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h2 { font-size: 16px; margin: 0 0 12px; }
.modal label { font-size: 12px; color: var(--text-muted); display: block; margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.modal-actions button.primary { background: #007a5a; color: #fff; border-color: #007a5a; }
.browse-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.browse-row button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }

/* Auth page (login) */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f8f8f8;
}
.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    width: 340px;
}
.auth-card h1 { font-size: 19px; margin: 0 0 16px; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form label { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.auth-form input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; font-size: 14px; }
.auth-form button { margin-top: 16px; border: none; background: #007a5a; color: #fff; padding: 10px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.auth-error { background: #fdecea; color: #a32d2d; font-size: 13px; padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; }
.auth-hint { font-size: 11px; color: var(--text-muted); margin-top: 20px; line-height: 1.6; }

@media (max-width: 700px) {
    .sidebar { width: 200px; }
}
