/* Fanxing AI — premium conversation surface
   Scoped to chat mode so image/video result layouts keep their own styling. */

body.chat-shell.workspace-mode-chat {
    --msg-accent: #8171ff;
    --msg-accent-cool: #56a5e9;
    --msg-text: rgba(247, 246, 252, 0.94);
    --msg-muted: rgba(209, 207, 224, 0.5);
    --msg-panel: rgba(17, 18, 25, 0.78);
    --msg-panel-strong: rgba(22, 23, 32, 0.91);
    --msg-border: rgba(255, 255, 255, 0.075);
}

body.chat-shell.workspace-mode-chat .messages-container:not(:has(.model-info-screen)) {
    width: min(100%, 840px);
    max-width: 840px;
    padding: 76px 18px 148px;
}

body.chat-shell.workspace-mode-chat .messages-container > .message + .message {
    margin-top: 14px;
}

body.chat-shell.workspace-mode-chat .message {
    width: 100%;
    gap: 10px;
    padding: 4px 0;
    background: transparent;
}

body.chat-shell.workspace-mode-chat .message.assistant {
    padding-right: 5%;
}

body.chat-shell.workspace-mode-chat .message.user {
    padding-left: 19%;
}

body.chat-shell.workspace-mode-chat .message-avatar,
body.chat-shell.workspace-mode-chat .user-avatar {
    width: 32px;
    height: 32px;
    margin-top: 3px;
    border-radius: 10px;
}

body.chat-shell.workspace-mode-chat .message.assistant .message-avatar {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(148, 134, 255, 0.2);
    background:
        radial-gradient(circle at 25% 18%, rgba(132, 117, 255, 0.2), transparent 48%),
        linear-gradient(145deg, rgba(24, 25, 36, 0.96), rgba(10, 11, 17, 0.94));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.055),
        0 7px 18px rgba(0, 0, 0, 0.23);
}

body.chat-shell.workspace-mode-chat .message.assistant .message-avatar::after {
    content: "";
    position: absolute;
    inset: auto 5px 3px;
    height: 1px;
    border-radius: 99px;
    background: linear-gradient(90deg, transparent, rgba(93, 168, 234, 0.8), transparent);
}

body.chat-shell.workspace-mode-chat .message.assistant .msg-avatar-img {
    width: 19px;
    height: 19px;
}

body.chat-shell.workspace-mode-chat .message.user .message-avatar,
body.chat-shell.workspace-mode-chat .message.user .user-avatar {
    border: 1px solid rgba(170, 160, 255, 0.34);
    color: #fbfaff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    background:
        linear-gradient(145deg, rgba(132, 115, 255, 0.96), rgba(82, 91, 197, 0.96));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.23),
        0 7px 17px rgba(73, 63, 174, 0.25);
}

body.chat-shell.workspace-mode-chat .message-body,
body.chat-shell.workspace-mode-chat .message.assistant .message-body:has(.message-bubble),
body.chat-shell.workspace-mode-chat .message.user .message-body:has(.message-bubble) {
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    gap: 0;
}

body.chat-shell.workspace-mode-chat .message.assistant .message-body {
    flex: 1 1 auto;
    width: auto;
    max-width: 748px;
}

body.chat-shell.workspace-mode-chat .message.user .message-body {
    flex: 0 1 auto;
    width: auto;
    max-width: min(620px, 100%);
}

body.chat-shell.workspace-mode-chat .message-bubble {
    min-width: 0;
}

body.chat-shell.workspace-mode-chat .message.assistant .message-bubble {
    position: relative;
    padding: 15px 17px 14px;
    overflow: visible;
    border: 1px solid var(--msg-border);
    border-radius: 15px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 40%),
        linear-gradient(180deg, var(--msg-panel-strong), var(--msg-panel));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.035),
        0 10px 28px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

body.chat-shell.workspace-mode-chat .message.assistant .message-bubble::before {
    content: "";
    position: absolute;
    top: 13px;
    bottom: 13px;
    left: -1px;
    width: 2px;
    border-radius: 0 99px 99px 0;
    background: linear-gradient(180deg, var(--msg-accent), var(--msg-accent-cool));
    box-shadow: 0 0 12px rgba(112, 101, 238, 0.26);
    opacity: 0.78;
}

body.chat-shell.workspace-mode-chat .message.user .message-bubble {
    align-items: flex-end;
}

body.chat-shell.workspace-mode-chat .message.user .message-content,
body.chat-shell.workspace-mode-chat .message.user .message-images + .message-content,
body.chat-shell.workspace-mode-chat .message.user .message-files + .message-content {
    width: fit-content;
    max-width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(145, 132, 255, 0.2);
    border-radius: 14px 14px 4px 14px;
    color: rgba(250, 249, 255, 0.95);
    background:
        linear-gradient(135deg, rgba(105, 91, 207, 0.34), rgba(64, 75, 137, 0.28)),
        rgba(22, 22, 31, 0.8);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 8px 22px rgba(0, 0, 0, 0.13);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

body.chat-shell.workspace-mode-chat .message-content {
    color: var(--msg-text);
    font-size: 14px;
    line-height: 1.72;
    letter-spacing: 0.005em;
}

body.chat-shell.workspace-mode-chat .message-content > :first-child {
    margin-top: 0;
}

body.chat-shell.workspace-mode-chat .message-content > :last-child {
    margin-bottom: 0;
}

body.chat-shell.workspace-mode-chat .message-content p {
    margin: 0 0 10px;
}

body.chat-shell.workspace-mode-chat .message-content h1,
body.chat-shell.workspace-mode-chat .message-content h2,
body.chat-shell.workspace-mode-chat .message-content h3 {
    color: rgba(252, 251, 255, 0.98);
    letter-spacing: -0.018em;
}

body.chat-shell.workspace-mode-chat .message-footer {
    min-height: 25px;
    gap: 8px;
    padding: 5px 3px 0;
    opacity: 0.62;
    transition: opacity 0.18s ease;
}

body.chat-shell.workspace-mode-chat .message:hover .message-footer,
body.chat-shell.workspace-mode-chat .message:focus-within .message-footer {
    opacity: 1;
}

body.chat-shell.workspace-mode-chat .message.user .message-footer {
    justify-content: flex-end;
}

body.chat-shell.workspace-mode-chat .message-footer .message-actions {
    gap: 2px;
}

body.chat-shell.workspace-mode-chat .message-footer .msg-action-btn {
    min-width: 0;
    height: 25px;
    padding: 0 7px;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: rgba(211, 208, 226, 0.62);
    font-size: 11px;
    background: transparent;
    box-shadow: none;
}

body.chat-shell.workspace-mode-chat .message-footer .msg-action-btn svg {
    width: 12px;
    height: 12px;
}

body.chat-shell.workspace-mode-chat .message-footer .msg-action-btn:hover {
    border-color: rgba(142, 128, 246, 0.16);
    color: rgba(240, 237, 255, 0.9);
    background: rgba(126, 110, 232, 0.09);
    transform: none;
}

body.chat-shell.workspace-mode-chat .message-footer .message-time,
body.chat-shell.workspace-mode-chat .message-footer .message-billing {
    color: var(--msg-muted);
    font-size: 10px;
}

body.chat-shell.workspace-mode-chat .thinking-section {
    margin: 0 0 12px;
    padding: 0 0 0 12px;
    border-left: 1px solid rgba(131, 115, 255, 0.42);
    background: transparent;
}

body.chat-shell.workspace-mode-chat .thinking-header {
    min-height: 28px;
    padding: 0 3px;
    border-radius: 7px;
}

body.chat-shell.workspace-mode-chat .thinking-chip {
    color: rgba(148, 136, 255, 0.88);
}

body.chat-shell.workspace-mode-chat .thinking-status,
body.chat-shell.workspace-mode-chat .thinking-toggle {
    color: var(--msg-muted);
}

body.chat-shell.workspace-mode-chat .thinking-content-inner {
    border-left-color: rgba(124, 107, 225, 0.12);
    color: rgba(220, 217, 233, 0.62);
    background: rgba(255, 255, 255, 0.018);
}

/* Light mode keeps the same hierarchy without the black-card feeling. */
body.chat-shell.theme-light.workspace-mode-chat {
    --msg-text: rgba(30, 28, 43, 0.92);
    --msg-muted: rgba(71, 67, 91, 0.46);
    --msg-panel: rgba(255, 255, 255, 0.64);
    --msg-panel-strong: rgba(255, 255, 255, 0.86);
    --msg-border: rgba(61, 55, 91, 0.09);
}

body.chat-shell.theme-light.workspace-mode-chat .message.assistant .message-avatar {
    border-color: rgba(106, 88, 220, 0.16);
    background:
        radial-gradient(circle at 24% 18%, rgba(125, 107, 242, 0.13), transparent 50%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(242, 241, 250, 0.94));
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 7px 18px rgba(59, 47, 115, 0.1);
}

body.chat-shell.theme-light.workspace-mode-chat .message.assistant .msg-avatar-img.is-openai-white {
    filter: none;
}

body.chat-shell.theme-light.workspace-mode-chat .message.assistant .message-bubble {
    border-color: var(--msg-border);
    background:
        linear-gradient(145deg, rgba(125, 107, 242, 0.025), transparent 42%),
        linear-gradient(180deg, var(--msg-panel-strong), var(--msg-panel));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.84),
        0 10px 30px rgba(50, 43, 84, 0.055);
}

body.chat-shell.theme-light.workspace-mode-chat .message.user .message-content,
body.chat-shell.theme-light.workspace-mode-chat .message.user .message-images + .message-content,
body.chat-shell.theme-light.workspace-mode-chat .message.user .message-files + .message-content {
    border-color: rgba(101, 81, 218, 0.16);
    color: rgba(34, 29, 65, 0.94);
    background:
        linear-gradient(135deg, rgba(113, 91, 226, 0.115), rgba(82, 136, 209, 0.075)),
        rgba(255, 255, 255, 0.74);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 8px 22px rgba(58, 47, 118, 0.065);
}

body.chat-shell.theme-light.workspace-mode-chat .message-content h1,
body.chat-shell.theme-light.workspace-mode-chat .message-content h2,
body.chat-shell.theme-light.workspace-mode-chat .message-content h3 {
    color: rgba(27, 24, 42, 0.98);
}

body.chat-shell.theme-light.workspace-mode-chat .message-footer .msg-action-btn {
    color: rgba(65, 60, 86, 0.56);
}

body.chat-shell.theme-light.workspace-mode-chat .message-footer .msg-action-btn:hover {
    border-color: rgba(105, 85, 219, 0.12);
    color: rgba(72, 54, 170, 0.9);
    background: rgba(107, 88, 220, 0.06);
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-content-inner {
    color: rgba(55, 50, 76, 0.6);
    background: rgba(95, 79, 190, 0.025);
}

@media (max-width: 780px) {
    body.chat-shell.workspace-mode-chat .messages-container:not(:has(.model-info-screen)) {
        padding-right: 12px;
        padding-left: 12px;
    }

    body.chat-shell.workspace-mode-chat .message.assistant {
        padding-right: 0;
    }

    body.chat-shell.workspace-mode-chat .message.user {
        padding-left: 10%;
    }

    body.chat-shell.workspace-mode-chat .message-avatar,
    body.chat-shell.workspace-mode-chat .user-avatar {
        width: 29px;
        height: 29px;
        border-radius: 9px;
    }

    body.chat-shell.workspace-mode-chat .message.assistant .message-bubble {
        padding: 13px 14px 12px;
    }

    body.chat-shell.workspace-mode-chat .message-content {
        font-size: 13.5px;
    }
}

@media (hover: none) {
    body.chat-shell.workspace-mode-chat .message-footer {
        opacity: 0.78;
    }
}
