:root {
    --navbar-height: 74px;
    --sidebar-width: 240px;
    --primary-color: #1f6feb;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f2f4f7;
    height: 100%;
}

a {
    text-decoration: none;
}

.hidden {
    display: none;
}

.btn {
    text-decoration: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.94rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background: #1a5dcc;
}

.btn-secondary {
    color: #1f2937;
    border-color: #cbd5e0;
    background: #ffffff;
}

.btn-secondary:hover {
    background: #f8fafc;
}

.btn-secondary.checked {
    background: #f8fafc;
}

.btn-secondary.checked:hover {
    background: #f1f5f9;
}

.avatar img {
    border-radius: 50%;
    object-fit: cover;
}

.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    color: white;
    background: var(--primary-color);
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 100%;
    height: var(--navbar-height);
    padding: 14px 24px 14px 10px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    gap: 16px;
}

.navbar>div {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.navbar .logo {
    padding-left: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
}

.navbar .search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar .search-input {
    width: 50%;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.navbar .avatar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.navbar .profile-dropdown {
    position: relative;
    display: inline-flex;
}

.navbar .profile-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 160px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
    padding: 6px;
    display: none;
    z-index: 30;
}

.navbar .profile-menu.is-open {
    display: block;
}

.navbar .profile-menu-item {
    display: block;
    padding: 9px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #0f172a;
    font-size: 0.93rem;
    font-weight: 500;
}

.navbar .profile-menu-item:hover {
    background: #f8fafc;
}

.navbar .profile-menu-item-danger {
    color: #dc2626;
}

.navbar .profile-menu-item-danger:hover {
    color: #b91c1c;
    background: #fef2f2;
}

.navbar .avatar img {
    width: 38px;
    height: 38px;
}

.navbar .avatar-fallback {
    width: 38px;
    height: 38px;
    object-fit: cover;
}

.navbar .profile-name {
    font-size: 0.96rem;
    font-weight: 600;
    color: #0f172a;
}

.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    height: calc(100% - var(--navbar-height));
    width: var(--sidebar-width);
    padding: 14px 24px 14px 10px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
}

.sidebar .links {
    display: block;
    flex-direction: column;
}

.sidebar .links a {
    display: block;
}

.sidebar .links button {
    border: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding-top: 15px;
    padding-bottom: 15px;
    width: 100%;
}

.content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-top: var(--navbar-height);
    margin-left: var(--sidebar-width);
    box-sizing: border-box;
    width: calc(100vw - var(--sidebar-width));
    height: calc(100vh - var(--navbar-height));
}

.login-page {
    display: grid;
    place-items: center;
}

.login-card {
    width: min(360px, 90vw);
    background: #ffffff;
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
    margin: 0 0 16px;
    font-size: 1.4rem;
}

.login-card .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-center;
}

.login-card .field {
    margin-bottom: 14px;
}

.login-card label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #482d2d;
}

.login-card label span {
    margin-left: 5px;
    color: #dc2626;
}

.login-card input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1rem;
}

.login-card .error {
    border: 1px solid #dc2626;
    background-color: #fef2f2;
}

.login-card button {
    width: 100%;
}

.login-card .error-message {
    margin: 5px 0 0 10px;
    font-size: 0.9rem;
    color: #dc2626;
}

.profile-card {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 12px;
    color: white;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    align-items: flex-start;
}

.profile-card .avatar {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    position: relative;
}

.profile-card .avatar .profile-avatar-editable {
    cursor: pointer;
}

.profile-card .avatar img {
    width: 150px;
    height: 150px;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.profile-card .avatar-fallback {
    width: 150px;
    height: 150px;
    border: 4px solid white;
    font-size: 58px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.profile-card .avatar-edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid white;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    /* padding: 16px; */
    justify-content: center;
    font-size: 32px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.profile-card .avatar.profile-avatar-editable:hover .avatar-edit-overlay {
    opacity: 1;
}

.profile-card .profile-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-card .profile-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.profile-card .profile-username {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
}

.profile-card .profile-bio {
    font-size: 16px;
    margin-bottom: 20px;
    opacity: 0.95;
    line-height: 1.5;
}

.profile-card .profile-member-since {
    font-size: 14px;
    opacity: 0.85;
}

.profile-card .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 14px;
}

.profile-card .stat-card {
    background: white;
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}

.profile-card .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.profile-card .stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.profile-card .stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-card .stat-subtext {
    margin-top: 6px;
    font-size: 12px;
    color: #888;
}

.chat {
    display: grid;
    grid-template-columns: 280px 1fr 260px;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.chat .chat-panel {
    background: #ffffff;
    border-left: 1px solid #dcdcdc;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat .chat-panel h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 12px 14px;
    font-size: 16px;
    border-bottom: 1px solid #ececec;
    background: #f8f8f8;
}

.chat .channel-add {
    width: 28px;
    height: 28px;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex: 0 0 auto;
}

.chat .channel-add:hover {
    background: #f3f4f6;
}

.chat .chat-panel.messages-panel {
    min-width: 0;
}

.chat .chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}

.chat .chat-list li {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f1f1;
    font-size: 14px;
}

.chat .chat-list li:last-child {
    border-bottom: 0;
}

.chat .chat-list li.active {
    background: #eef4ff;
    font-weight: 600;
}

.chat .messages {
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 12px;
    min-height: 0;
    flex: 1 1 auto;
}

.chat .message-item {
    max-width: 75%;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #ededed;
    background: #f9f9f9;
}

.chat .message-item.self {
    margin-left: auto;
    background: #e9f7ee;
    border-color: #d2efdb;
}

.chat .message-meta {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #666;
}

.chat .message-composer {
    display: flex;
    gap: 10px;
    padding: 12px 14px 14px;
    border-top: 1px solid #ececec;
    background: #fafafa;
}

.chat .message-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d0d7de;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.chat .message-input:focus {
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.chat .message-send {
    border: 0;
    border-radius: 10px;
    padding: 0 16px;
    background: #1f6feb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.chat .message-send:hover {
    background: #1a5dcc;
}