:root {
    color-scheme: dark;
    --ink: #f2f5f4;
    --muted: #aeb8b6;
    --dim: #74817f;
    --bg: #171918;
    --rail: #111313;
    --panel: #212624;
    --panel-2: #292f2d;
    --line: #38423f;
    --teal: #42d6b5;
    --coral: #ff7a68;
    --gold: #f0c35b;
    --danger: #ff5f7c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
}

button,
input,
textarea {
    font: inherit;
}

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

.login-shell {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(66, 214, 181, 0.16), transparent 32%),
        linear-gradient(315deg, rgba(255, 122, 104, 0.13), transparent 38%),
        var(--bg);
}

.login-panel {
    width: min(420px, 100%);
    padding: 34px;
    background: #202523;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.brand-mark,
.server-dot,
.avatar {
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #0b1513;
    background: var(--teal);
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    font-size: 28px;
}

.login-panel h1 {
    margin: 22px 0 10px;
    font-size: 36px;
}

.login-panel p {
    margin: 0 0 24px;
    color: var(--muted);
    line-height: 1.55;
}

.primary-action,
.composer button,
.channel-create button,
.quick-create button {
    border: 0;
    border-radius: 6px;
    background: var(--teal);
    color: #0b1513;
    cursor: pointer;
    font-weight: 800;
}

.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    padding: 0 16px;
}

.auth-error {
    margin: 0 0 16px;
    padding: 11px 12px;
    border: 1px solid rgba(255, 95, 124, 0.48);
    border-radius: 6px;
    background: rgba(255, 95, 124, 0.12);
    color: #ffd6de;
    line-height: 1.4;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 0 0 18px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #171b1a;
}

.auth-tab {
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

.auth-tab.active {
    background: var(--panel-2);
    color: var(--ink);
}

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

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

.auth-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #171b1a;
    color: var(--ink);
    outline: none;
    padding: 0 12px;
}

.auth-form input:focus,
.quick-create input:focus,
.channel-create input:focus,
.composer textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(66, 214, 181, 0.12);
}

.auth-form .primary-action {
    margin-top: 2px;
}

.sso-link {
    display: block;
    margin-top: 18px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.sso-link:hover {
    color: var(--ink);
}

.app-shell {
    height: 100%;
    display: grid;
    grid-template-columns: 76px 276px minmax(0, 1fr);
    overflow: hidden;
}

.server-rail {
    background: var(--rail);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 14px 10px;
    border-right: 1px solid #0d0f0f;
}

.server-dot {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    flex: 0 0 auto;
    background: var(--panel-2);
    color: var(--ink);
    transition: background 160ms ease, color 160ms ease;
}

.server-dot.active,
.server-dot:hover,
.home-dot {
    background: var(--teal);
    color: #081210;
}

.quick-create {
    width: 100%;
    margin-top: auto;
    display: grid;
    gap: 8px;
}

.quick-create input,
.channel-create input,
.composer textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #171b1a;
    color: var(--ink);
    outline: none;
}

.quick-create input {
    min-width: 0;
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
}

.quick-create button,
.channel-create button {
    height: 34px;
}

.channel-panel {
    min-width: 0;
    background: var(--panel);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    border-right: 1px solid #151817;
}

.channel-panel header {
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--line);
}

.channel-panel header strong,
.chat-header strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-panel header span,
.user-strip span,
.chat-header small,
.message time {
    color: var(--dim);
    font-size: 12px;
}

.channel-list {
    padding: 12px;
    overflow-y: auto;
}

.channel-list a {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-list a span,
.chat-header span {
    color: var(--gold);
    font-weight: 900;
}

.channel-list a.active,
.channel-list a:hover {
    background: var(--panel-2);
    color: var(--ink);
}

.channel-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
}

.channel-create input {
    height: 38px;
    padding: 0 10px;
}

.user-strip {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    gap: 10px;
    align-items: center;
    min-height: 64px;
    padding: 12px;
    background: #181c1b;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    flex: 0 0 auto;
}

.user-strip strong,
.user-strip span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-strip button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.chat-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--bg);
}

.chat-header {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 22px;
    border-bottom: 1px solid var(--line);
}

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

.message-list {
    overflow-y: auto;
    padding: 18px 22px;
}

.empty-state {
    color: var(--dim);
    padding: 28px 0;
}

.message {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    padding: 9px 0;
}

.message header {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.message p {
    margin: 4px 0 0;
    color: #e1e7e5;
    line-height: 1.48;
    overflow-wrap: anywhere;
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--line);
    background: #151817;
}

.composer textarea {
    min-height: 44px;
    max-height: 140px;
    resize: vertical;
    padding: 12px 14px;
    line-height: 1.35;
}

.composer button {
    height: 44px;
}

@media (max-width: 780px) {
    .app-shell {
        grid-template-columns: 62px minmax(0, 1fr);
    }

    .channel-panel {
        display: none;
    }

    .server-dot {
        width: 42px;
        height: 42px;
    }

    .quick-create input {
        display: none;
    }

    .chat-header {
        padding: 0 14px;
    }

    .message-list {
        padding: 14px;
    }

    .composer {
        grid-template-columns: minmax(0, 1fr);
        padding: 12px;
    }
}
