/*
 * 用户会话样式：贴近问卷页的少女心笔记本风格，移动端优先。
 * 作者: @ccfork
 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    overflow: hidden;
    background: linear-gradient(145deg, #fff5f9 0%, #ffe4ef 100%);
    color: #592e3f;
    font-family: -apple-system, "Segoe UI", "Quicksand", system-ui, "Helvetica Neue", sans-serif;
}

button,
textarea {
    font: inherit;
}

.chat-shell {
    display: flex;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    margin: 0 auto;
    flex-direction: column;
    background: #ffffffea;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px dashed #ffcfdf;
    flex-shrink: 0;
}

.watch-panel {
    flex-shrink: 0;
    margin: 0.65rem 0.75rem 0;
    padding: 7px;
    border: 1px solid #ffd1df;
    border-radius: 18px;
    background: #fff7fa;
}

.watch-panel video {
    display: block;
    width: 100%;
    max-height: min(30vh, 220px);
    border-radius: 14px;
    background: #1b1117;
}

.chat-user-info,
.chat-actions,
.composer {
    display: flex;
    align-items: center;
}

.chat-user-info {
    min-width: 0;
    gap: 10px;
}

.chat-user-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #ffeef4;
    box-shadow: inset 0 0 0 1px #ffd1df;
    font-size: 1.25rem;
}

.chat-user-details {
    min-width: 0;
}

.chat-user-details h1 {
    overflow: hidden;
    background: linear-gradient(135deg, #f7a1c1, #ff8bb0);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-user-details p {
    margin-top: 0.12rem;
    color: #bc6f8c;
    font-size: 0.72rem;
}

.chat-actions {
    gap: 7px;
}

.icon-btn,
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid #ffd1df;
    border-radius: 50%;
    color: #b35573;
    background: #fff7fa;
    cursor: pointer;
}

.messages-container {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding: 0.9rem 0.9rem 1rem;
}

.message-group {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px;
    width: min(88%, 460px);
    scroll-margin: 80px;
    -webkit-touch-callout: none;
    user-select: none;
}

.message-group.user {
    grid-template-columns: minmax(0, 1fr) auto;
    align-self: flex-end;
}

.message-group.admin {
    align-self: flex-start;
}

.message-avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-top: 4px;
    border-radius: 50%;
    color: #fff;
    background: #ffb7cb;
    font-size: 0.78rem;
}

.message-group.user .message-avatar {
    grid-column: 2;
    background: #ff8aac;
}

.message-body {
    min-width: 0;
}

.message-group.user .message-body {
    grid-column: 1;
    grid-row: 1;
}

.message-bubble {
    width: fit-content;
    max-width: 100%;
    padding: 9px 13px;
    border: 1px solid #ffd1df;
    border-radius: 20px 20px 20px 6px;
    background: #fff;
    box-shadow: 0 4px 12px #ffdae7;
    color: #673f50;
    font-size: 0.88rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.message-text {
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-group.user .message-bubble {
    margin-left: auto;
    border-color: #ff8aac;
    border-radius: 20px 20px 6px 20px;
    background: #ff8aac;
    color: #fff;
}

.message-time {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    color: #e9a3bd;
    font-size: 0.64rem;
}

.message-group.user .message-time {
    justify-content: flex-end;
    text-align: right;
}

.recalled-bubble {
    color: #b9748d;
    background: #fff7fa;
    border-style: dashed;
}

.message-recall-label {
    color: #bc6f8c;
    font-weight: 800;
}

.message-group.user .message-bubble.has-sticker {
    background: #fff;
}

.image-bubble,
.message-group.user .image-bubble {
    padding: 6px;
    background: #fff;
}

.message-image {
    display: block;
    max-width: min(240px, 62vw);
    max-height: 260px;
    border-radius: 14px;
    object-fit: contain;
    cursor: zoom-in;
}

.message-reply-block {
    display: block;
    width: auto;
    max-width: min(210px, 62vw);
    margin: 0 0 5px;
    padding: 5px 8px;
    border: 0;
    border-left: 2px solid #ff8aac;
    border-radius: 10px;
    color: #7a5364;
    background: #fff1f6;
    text-align: left;
    cursor: pointer;
    line-height: 1.25;
}

.message-group.user .message-reply-block {
    border-left-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.22);
}

.image-bubble .message-reply-block {
    color: #7a5364;
    background: #fff1f6;
}

.message-reply-sender {
    display: block;
    color: #b35573;
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1.2;
}

.message-group.user .message-reply-sender {
    color: #fff;
}

.image-bubble .message-reply-sender {
    color: #b35573;
}

.message-reply-preview {
    display: block;
    overflow: hidden;
    color: inherit;
    font-size: 0.72rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-highlight .message-bubble {
    box-shadow: 0 0 0 3px rgba(255, 138, 172, 0.28);
    transform: translateY(-1px);
}

.empty-state,
.state-block {
    display: grid;
    place-items: center;
    gap: 8px;
    color: #c26483;
    font-size: 0.78rem;
    text-align: center;
}

.empty-state {
    min-height: 100%;
    align-content: center;
}

.empty-state i {
    margin-bottom: 4px;
    color: #ffb7cb;
    font-size: 2.4rem;
}

.empty-state strong {
    color: #b35573;
    font-size: 0.94rem;
}

.input-area {
    flex-shrink: 0;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom));
    border-top: 1px dashed #ffcfdf;
    background: #ffffffea;
}

.composer {
    gap: 8px;
}

.hidden-file-input {
    display: none;
}

.upload-progress {
    display: grid;
    gap: 5px;
    margin-bottom: 8px;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress-bar {
    overflow: hidden;
    height: 7px;
    border-radius: 999px;
    background: #ffe2ec;
}

.upload-progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #ff8aac;
    transition: width 0.18s ease;
}

.upload-progress p {
    color: #bc6f8c;
    font-size: 0.72rem;
    font-weight: 800;
}

.reply-draft {
    display: grid;
    grid-template-columns: 4px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
    padding: 9px 10px;
    border: 1px solid #ffd1df;
    border-radius: 16px;
    background: #fff7fa;
}

.reply-draft-mark {
    width: 4px;
    height: 34px;
    border-radius: 999px;
    background: #ff8aac;
}

.reply-draft-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.reply-draft-main strong {
    color: #b35573;
    font-size: 0.76rem;
}

.reply-draft-main span {
    overflow: hidden;
    color: #7a5364;
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-draft-close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    color: #b35573;
    background: #ffe2ec;
    cursor: pointer;
}

.message-input {
    flex: 1;
    min-height: 44px;
    max-height: 128px;
    resize: none;
    border: 1.5px solid #ffc1d4;
    border-radius: 22px;
    outline: 0;
    padding: 10px 13px;
    background: #fef6f9;
    color: #673f50;
    font-size: 0.88rem;
    line-height: 1.5;
}

.message-input:focus {
    border-color: #ff8aac;
    background: #fff;
}

.send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: #ff8aac;
    box-shadow: 0 2px 4px #ffbbd1;
    cursor: pointer;
}

.send-btn:active,
.icon-btn:active,
.tool-btn:active {
    transform: scale(0.96);
}

.send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 40;
    max-width: min(360px, calc(100vw - 32px));
    padding: 9px 12px;
    border-radius: 18px;
    color: #fff;
    background: rgba(179, 85, 115, 0.94);
    box-shadow: 0 8px 18px rgba(241, 147, 177, 0.28);
    font-size: 0.78rem;
}

.message-action-menu {
    position: fixed;
    z-index: 100;
    min-width: 112px;
    padding: 6px;
    border: 1px solid #ffd1df;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(241, 147, 177, 0.28);
}

.message-action-menu button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 9px 12px;
    color: #b35573;
    background: #fff7fa;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #ffc1d4;
}

@media (min-width: 600px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-shell {
        height: min(780px, calc(100vh - 2rem));
        border-radius: 32px;
        box-shadow: 0 20px 35px rgba(241, 147, 177, 0.2);
        overflow: hidden;
    }

}
