body {
    font-family: monospace;
    display: grid;
    grid-template-areas: "sidebar chat" "sidebar talk";
    grid-template-columns: auto 1fr;
    grid-template-rows:1fr auto;
    @media screen and (min-width: 600px) {
        height: 100vh;
    }
    gap: 10px;
    padding: 0;
    margin: 0;
    color: black;
    --page-bg: white;
    --message-bg: #dadada;

    @media (prefers-color-scheme: dark) {
        color: white;
        --page-bg: #333;
        --message-bg: #222;
    }
    background: var(--page-bg);
}

input#menu_open {
    position: absolute;
    left: -100px;
    visibility: hidden;
}

* {
    box-sizing: border-box;
}

nav#sidebar {
    grid-area: sidebar;
    background: var(--message-bg);
    display: flex;
    flex-direction: column;

    > * {
        padding: 10px;
    }

    h1 {
        margin: 0;
        font-size: 20px;
        @media screen and (min-width: 600px) {
            display: none;
        }
    }

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

    a.active, a:hover, a:focus-visible {
        background: var(--page-bg);
    }

    a.hasNew {
        font-style: italic;

        &:after {
            content: "*";
        }
    }

    form#user {
        display: flex;
        flex-direction: column;

        label {
            line-height: 20px;
        }

        input {
            width: 100%;
            height: 40px;
        }

        button {
            margin-top: 10px;
            height: 40px;
        }
    }
}

section#help {
    grid-area: chat;
    @media screen and (min-width: 600px) {
        max-height: 100vh;
        overflow: auto;
    }
}

button:not([disabled]) {
    cursor: pointer;
}

section#channel_messages {
    grid-area: chat;
    display: flex;
    flex-direction: column-reverse;
    padding-right: 10px;

    > * {
        flex-shrink: 0
    }

    > div {
        position: relative;

        header {
            display: flex;
            align-items: center;
            gap: 10px;
            line-height: 20px;
        }

        .message-content {
            background-color: #e3e3e3;
            @media (prefers-color-scheme: dark) {
                background-color: #222;
            }
            padding: 10px;
        }

        margin-bottom: 20px;

        .replies.has-some {
            position: absolute;
            bottom: -0.5em;
            right: -0.5em;
            padding: 0 5px;
            border-radius: 0.5em;
            border: 1px solid;
            text-decoration: none;
            background-color: white;
            @media (prefers-color-scheme: dark) {
                background-color: #222;
            }

            &::after {
                content: "➜";
            }
        }

        &.isNew:not(.self) .message-content,
        &.hasNewReplies .replies.has-some {
            color: white;
            background: #043872;
        }
    }

    > a {
        line-height: 20px;
        margin: 20px 0;
    }

    > .return-to-channel {
        align-self: flex-start;
        background: white;
        color: inherit;
        @media (prefers-color-scheme: dark) {
            background-color: #222;
        }
        padding: 0 5px;
        border-radius: 0.5em;
        border: 1px solid;
        text-decoration: none;

        &:before {
            content: "➜";
            display: inline-block;
            transform: rotate(180deg);
            margin-right: 10px;
        }
    }

    > .message_author {
        margin-top: 10px;
        margin-bottom: 5px;
        display: inline-block;
    }

    > .link-to-older,
    > .link-to-recent {
        text-align: center;
        display: block;
        line-height: 40px;
    }

    @media (min-width: 600px) {
        overflow-y: auto;
    }
    @media (max-width: 600px) {
        min-height: calc(50vh);
    }
    padding-top: 60px;
}

@media (min-width: 600px) {
    #menu_spacer {
        flex-grow: 1;
    }
}

@media (max-width: 600px) {
    h1 label {
        display: block;
        user-select: none;
        cursor: pointer;
        &:before {
            content: "☰ "
        }
    }

    nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1;
        background: white;
        height: 100vh;
        overflow: hidden;
    }

    #menu_open:not(:checked) ~ nav {
        height: 48px;

        h1 ~ * {
            display: none;
        }
    }
}

form#talk {
    grid-area: talk;
    padding: 0 10px 10px 0;
    display: flex;
    gap: 10px;

    input[type="text"] {
        flex-grow: 1;
        font-size: 16px;
    }

    input {
        height: 40px;
        padding: 0 10px;
    }
}

form#signup {
    grid-area: talk;
    margin: 0 10px 10px 0;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;

    label {
        display: flex;
        align-items: center;

        input {
            flex-grow: 1;
        }
    }

    input {
        padding: 0 10px;
        height: 40px;
    }

    @media (max-width: 600px) {
        flex-direction: column;
        margin-bottom: 100px;
    }
}

#message {
    position: fixed;
    top: 80px;
    left: 10px;
    right: 10px;
    margin: auto;
    width: fit-content;
    animation: fade-out 1s forwards;
    animation-delay: 4s;
    padding: 10px;
}

@keyframes fade-out {
    100% {
        opacity: 0;
        pointer-events: none;
        transform: translate(0, -20px);
    }
}

a {
    color: inherit;
}
input, button, #message {
    background: var(--message-bg);
    color: inherit;
    border: 1px solid;
}