/* RustCord client.
 *
 * Shape language: people are circles, everything else is a squircle; one radius token,
 * short transitions, reduced-motion respected. Discord's layout proportions, our palette.
 */

:root {
    --squircle: 12px;
    --rail: 72px;
    --sidebar: 240px;
    --members: 240px;
    --surface-0: #1e1f22;
    --surface-1: #2b2d31;
    --surface-2: #313338;
    --surface-3: #383a40;
    --surface-4: #404249;
    --border: #232428;
    --text-primary: #f2f3f5;
    --text-secondary: #b5bac1;
    --text-muted: #949ba4;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --green: #23a55a;
    --red: #f23f43;
}

* {
    box-sizing: border-box;
}

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

body {
    background: var(--surface-2);
    color: var(--text-primary);
    font: 400 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    overflow: hidden;
}

button {
    font: inherit;
}

a {
    color: var(--text-secondary);
}

/* ---------------------------------------------------------------- sign-in */

.auth {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background: radial-gradient(1000px 520px at 20% -10%, #1c1f3a 0%, #000 60%);
    overflow: auto;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

.brand-name {
    font-weight: 650;
    letter-spacing: -0.01em;
}

.auth h1 {
    font-size: 22px;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.auth-foot {
    color: var(--text-muted);
    font-size: 12px;
    margin: 0;
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--surface-3);
}

label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0 0 6px;
}

input,
select,
textarea {
    width: 100%;
    background: #1e1f22;
    border: 1px solid #111214;
    border-radius: var(--squircle);
    color: var(--text-primary);
    padding: 10px 12px;
    font: inherit;
    margin-bottom: 12px;
}

textarea {
    resize: none;
    max-height: 180px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn {
    border: 1px solid transparent;
    background: var(--surface-3);
    color: var(--text-primary);
    border-radius: var(--squircle);
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease, transform 120ms ease;
}

.btn:hover {
    background: var(--surface-4);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn.primary:hover {
    background: var(--accent-hover);
}

.btn.ghost {
    background: transparent;
}

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

.btn.small {
    padding: 5px 10px;
    font-size: 12px;
}

.btn.wide {
    width: 100%;
}

.muted {
    color: var(--text-secondary);
}

.small {
    font-size: 12px;
}

.row {
    display: flex;
    gap: 8px;
}

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

/* ---------------------------------------------------------------- app shell */

.app {
    height: 100%;
    display: grid;
    grid-template-columns: var(--rail) var(--sidebar) minmax(0, 1fr) var(--members);
    background: var(--surface-2);
}

/* server rail */

.rail {
    background: var(--surface-0);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    overflow-y: auto;
}

.rail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.rail-item,
.rail-add {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 16px; /* things are squircles */
    background: var(--surface-1);
    color: var(--text-primary);
    font-weight: 650;
    cursor: pointer;
    transition: border-radius 180ms ease, background-color 180ms ease;
}

.rail-item:hover,
.rail-add:hover {
    border-radius: 14px;
    background: var(--accent);
}

.rail-item.active {
    border-radius: 14px;
    background: var(--accent);
}

.rail-add {
    color: var(--green);
    font-size: 20px;
}

/* sidebar */

.sidebar {
    background: var(--surface-1);
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invite-btn {
    flex: 0 0 auto;
    border: 1px solid var(--surface-4);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 11px;
    cursor: pointer;
}

.invite-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.channels {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px;
}

.group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 8px 4px;
}

.group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.channel-add {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    padding: 0 4px;
}

.channel-add:hover {
    color: var(--text-primary);
}

.channel {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 7px 8px;
    text-align: left;
    cursor: pointer;
}

.channel:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.channel.active {
    background: var(--surface-3);
    color: var(--text-primary);
    font-weight: 600;
}

.channel.joined .channel-name {
    color: var(--green);
}

.channel-sigil {
    color: var(--text-muted);
    width: 14px;
    text-align: center;
}

.channel-name {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.channel-count {
    font-size: 11px;
    color: var(--text-muted);
}

.group-empty {
    color: var(--text-muted);
    font-size: 12px;
    margin: 2px 8px 6px;
}

/* voice dock */

.voice-dock {
    margin: 8px;
    padding: 10px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--squircle);
}

.voice-dock-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
}

.signal {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(35, 165, 90, 0.18);
}

.voice-dock-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0 8px;
}

/* me strip */

.me {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--surface-0);
    border-top: 1px solid var(--border);
}

.me-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.me-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.me-tag {
    font-size: 11px;
    color: var(--text-muted);
}

.icon-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    border-radius: 8px;
    padding: 4px 6px;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--surface-3);
}

/* avatars: people are circles */

.avatar {
    --avatar-accent: var(--accent);
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 650;
    background: linear-gradient(135deg, var(--avatar-accent), #111214);
    color: #fff;
}

.avatar.big {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
}

/* chat */

.chat {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--surface-2);
}

.chat-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.hash {
    color: var(--text-muted);
    font-size: 18px;
}

.chat-title {
    font-weight: 650;
}

.chat-topic {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* call stage: who is here, video where someone is on camera or sharing */

.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 14px 16px 0;
    gap: 10px;
}

.stage-tiles {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    align-content: start;
    overflow-y: auto;
    min-height: 0;
}

.tile {
    position: relative;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--squircle);
    min-height: 140px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.tile-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.tile-name {
    position: absolute;
    left: 8px;
    bottom: 6px;
    font-size: 12px;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.55);
    border-radius: 6px;
    padding: 1px 6px;
}

.tile-live {
    position: absolute;
    right: 8px;
    top: 6px;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #fff;
    background: var(--red);
    border-radius: 4px;
    padding: 1px 6px;
}

.avatar.xl {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
    font-size: 26px;
}

.stage-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 14px;
}

.stage-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    min-height: 0;
}

.msg {
    display: flex;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 8px;
}

.msg:hover {
    background: rgba(0, 0, 0, 0.08);
}

.msg.grouped {
    padding-top: 2px;
    padding-bottom: 2px;
}

.avatar-spacer {
    width: 32px;
    flex: 0 0 32px;
}

.msg-body {
    min-width: 0;
    flex: 1;
}

.msg-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.msg-author {
    font-weight: 650;
    font-size: 14px;
}

.msg-time {
    color: var(--text-muted);
    font-size: 11px;
}

.msg-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14.5px;
    color: var(--text-primary);
}

.composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 8px 16px 18px;
}

.composer textarea {
    margin: 0;
    background: var(--surface-3);
    border-color: transparent;
    border-radius: 10px;
    padding: 11px 14px;
}

.composer .send {
    flex: 0 0 auto;
}

.empty {
    margin: 40px auto;
    max-width: 460px;
    text-align: center;
}

.empty h2 {
    font-size: 20px;
    margin: 0 0 6px;
}

/* members */

.members {
    background: var(--surface-1);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 8px;
}

.members-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 4px 8px 10px;
}

.member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
}

.member:hover {
    background: var(--surface-3);
}

.member-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crown {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border: 1px solid var(--surface-4);
    border-radius: 999px;
    padding: 1px 7px;
}

/* ---------------------------------------------------------------- modal + banner */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 20;
}

.modal-card {
    width: min(460px, 100%);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
}

.modal-card h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.modal-card .muted {
    font-size: 13px;
    margin: 0 0 16px;
}

.banner {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    max-width: min(560px, calc(100vw - 40px));
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-left: 3px solid var(--red);
    border-radius: var(--squircle);
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
    z-index: 30;
}

.banner[data-tone="ok"] {
    border-left-color: var(--green);
}

.audio-sink {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

@media (max-width: 1100px) {
    .app {
        grid-template-columns: var(--rail) var(--sidebar) minmax(0, 1fr);
    }
    .members {
        display: none;
    }
}

@media (max-width: 760px) {
    :root {
        --rail: 60px;
        --sidebar: 190px;
    }
    .chat-topic {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .rail-item,
    .rail-add {
        transition: none;
    }
}
