:root {
    --bg: #080808;
    --panel: rgba(14, 14, 14, 0.92);
    --panel-border: rgba(255, 255, 255, 0.18);
    --text: #f5f5f5;
    --muted: #8c8c8c;
    --danger: #cb5d5d;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

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

body {
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 35%),
        linear-gradient(180deg, #050505 0%, #090909 50%, #050505 100%);
    color: var(--text);
    font-family: "Courier New", Courier, monospace;
}

button,
input,
textarea {
    font: inherit;
}

.screen {
    height: 100vh;
    position: relative;
    padding: 24px;
    overflow: hidden;
}

.panel {
    position: absolute;
    inset: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.panel-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.panel-login,
.panel-chat {
    display: grid;
    place-items: center;
}

.panel-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    height: 100%;
}

.panel.hidden {
    display: none;
}

.hero-title {
    margin: 0;
    font-size: clamp(1.7rem, 4.5vw, 3.2rem);
    line-height: 1;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-align: center;
    font-weight: 300;
    white-space: nowrap;
}

.hero-copy {
    padding: 0 12px;
}

.enter-shell {
    padding: 14px;
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.18);
}

.login-box,
.chat-shell {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

.login-box {
    width: min(100%, 460px);
    display: grid;
    gap: 18px;
    padding: 28px;
}

.field-box {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.25);
}

.field-box-wide {
    min-height: 128px;
}

.field-box span {
    color: var(--muted);
    font-size: 0.9rem;
    letter-spacing: 0.12em;
}

.field-box input,
.field-box textarea {
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    width: 100%;
    resize: none;
}

.square-button {
    border: 1px solid var(--panel-border);
    background: #111;
    color: var(--text);
    min-height: 56px;
    min-width: 150px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    cursor: pointer;
    transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.square-button:hover,
.square-button:focus-visible {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.square-button-small {
    min-width: 96px;
    min-height: 44px;
}

.chat-shell {
    width: min(100%, 920px);
    height: min(78vh, 760px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 18px;
    padding: 24px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 18px;
}

.chat-title {
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.chat-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.9rem;
}

.messages {
    display: grid;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    padding-right: 4px;
}

.message-card {
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.2);
    padding: 14px 16px;
}

.message-top {
    display: flex;
    justify-content: space-between;
    min-height: 0;
    align-items: center;
    gap: 18px;
    margin-bottom: 10px;
}

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

.message-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
}

.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.message-delete {
    border: 1px solid rgba(203, 93, 93, 0.45);
    background: rgba(60, 10, 10, 0.24);
    color: var(--danger);
    min-height: 36px;
    padding: 0 12px;
    cursor: pointer;
}

.composer {
    display: grid;
    gap: 16px;
}

.status-text {
    min-height: 1.25rem;
    margin: 0;
    color: var(--muted);
}

.status-text.error {
    color: var(--danger);
}

@media (max-width: 768px) {
    .screen {
        padding: 16px;
    }

    .panel {
        inset: 16px;
    }

    .panel-hero {
        min-height: 360px;
        gap: 24px;
    }

    .hero-title {
        white-space: normal;
        line-height: 1.15;
    }

    .chat-shell {
        height: calc(100vh - 32px);
        padding: 18px;
    }

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

    .square-button,
    .square-button-small {
        width: 100%;
    }
}