:root {
    --accent: #e30613;
    --accent-dark: #c0000c;
    --ink: #1a1c1c;
    --title: #050505;
    --muted: #5f5e60;
    --soft-muted: #8d7f7d;
    --page: #f9f9f9;
    --panel: #ffffff;
    --field: #f3f3f3;
    --border: #dedede;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    --strong-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--ink);
    background: var(--page);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

p,
h2,
ul {
    margin: 0;
    padding: 0;
}

ul {
    list-style: none;
}

.box {
    width: 100%;
    height: 100%;
    user-select: none;
}

.chat {
    min-height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--page);
}

.head {
    min-height: calc(88px + env(safe-area-inset-top));
    padding: calc(18px + env(safe-area-inset-top)) 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--page);
    border-bottom: 1px solid rgba(222, 222, 222, 0.7);
}

.back-button {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.back-button:active {
    background: #eeeeee;
}

.back-arrow {
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-left: 4px;
}

.name {
    min-width: 0;
}

.title {
    color: var(--title);
    font-size: 28px;
    line-height: 34px;
    font-weight: 900;
}

.subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 18px;
}

.main {
    flex: 1;
    overflow: auto;
    width: 100%;
    background:
        linear-gradient(180deg, rgba(227, 6, 19, 0.04) 0%, rgba(249, 249, 249, 0) 180px),
        var(--page);
}

.main::-webkit-scrollbar {
    width: 6px;
}

.main::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 999px;
}

.context {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 18px 16px 20px;
}

.context li {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.context .time,
.context .notice {
    justify-content: center;
}

.context .time span,
.context .notice span {
    max-width: 92%;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    color: var(--muted);
    background: #eeeeee;
}

.context .notice span {
    color: var(--accent-dark);
    background: #fff5f3;
    border: 1px solid rgba(227, 6, 19, 0.16);
    font-weight: 800;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.right {
    flex: 1;
    min-width: 0;
}

.author {
    margin: 0 4px 6px;
    color: var(--soft-muted);
    font-size: 12px;
    line-height: 16px;
}

.me {
    justify-content: flex-end;
}

.me .right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.me .author {
    text-align: right;
}

.msg {
    max-width: min(72vw, 420px);
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 21px;
    word-wrap: break-word;
    word-break: break-word;
    box-shadow: var(--shadow);
}

.other .msg {
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--border);
    border-top-left-radius: 6px;
}

.me .msg {
    color: #ffffff;
    background: var(--accent);
    border-top-right-radius: 6px;
    box-shadow: 0 8px 18px rgba(227, 6, 19, 0.18);
}

.msg.system {
    color: var(--accent-dark);
    background: #fff5f3;
}

.reply-link {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reply-link .link {
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--accent-dark);
    background: #fff5f3;
    border: 1px solid rgba(227, 6, 19, 0.14);
    font-size: 13px;
    line-height: 18px;
    cursor: pointer;
}

.picture {
    padding: 0;
    overflow: hidden;
}

.me .msg.picture,
.other .msg.picture {
    padding: 0 !important;
    color: var(--ink) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.picture img,
.msg img {
    display: block;
    max-width: min(64vw, 280px);
    max-height: 240px;
    border-radius: 12px;
    cursor: zoom-in;
}

.footer {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    background: rgba(249, 249, 249, 0.96);
    border-top: 1px solid rgba(222, 222, 222, 0.8);
    backdrop-filter: blur(12px);
}

.footer .list {
    width: min(760px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.wrap-editor {
    min-height: 46px;
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-radius: 16px;
    background: var(--field);
    border: 1px solid transparent;
}

.wrap-editor:focus-within {
    background: #ffffff;
    border-color: rgba(227, 6, 19, 0.28);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.08);
}

.editor {
    width: 100%;
    min-height: 22px;
    max-height: 88px;
    overflow-y: auto;
    outline: none;
    color: var(--ink);
    caret-color: var(--accent);
    white-space: pre-wrap;
    word-break: break-word;
}

.editor:empty::before {
    content: attr(data-placeholder);
    color: #a7a7a7;
}

.btn-choose,
.btn-submit {
    height: 46px;
    flex-shrink: 0;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(17, 17, 17, 0.08);
}

.btn-choose {
    width: 46px;
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border);
}

.btn-choose::before,
.btn-choose::after {
    content: "";
    position: absolute;
    background: var(--accent);
}

.btn-choose::before {
    width: 18px;
    height: 2px;
    top: 22px;
    left: 14px;
}

.btn-choose::after {
    width: 2px;
    height: 18px;
    top: 14px;
    left: 22px;
}

.file-image {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.btn-submit {
    min-width: 68px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--accent);
    font-weight: 900;
}

.btn-submit:active,
.btn-choose:active {
    transform: translateY(1px);
}

.message {
    position: fixed;
    z-index: 99999;
    top: calc(14px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--strong-shadow);
    font-weight: 800;
}

.image-loading-container {
    min-width: 180px;
    padding: 12px;
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.loading-text {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.progress-container {
    width: 100%;
    height: 6px;
    margin-top: 8px;
    background: #eeeeee;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: inherit;
    transition: width 0.3s ease;
}

.image-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.82);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.image-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.image-modal-content {
    max-width: 94%;
    max-height: 88%;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
    transform: scale(0.96);
    transition: transform 0.22s ease;
    cursor: zoom-out;
}

.image-modal-overlay.active .image-modal-content {
    transform: scale(1);
}

.image-modal-close {
    position: absolute;
    top: calc(18px + env(safe-area-inset-top));
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    font-size: 28px;
    line-height: 1;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--page);
}

.loading-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #eeeeee;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 820px) {
    body {
        background: #eeeeee;
    }

    .box {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 28px;
    }

    .chat {
        width: min(760px, 100%);
        min-height: 680px;
        height: min(860px, calc(100vh - 56px));
        margin: 0 auto;
        border: 1px solid var(--border);
        border-radius: 18px;
        overflow: hidden;
        box-shadow: var(--strong-shadow);
    }

    .head,
    .footer {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 380px) {
    .title {
        font-size: 24px;
        line-height: 30px;
    }

    .subtitle {
        display: none;
    }

    .footer .list {
        gap: 8px;
    }

    .btn-submit {
        min-width: 60px;
        padding: 0 14px;
    }
}
