:root {
    color-scheme: dark;
    --bg: #060606;
    --panel: rgba(14, 14, 14, 0.88);
    --panel-border: rgba(255, 255, 255, 0.1);
    --card: rgba(255, 255, 255, 0.035);
    --text: #f5f5f5;
    --muted: #9a9a9a;
    --accent: #f1f1f1;
    --accent-soft: rgba(255, 255, 255, 0.12);
    --danger: #8a8a8a;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
    --font-ui: "Space Grotesk", "Segoe UI Variable", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 32%),
        radial-gradient(circle at right, rgba(150, 150, 150, 0.08), transparent 26%),
        linear-gradient(180deg, #090909 0%, #040404 100%);
    color: var(--text);
    font-family: var(--font-ui);
}

body {
    overflow: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--accent);
    color: #050505;
    cursor: pointer;
    font-weight: 700;
    padding: 0.88rem 1.15rem;
    transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

button.ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--panel-border);
}

button.danger {
    background: var(--danger);
    color: #fff;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    outline: none;
}

input:focus,
textarea:focus {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

textarea {
    resize: none;
}

.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 0.7px, transparent 0.7px);
    background-size: 24px 24px;
    opacity: 0.18;
}

.app-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 1.2rem;
    min-height: 100vh;
    padding: 1.2rem;
}

.sidebar,
.workspace,
.call-panel,
.modal {
    border: 1px solid var(--panel-border);
    background: var(--panel);
    backdrop-filter: blur(28px);
    box-shadow: var(--shadow);
}

.sidebar {
    display: flex;
    flex-direction: column;
    border-radius: 30px;
    overflow: hidden;
}

.sidebar-top {
    padding: 1.3rem;
    border-bottom: 1px solid var(--panel-border);
}

.brand-block,
.profile-card,
.chat-header,
.sidebar-actions,
.modal-actions,
.call-controls,
.call-copy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
}

.brand-block h1,
.chat-header h2,
.modal-copy h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.35);
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.73rem;
}

.profile-card {
    margin: 1.2rem 0;
    padding: 0.85rem;
    border-radius: 22px;
    background: var(--card);
}

.profile-card p,
.chat-item p,
.empty-state p,
.modal-copy p,
.chat-header p {
    margin: 0;
    color: var(--muted);
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(92, 92, 92, 0.24));
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-actions {
    margin-bottom: 1rem;
}

.sidebar-actions button {
    flex: 1 1 auto;
}

.search-field,
.field,
.composer-field {
    display: grid;
    gap: 0.45rem;
}

.search-field span,
.field span,
.composer-field span {
    color: var(--muted);
    font-size: 0.8rem;
}

.chat-list,
.message-list,
.directory-list {
    overflow: auto;
}

.chat-list {
    padding: 0.5rem;
}

.chat-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 22px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.chat-item:hover,
.chat-item.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.chat-item-meta {
    display: grid;
    justify-items: end;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.chat-item-meta i {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-style: normal;
    font-weight: 700;
}

.workspace {
    position: relative;
    border-radius: 34px;
    padding: 1.4rem;
    overflow: hidden;
}

.empty-state,
.chat-view {
    height: calc(100vh - 2.8rem);
}

.empty-state {
    display: grid;
    place-content: center;
    gap: 0.45rem;
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}

.empty-state h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.4rem);
}

.chat-view {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
}

.chat-header {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--panel-border);
}

.chat-header-actions {
    display: flex;
    gap: 0.7rem;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding-right: 0.4rem;
}

.message {
    display: grid;
    gap: 0.35rem;
    max-width: 75%;
}

.message.own {
    align-self: end;
}

.message-body {
    padding: 1rem 1.1rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.message.own .message-body {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(115, 115, 115, 0.12));
}

.message-author {
    display: block;
    margin-bottom: 0.35rem;
    color: #d8d8d8;
    font-size: 0.76rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.message-body p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.message time {
    font-size: 0.76rem;
    color: var(--muted);
}

.message.own time {
    justify-self: end;
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: end;
}

.composer textarea {
    min-height: 58px;
    max-height: 180px;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(4, 6, 9, 0.74);
    backdrop-filter: blur(12px);
}

.modal {
    width: min(100%, 540px);
    border-radius: 30px;
    padding: 1.5rem;
}

.compact-modal {
    width: min(100%, 460px);
}

.wide-modal {
    width: min(100%, 700px);
}

.modal-copy {
    margin-bottom: 1rem;
}

.auth-tabs,
.auth-form,
.stack-form {
    display: grid;
    gap: 0.9rem;
}

.auth-tabs {
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 1rem;
}

.auth-tabs button.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.directory-list {
    max-height: 320px;
    padding-right: 0.25rem;
}

.directory-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem 1rem;
    margin-bottom: 0.55rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.directory-item input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

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

.presence.online {
    color: var(--accent);
}

.status-bar {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%) translateY(24px);
    z-index: 20;
    min-width: 240px;
    max-width: calc(100vw - 2rem);
    padding: 0.85rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--panel-border);
    background: rgba(8, 11, 17, 0.92);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.status-bar.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.status-bar[data-kind="error"] {
    border-color: rgba(255, 255, 255, 0.22);
}

.call-panel {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 15;
    width: min(420px, calc(100vw - 2rem));
    padding: 1rem;
    border-radius: 28px;
}

.call-media {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 0.8rem;
    margin: 1rem 0;
}

.call-media video {
    width: 100%;
    min-height: 150px;
    border-radius: 22px;
    background: #000;
    object-fit: cover;
}

.call-media video.video-off {
    min-height: 96px;
}

.call-controls {
    gap: 0.8rem;
}

.list-placeholder {
    padding: 1rem;
    color: var(--muted);
}

.hidden {
    display: none !important;
}

@media (max-width: 920px) {
    body {
        overflow: auto;
    }

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

    .sidebar,
    .workspace {
        min-height: auto;
    }

    .empty-state,
    .chat-view {
        height: auto;
        min-height: 60vh;
    }

    .composer {
        grid-template-columns: 1fr;
    }

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