* {
    box-sizing: border-box;
}

:root {
    --bg: #08111f;
    --bg2: #101a2d;
    --panel: rgba(15, 23, 42, 0.78);
    --panel-solid: #111c31;
    --panel-soft: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --text: #f5f7fb;
    --muted: #94a3b8;
    --cyan: #22d3ee;
    --blue: #38bdf8;
    --purple: #8b5cf6;
    --green: #22c55e;
    --red: #ef4444;
    --shadow: 0 20px 60px rgba(0,0,0,0.35);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(34, 211, 238, 0.10), transparent 22%),
        radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.12), transparent 26%),
        linear-gradient(180deg, var(--bg), var(--bg2));
}

body.auth-body,
body.app-body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(80px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}

.orb-1 {
    width: 320px;
    height: 320px;
    background: var(--cyan);
    top: -80px;
    left: -80px;
}

.orb-2 {
    width: 360px;
    height: 360px;
    background: var(--purple);
    right: -120px;
    bottom: -120px;
}

.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 28px;
    align-items: center;
    padding: 32px;
}

.brand-panel,
.auth-card,
.sidebar,
.conversation-list-panel,
.chat-header,
.messages,
.composer {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.brand-panel {
    border-radius: var(--radius-xl);
    padding: 36px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.brand-badge.small {
    font-size: 10px;
    padding: 7px 10px;
    margin-bottom: 10px;
}

.brand-panel h1 {
    margin: 0 0 14px;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.brand-panel h1 span {
    color: var(--cyan);
}

.brand-panel p {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.7;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.feature-card {
    border: 1px solid var(--border);
    background: var(--panel-soft);
    border-radius: 18px;
    padding: 18px;
}

.feature-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
}

.feature-card span {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.auth-card {
    border-radius: var(--radius-xl);
    padding: 26px;
    position: relative;
    z-index: 1;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(139, 92, 246, 0.18));
    border-color: rgba(139, 92, 246, 0.4);
}

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

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

.auth-form h2 {
    margin: 8px 0 6px;
    font-size: 1.6rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.94rem;
    color: #dbe6f5;
}

.auth-form input,
.select-mode,
textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    outline: none;
}

.auth-form input:focus,
.select-mode:focus,
textarea:focus {
    border-color: rgba(34, 211, 238, 0.6);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.btn-primary,
.btn-secondary,
.user-row,
.logout-link,
.back-link,
.conversation-card {
    transition: all 0.18s ease;
}

.btn-primary {
    border: 0;
    border-radius: 16px;
    padding: 15px 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-secondary {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 700;
    color: var(--text);
    background: rgba(255,255,255,0.05);
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
}

.form-message {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.94rem;
}

.form-message.success {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.28);
}

.form-message.error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.28);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    padding: 20px;
}

.sidebar,
.conversation-list-panel {
    border-radius: var(--radius-xl);
}

.sidebar {
    padding: 20px;
    overflow: auto;
}

.sidebar-header,
.panel-header,
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.sidebar-header h1,
.panel-header h2 {
    margin: 0;
}

.logout-link,
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: #dce7f5;
    padding: 10px 12px;
    border-radius: 12px;
}

.logout-link:hover,
.back-link:hover {
    background: rgba(255,255,255,0.08);
}

.me-card {
    margin-top: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
}

.avatar,
.mini-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
}

.avatar {
    width: 48px;
    height: 48px;
}

.avatar.large {
    width: 58px;
    height: 58px;
    font-size: 1.08rem;
}

.mini-avatar {
    width: 40px;
    height: 40px;
}

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

.section-title {
    margin: 20px 0 10px;
    color: var(--muted);
    font-size: 0.84rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-row-form {
    margin: 0;
}

.user-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
}

.user-row:hover {
    background: rgba(255,255,255,0.08);
}

.user-row span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-row small {
    color: var(--muted);
}

.conversation-list-panel {
    padding: 24px;
    overflow: auto;
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.conversation-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
}

.conversation-card:hover {
    background: rgba(255,255,255,0.07);
    transform: translateY(-1px);
}

.conversation-meta {
    flex: 1;
    min-width: 0;
}

.conversation-top,
.conversation-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.conversation-bottom {
    margin-top: 8px;
}

.preview-text {
    min-width: 0;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill,
.presence-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.24);
    color: #bbf7d0;
}

.empty-state {
    margin-top: 24px;
    padding: 36px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: 22px;
    color: var(--muted);
}

.empty-state h3 {
    margin-top: 0;
    color: var(--text);
}

.chat-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 16px;
    padding: 18px;
}

.chat-header,
.messages,
.composer {
    border-radius: var(--radius-lg);
}

.chat-header {
    padding: 16px 18px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.messages {
    min-height: 0;
    overflow: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-row {
    display: flex;
}

.message-row.me {
    justify-content: flex-end;
}

.message-row.them {
    justify-content: flex-start;
}

.message-bubble {
    max-width: min(72%, 720px);
    padding: 14px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
}

.message-row.me .message-bubble {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.20), rgba(139, 92, 246, 0.18));
}

.message-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.message-time {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.composer {
    padding: 16px;
}

.composer-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.composer-form {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 12px;
    align-items: end;
}

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

.send-btn {
    height: 56px;
}

.alert-inline {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.92rem;
}

.alert-inline.error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.24);
}

.alert-inline.success {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.24);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
}

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

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

@media (max-width: 1024px) {
    .auth-shell {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 46vh;
    }
}

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

    .auth-shell,
    .app-shell,
    .chat-shell {
        padding: 12px;
    }

    .brand-panel,
    .auth-card,
    .sidebar,
    .conversation-list-panel,
    .chat-header,
    .messages,
    .composer {
        border-radius: 18px;
    }

    .conversation-top,
    .conversation-bottom,
    .composer-tools,
    .composer-form {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .message-bubble {
        max-width: 88%;
    }

    .presence-pill {
        display: none;
    }
}
.dashboard-search-form {
    margin-top: 16px;
}

.dashboard-search-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    outline: none;
}

.dashboard-search-input:focus {
    border-color: rgba(34, 211, 238, 0.6);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}