.forum-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.chat-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: 0;
    background: #0a0a0a;
    border-top: 1px solid #1a1a1a;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.chat-msg {
    border-radius: 12px;
    border: 1px solid #1a1a1a;
    background: #0f0f0f;
    padding: 14px 16px;
}

.chat-msg-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.chat-nick {
    font-size: 14px;
    font-weight: 600;
    color: #86efac;
}

.chat-time {
    font-size: 11px;
    color: #525252;
}

.chat-text {
    font-size: 15px;
    line-height: 1.5;
    color: #e5e5e5;
    word-break: break-word;
}

.chat-text.md {
    white-space: normal;
}

.chat-text.md p {
    margin: 0 0 0.45em;
}

.chat-text.md p:last-child {
    margin-bottom: 0;
}

.chat-text.md strong { color: #fafafa; font-weight: 600; }
.chat-text.md em { color: #d4d4d4; font-style: italic; }

.chat-text.md code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.9em;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 0.1em 0.35em;
}

.chat-text.md pre {
    margin: 0.5em 0;
    padding: 10px 12px;
    background: #141414;
    border: 1px solid #262626;
    border-radius: 8px;
    overflow-x: auto;
}

.chat-text.md pre code {
    border: none;
    padding: 0;
    background: none;
}

.chat-text.md ul,
.chat-text.md ol {
    margin: 0.35em 0;
    padding-left: 1.4em;
}

.chat-text.md blockquote {
    margin: 0.35em 0;
    padding-left: 12px;
    border-left: 3px solid #404040;
    color: #a3a3a3;
}

.chat-text.md h1,
.chat-text.md h2,
.chat-text.md h3 {
    margin: 0.4em 0 0.25em;
    font-size: 1em;
    font-weight: 600;
    color: #fafafa;
}

.chat-reactions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #1a1a1a;
}

.reaction-picker {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.chat-msg:hover .reaction-picker,
.chat-msg:focus-within .reaction-picker {
    opacity: 1;
}

.reaction-chip,
.reaction-add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #2a2a2a;
    background: #141414;
    color: #e5e5e5;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}

.reaction-chip:hover,
.reaction-add:hover {
    border-color: #525252;
    background: #1a1a1a;
}

.reaction-chip.mine {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}

.reaction-count {
    font-size: 12px;
    color: #a3a3a3;
    min-width: 0.75em;
}

.reaction-add {
    padding: 4px 6px;
    font-size: 15px;
    opacity: 0.7;
}

.reaction-add:hover {
    opacity: 1;
}

.chat-hint {
    margin: 0;
    font-size: 11px;
    color: #525252;
    line-height: 1.4;
}

.chat-form {
    flex-shrink: 0;
    border-top: 1px solid #1a1a1a;
    padding: 14px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #080808;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.chat-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    min-width: 0;
    max-width: 200px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    background: #141414;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: #404040;
}

.chat-textarea {
    width: 100%;
    min-height: 56px;
    max-height: 160px;
    resize: vertical;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    background: #141414;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.chat-textarea:focus {
    outline: none;
    border-color: #404040;
}

.chat-send {
    padding: 10px 22px;
    border-radius: 10px;
    border: none;
    background: #fff;
    color: #000;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-send:hover { background: #e5e5e5; }
.chat-send:disabled { opacity: 0.5; cursor: wait; }

.chat-error {
    flex-shrink: 0;
    font-size: 13px;
    color: #fde68a;
    padding: 10px 20px 0;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

@media (min-width: 901px) {
    .chat-messages,
    .chat-form,
    .chat-error {
        max-width: min(1100px, 92vw);
    }
}

/* —— Mobile —— */
@media (max-width: 767px) {
    html.forum-page-root,
    body.forum-page {
        height: 100%;
        height: 100dvh;
    }

    body.forum-page {
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    }

    body.forum-page.has-bottom-nav {
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    }

    .forum-header-inner {
        padding: 8px 12px !important;
    }

    .forum-header-inner .forum-title-sub {
        display: none;
    }

    .chat-messages {
        padding: 10px 12px 12px;
        gap: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .chat-msg {
        padding: 12px;
        border-radius: 10px;
    }

    .chat-msg-head {
        flex-wrap: wrap;
        gap: 4px 8px;
    }

    .chat-nick {
        font-size: 13px;
        max-width: 55%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-time {
        font-size: 10px;
        flex-shrink: 0;
        margin-left: auto;
    }

    .chat-text {
        font-size: 14px;
    }

    .chat-form {
        padding: 10px 12px 10px;
        gap: 8px;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.3);
    }

    body.forum-page.keyboard-open {
        padding-bottom: 0;
    }

    body.forum-page.keyboard-open .site-nav-bottom {
        display: none;
    }

    .chat-form-row {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .chat-input {
        flex: 1;
        max-width: none;
        min-height: 44px;
        font-size: 16px;
    }

    .chat-send {
        min-height: 44px;
        min-width: 72px;
        padding: 10px 16px;
        font-size: 15px;
    }

    .chat-textarea {
        min-height: 48px;
        max-height: 120px;
        font-size: 16px;
        padding: 10px 12px;
    }

    .chat-hint {
        display: none;
    }

    .reaction-picker {
        opacity: 1;
    }

    .reaction-chip,
    .reaction-add {
        min-height: 36px;
        min-width: 36px;
        padding: 6px 10px;
        justify-content: center;
    }

    .reaction-add {
        font-size: 16px;
    }

    .chat-error {
        padding: 8px 12px 0;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .chat-send {
        min-width: 64px;
        padding: 10px 12px;
    }
}

/* Dotyk: reakcje zawsze widoczne */
@media (hover: none), (pointer: coarse) {
    .reaction-picker {
        opacity: 1;
    }
}
