* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: #f4f6fb;
    color: #222;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-card {
    width: 100%;
    max-width: 820px;
    height: 88vh;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 20px 22px 14px;
    border-bottom: 1px solid #e8ebf2;
    background: #ffffff;
    flex-shrink: 0;
}

.chat-header h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
}

.sub {
    margin: 6px 0 0;
    color: #666;
    font-size: 14px;
}

.chat-toolbar {
    padding: 14px 20px;
    border-bottom: 1px solid #e8ebf2;
    background: #fafbff;
    flex-shrink: 0;
}

.input-box {
    display: flex;
    gap: 12px;
}

.input-box input {
    flex: 1;
    min-width: 0;
    height: 50px;
    padding: 0 16px;
    border: 1px solid #d9deea;
    border-radius: 12px;
    font-size: 16px;
    line-height: 50px;
    outline: none;
    background: #fff;
    color: #222;
}

.input-box input::placeholder {
    color: #999;
}

.input-box input:focus {
    border-color: #2d6cdf;
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}

.input-box button {
    min-width: 160px;
    height: 50px;
    padding: 0 18px;
    border: none;
    border-radius: 12px;
    background: #2d6cdf;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.08s ease, opacity 0.15s ease;
}

.input-box button:hover {
    opacity: 0.96;
}

.input-box button:active {
    transform: scale(0.98);
}

.input-box button:disabled {
    background: #7f9edb;
    cursor: not-allowed;
    opacity: 0.95;
}

.chat-room {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    background: #f7f9fd;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.empty-state {
    margin: auto;
    text-align: center;
    color: #888;
    font-size: 15px;
}

.message {
    max-width: 78%;
    padding: 12px 14px;
    border-radius: 16px;
    line-height: 1.55;
    word-break: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.message .meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.message .text {
    font-size: 14px;
}

.message.participant_a {
    align-self: flex-start;
    background: #eaf2ff;
    border-top-left-radius: 6px;
}

.message.participant_b {
    align-self: flex-end;
    background: #fff1eb;
    border-top-right-radius: 6px;
}

.message.moderator {
    align-self: center;
    max-width: 88%;
    background: #eef8ee;
}

/* 사람 메시지용 */
.message.user {
    align-self: flex-end;
    background: #2d6cdf;
    color: #fff;
    border-top-right-radius: 6px;
}

.message.user .meta {
    color: rgba(255, 255, 255, 0.82);
}

/* 하단 채팅 입력바 */
.chat-input-bar {
    border-top: 1px solid #e8ebf2;
    background: #ffffff;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-wrap input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 16px;
    border: 1px solid #d9deea;
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    background: #f9fbff;
    color: #222;
}

.chat-input-wrap input::placeholder {
    color: #999;
}

.chat-input-wrap input:focus {
    border-color: #2d6cdf;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.15);
}

.chat-input-wrap button {
    flex-shrink: 0;
    min-width: 82px;
    height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: 24px;
    background: #2d6cdf;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.08s ease, opacity 0.15s ease;
}

.chat-input-wrap button:hover {
    opacity: 0.96;
}

.chat-input-wrap button:active {
    transform: scale(0.98);
}

.chat-input-wrap button:disabled {
    background: #7f9edb;
    cursor: not-allowed;
    opacity: 0.95;
}

/* 태블릿 */
@media (max-width: 900px) {
    .app-shell {
        padding: 12px;
    }

    .chat-card {
        max-width: 100%;
        height: 92vh;
    }

    .input-box button {
        min-width: 140px;
    }
}

/* 모바일 */
@media (max-width: 768px) {
    .app-shell {
        padding: 0;
        align-items: stretch;
    }

    .chat-card {
        max-width: 100%;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-header {
        padding: 16px;
    }

    .chat-header h1 {
        font-size: 22px;
    }

    .sub {
        font-size: 13px;
    }

    .chat-toolbar {
        padding: 12px 14px;
    }

    .input-box {
        flex-direction: column;
        gap: 10px;
    }

    .input-box input {
        width: 100%;
        height: 60px;
        padding: 0 18px;
        font-size: 18px;
        line-height: 60px;
        border-radius: 16px;
    }

    .input-box button {
        width: 100%;
        min-width: 100%;
        height: 60px;
        padding: 0 18px;
        font-size: 17px;
        border-radius: 16px;
    }

    .chat-room {
        padding: 14px;
        gap: 10px;
    }

    .message {
        max-width: 92%;
        padding: 12px 13px;
    }

    .message .meta {
        font-size: 11px;
    }

    .message .text {
        font-size: 14px;
    }

    .chat-input-bar {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .chat-input-wrap {
        gap: 8px;
    }

    .chat-input-wrap input {
        height: 52px;
        font-size: 16px;
        border-radius: 26px;
        padding: 0 16px;
    }

    .chat-input-wrap button {
        min-width: 74px;
        height: 52px;
        padding: 0 16px;
        font-size: 15px;
        border-radius: 26px;
    }
}

/* 작은 모바일 */
@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 20px;
    }

    .sub {
        font-size: 12px;
    }

    .input-box input {
        height: 62px;
        padding: 0 18px;
        font-size: 18px;
        line-height: 62px;
    }

    .input-box button {
        height: 58px;
        font-size: 16px;
    }

    .message {
        max-width: 95%;
    }

    .chat-input-wrap input {
        height: 50px;
        font-size: 15px;
    }

    .chat-input-wrap button {
        min-width: 70px;
        height: 50px;
        font-size: 14px;
    }
}