:root {
    --orange: #f49a00;
    --orange-deep: #df8300;
    --cream: #fff1d8;
    --cream-light: #fff8ed;
    --ink: #2c231b;
    --line: #4d3b2c;
    --panel: #ffffff;
    --blue: #597f9c;
    --blue-deep: #355f80;
    --gold: #ffd84d;

    /* チャット画面用の割り当て */
    --page-bg: #f49a00;
    --panel-bg: #ffffff;
    --line-soft: #d1d1d1;
    --title-bg: var(--cream);
    --text: var(--ink);
    --muted: #6b6b6b;
    --reply-name: var(--orange-deep);
    --user-bg: #ffffff;
    --reply-bg: var(--cream-light);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: var(--orange) !important;
}

body {
    background: var(--orange) !important;
    color: var(--text);
    font-family:
        "Hiragino Sans",
        "Yu Gothic",
        Meiryo,
        sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    color: var(--blue-deep);
    text-decoration: underline;
}

button,
textarea {
    font: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*
|--------------------------------------------------------------------------
| ページ全体
|--------------------------------------------------------------------------
*/

.chat-page {
    display: grid;
    grid-template-rows:
        auto minmax(0, 1fr) auto;
    width: min(1180px, 100%);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    border-right: 3px solid var(--line);
    border-left: 3px solid var(--line);
    background: var(--panel-bg);
}

/* 上部 */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 52px;
    padding: 9px 16px;
    border-bottom: 3px solid var(--line);
    background: #ffffff;
}

.chat-site-name {
    color: #c81f2a;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: 22px;
    font-weight: 700;
    text-decoration: none;
}

.chat-site-name:hover {
    text-decoration: none;
}

.chat-navigation a {
    font-size: 13px;
    font-weight: 700;
}

/* 中央部分 */

.chat-layout {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr) 230px;
    min-height: 0;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
}

/*
|--------------------------------------------------------------------------
| チャット本体
|--------------------------------------------------------------------------
*/

.chat-main {
    display: grid;
    grid-template-rows:
        auto minmax(0, 1fr) auto auto;
    min-width: 0;
    min-height: 0;
    gap: 10px;
}

/* タイトル */

.chat-title-box {
    position: relative;
    padding: 14px 18px;
    border: 2px solid var(--line);
    background: var(--title-bg);
    text-align: center;
}

.chat-title-box::before,
.chat-title-box::after {
    position: absolute;
    top: 50%;
    width: 11%;
    height: 1px;
    background: var(--line);
    content: "";
}

.chat-title-box::before {
    left: 5%;
}

.chat-title-box::after {
    right: 5%;
}

.chat-title-box h1 {
    margin: 0;
    color: var(--ink);
    font-family:
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        Meiryo,
        sans-serif;
    font-size: 25px;
    font-weight: 900;
    letter-spacing: 0.05em;
}

.chat-title-box p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/*
|--------------------------------------------------------------------------
| 会話欄
|--------------------------------------------------------------------------
*/

.chat-board {
    min-height: 0;
    overflow-y: auto;
    border: 2px solid var(--line);
    background: #ffffff;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.chat-empty {
    display: grid;
    min-height: 100%;
    padding: 30px;
    place-items: center;
    color: #777777;
    text-align: center;
}

.chat-message {
    padding: 11px 14px 14px;
    border-bottom: 1px dotted #bcbcbc;
    text-align: left;
}

.chat-message:last-child {
    border-bottom: 0;
}

.chat-message-user {
    background: var(--user-bg);
}

.chat-message-reply {
    background: var(--reply-bg);
}

/* 投稿情報 */

.message-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px;
    color: #444444;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.message-number {
    color: #111111;
}

.reply-name-label {
    color: #444444;
}

.message-name {
    color: var(--reply-name);
    font-weight: 700;
}

.message-date {
    color: #666666;
}

/* 投稿本文 */

.message-body {
    margin-top: 6px;
    padding-left: 20px;
    color: #111111;
    font-size: 15px;
    line-height: 1.75;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/*
|--------------------------------------------------------------------------
| 入力欄
|--------------------------------------------------------------------------
*/

.post-form {
    padding: 10px;
    border: 2px solid var(--line);
    background: var(--title-bg);
}

.post-form textarea {
    display: block;
    width: 100%;
    height: 82px;
    min-height: 82px;
    max-height: 150px;
    padding: 9px 10px;
    border: 2px solid var(--line);
    background: #ffffff;
    color: #111111;
    line-height: 1.6;
    resize: vertical;
}

.post-form textarea:focus {
    border-color: var(--blue);
    outline: 2px solid rgba(89, 127, 156, 0.2);
    outline-offset: 1px;
}

.post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.character-counter {
    color: var(--muted);
    font-size: 12px;
}

.post-buttons {
    display: flex;
    gap: 8px;
}

.clear-button,
.send-button {
    min-width: 90px;
    min-height: 38px;
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.clear-button {
    border: 2px solid var(--line);
    background: #ffffff;
    color: #252525;
}

.send-button {
    border: 2px solid var(--line);
    background: var(--orange);
    color: #ffffff;
}

.clear-button:hover {
    background: #e7e7e7;
}

.send-button:hover {
    filter: brightness(0.96);
}

/* 注意書き */

.chat-note {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

/*
|--------------------------------------------------------------------------
| 広告
|--------------------------------------------------------------------------
*/

.chat-side {
    display: grid;
    grid-auto-rows: minmax(210px, auto);
    min-height: 0;
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ad-box {
    display: grid;
    min-height: 210px;
    overflow: hidden;
    border: 2px solid var(--line);
    background: #f4f4f4;
    align-content: center;
    justify-items: center;
    text-align: center;
}

.ad-box-placeholder {
    padding: 20px;
    background:
        repeating-linear-gradient(-45deg,
            #fafafa,
            #fafafa 10px,
            #eeeeee 10px,
            #eeeeee 20px);
    color: #777777;
}

.ad-box-placeholder span {
    color: #555555;
    font-size: 25px;
    font-weight: 700;
}

.ad-box small {
    display: block;
    margin-top: 5px;
    color: #777777;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: 8px;
    letter-spacing: 0.16em;
}

.ad-box-image {
    display: block;
    min-height: 0;
    padding: 7px;
    background: #ffffff;
}

.ad-box-image a {
    display: block;
}

.ad-box-image img {
    width: 100%;
    height: auto;
    max-height: 290px;
    margin: 0 auto;
    object-fit: contain;
}

/* フッター */

.chat-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 16px 10px;
    border-top: 3px solid var(--line);
    background: #ffffff;
    color: var(--muted);
    font-size: 11px;
}

/*
|--------------------------------------------------------------------------
| タブレット
|--------------------------------------------------------------------------
*/

@media (max-width: 850px) {
    .chat-layout {
        grid-template-columns: 1fr;
        grid-template-rows:
            minmax(0, 1fr) 100px;
    }

    .chat-side {
        display: flex;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .ad-box {
        flex: 0 0 220px;
        min-height: 100px;
        height: 100px;
    }

    .ad-box-image img {
        max-height: 75px;
    }
}

/*
|--------------------------------------------------------------------------
| スマートフォン
|--------------------------------------------------------------------------
*/

@media (max-width: 650px) {
    .chat-page {
        border: 0;
    }

    .chat-header {
        min-height: 46px;
        padding: 7px 10px;
    }

    .chat-site-name {
        font-size: 19px;
    }

    .chat-layout {
        gap: 7px;
        padding: 7px;
    }

    .chat-main {
        gap: 7px;
    }

    .chat-title-box {
        padding: 10px 8px;
    }

    .chat-title-box::before,
    .chat-title-box::after {
        display: none;
    }

    .chat-title-box h1 {
        font-size: 20px;
    }

    .chat-title-box p {
        font-size: 11px;
    }

    .chat-message {
        padding: 9px 8px 11px;
    }

    .message-body {
        padding-left: 9px;
        font-size: 14px;
    }

    .post-form {
        padding: 8px;
    }

    .post-form textarea {
        height: 74px;
        min-height: 74px;
    }

    .chat-note {
        display: none;
    }

    .chat-footer {
        padding: 6px 10px;
    }
}

/*
|--------------------------------------------------------------------------
| 小さいスマートフォン
|--------------------------------------------------------------------------
*/

@media (max-width: 430px) {
    .chat-header {
        display: block;
        text-align: center;
    }

    .chat-navigation {
        margin-top: 2px;
    }

    .chat-layout {
        grid-template-rows:
            minmax(0, 1fr) 84px;
    }

    .chat-title-box h1 {
        font-size: 18px;
    }

    .post-actions {
        gap: 6px;
    }

    .clear-button,
    .send-button {
        min-width: 72px;
        min-height: 36px;
        padding: 6px 10px;
    }

    .ad-box {
        flex-basis: 185px;
        height: 84px;
        min-height: 84px;
    }

    .ad-box-image img {
        max-height: 60px;
    }

    .chat-footer span {
        display: none;
    }
}