/* Fanxing AI — clean commercial conversation layout.
   Loaded after the legacy skin and scoped to language-model chat only. */

body.chat-shell.workspace-mode-chat {
    --msg-accent: #6ea4ff;
    --msg-text: rgba(244, 247, 252, 0.94);
    --msg-muted: rgba(187, 197, 212, 0.55);
    --msg-user-bg: #172238;
    --msg-user-border: rgba(102, 151, 236, 0.22);
    --msg-card-bg: #11151d;
    --msg-card-border: rgba(255, 255, 255, 0.085);
    --msg-card-shadow: 0 14px 34px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

body.chat-shell.workspace-mode-chat .messages-container:not(:has(.model-info-screen)) {
    box-sizing: border-box;
    width: min(100%, 1220px);
    max-width: 1220px;
    padding: 72px 22px 150px;
}

/* Match the image/video composer width without increasing its height. */
body.chat-shell.workspace-mode-chat .input-container {
    width: min(1160px, calc(100% - 44px));
    max-width: 1160px;
}

body.chat-shell.workspace-mode-chat .chat-input-box {
    width: 100%;
    max-width: 1160px;
}

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

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

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

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

/* One quiet model mark is enough; the user bubble does not need a second badge. */
body.chat-shell.workspace-mode-chat .message.assistant .message-avatar {
    width: 30px;
    height: 30px;
    margin-top: 9px;
    overflow: visible;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

body.chat-shell.workspace-mode-chat .message.assistant .message-avatar::after {
    content: none;
}

body.chat-shell.workspace-mode-chat .message.assistant .msg-avatar-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(90, 148, 255, 0.26));
}

body.chat-shell.workspace-mode-chat .message.user > .message-avatar {
    display: none;
}

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) {
    position: relative;
    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: 1080px;
}

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

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

/* Assistant replies use one restrained surface to create hierarchy. */
body.chat-shell.workspace-mode-chat .message.assistant .message-bubble {
    position: relative;
    padding: 17px 19px 18px;
    overflow: hidden;
    border: 1px solid var(--msg-card-border);
    border-radius: 14px;
    background: var(--msg-card-bg);
    box-shadow: var(--msg-card-shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.chat-shell.workspace-mode-chat .message.assistant .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    right: 18px;
    left: 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(111, 166, 255, 0.22), transparent);
    pointer-events: none;
}

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 var(--msg-user-border);
    border-radius: 13px 13px 4px 13px;
    color: rgba(250, 249, 255, 0.96);
    background: var(--msg-user-bg);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.035);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

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

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 11px; }

body.chat-shell.workspace-mode-chat .message-content ul,
body.chat-shell.workspace-mode-chat .message-content ol {
    margin: 7px 0 10px;
    padding-left: 20px;
}

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

/* The small markdown formatter can leave blank <br> tags between list items. */
body.chat-shell.workspace-mode-chat .message-content ul > br,
body.chat-shell.workspace-mode-chat .message-content ol > br {
    display: none;
}

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.015em;
}

/* Utilities stay quiet until the current answer is hovered or focused. */
body.chat-shell.workspace-mode-chat .message-footer {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 2;
    min-height: 22px;
    gap: 7px;
    padding: 5px 2px 0;
    opacity: 0.66;
    transition: opacity 0.16s ease;
}

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

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: 1px; }

body.chat-shell.workspace-mode-chat .message.user .message-footer {
    right: 0;
    left: auto;
    width: max-content;
    min-width: max-content;
    white-space: nowrap;
}

body.chat-shell.workspace-mode-chat .message.user .message-footer .message-actions,
body.chat-shell.workspace-mode-chat .message.user .message-footer .msg-action-btn,
body.chat-shell.workspace-mode-chat .message.user .message-footer .message-time {
    flex: 0 0 auto;
    white-space: nowrap;
}

body.chat-shell.workspace-mode-chat .message-footer .msg-action-btn {
    min-width: 0;
    height: 24px;
    padding: 0 6px;
    gap: 4px;
    border: 0;
    border-radius: 6px;
    color: rgba(211, 208, 226, 0.58);
    font-size: 10.5px;
    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: 0;
    color: rgba(242, 240, 255, 0.92);
    background: rgba(255, 255, 255, 0.055);
    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 .message-completion-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    order: 3;
    flex: 0 0 auto;
    margin-left: 8px;
    min-height: 20px;
    padding: 0 7px;
    border: 1px solid rgba(57, 205, 139, 0.2);
    border-radius: 999px;
    color: #78dca8;
    background: rgba(33, 157, 101, 0.12);
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
}

body.chat-shell.workspace-mode-chat .message-completion-status::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(57, 205, 139, 0.1);
}

body.chat-shell.workspace-mode-chat .message-footer:has(.message-completion-status) {
    opacity: 0.88;
}

body.chat-shell.workspace-mode-chat .message-footer .message-time {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
}

/* Reasoning is supporting information, not another nested panel. */
body.chat-shell.workspace-mode-chat .thinking-section {
    margin: 0 0 12px;
    padding: 0;
    border: 0;
    background: transparent;
}

body.chat-shell.workspace-mode-chat .thinking-header {
    width: fit-content;
    min-height: 29px;
    padding: 0 10px;
    border: 1px solid rgba(225, 171, 49, 0.34);
    border-radius: 999px;
    background: rgba(170, 117, 20, 0.13);
}

body.chat-shell.workspace-mode-chat .thinking-header:hover {
    border-color: rgba(242, 191, 69, 0.52);
    background: rgba(185, 128, 20, 0.2);
}

body.chat-shell.workspace-mode-chat .thinking-chip {
    color: #f5c65b;
    font-size: 11px;
    font-weight: 650;
}

body.chat-shell.workspace-mode-chat .thinking-status,
body.chat-shell.workspace-mode-chat .thinking-toggle {
    color: rgba(231, 222, 196, 0.68);
    font-size: 10px;
}

body.chat-shell.workspace-mode-chat .thinking-status:empty {
    display: none;
}

body.chat-shell.workspace-mode-chat .thinking-toggle {
    margin-left: 2px;
}

body.chat-shell.workspace-mode-chat .thinking-content-inner {
    margin-top: 7px;
    padding: 8px 10px;
    border: 0;
    border-left: 1px solid rgba(112, 164, 255, 0.22);
    border-radius: 0;
    color: rgba(220, 217, 233, 0.6);
    background: transparent;
}

/* Light mode keeps the same hierarchy. */
body.chat-shell.theme-light.workspace-mode-chat {
    --msg-text: rgba(31, 29, 42, 0.92);
    --msg-muted: rgba(69, 65, 88, 0.46);
    --msg-user-bg: rgba(112, 94, 213, 0.09);
    --msg-user-border: rgba(103, 84, 210, 0.13);
    --msg-card-bg: #ffffff;
    --msg-card-border: rgba(43, 49, 67, 0.105);
    --msg-card-shadow: 0 12px 30px rgba(35, 43, 66, 0.075), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

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: 1px solid var(--msg-card-border) !important;
    background: var(--msg-card-bg) !important;
    box-shadow: var(--msg-card-shadow) !important;
}

body.chat-shell.theme-light.workspace-mode-chat .message.assistant .message-bubble::before {
    background: linear-gradient(90deg, transparent, rgba(101, 86, 205, 0.16), transparent);
}

body.chat-shell.theme-light.workspace-mode-chat .message.assistant .msg-avatar-img {
    filter: drop-shadow(0 0 7px rgba(91, 76, 196, 0.16));
}

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 {
    color: rgba(34, 29, 62, 0.94);
    background: var(--msg-user-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

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(66, 61, 85, 0.54); }

body.chat-shell.theme-light.workspace-mode-chat .message-footer .msg-action-btn:hover {
    color: rgba(70, 52, 165, 0.9);
    background: rgba(102, 83, 208, 0.065);
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-header {
    border-color: rgba(170, 117, 20, 0.28);
    background: rgba(224, 166, 45, 0.1);
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-header:hover {
    border-color: rgba(170, 117, 20, 0.45);
    background: rgba(224, 166, 45, 0.16);
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-content-inner {
    color: rgba(55, 50, 76, 0.58);
    border-left-color: rgba(102, 83, 208, 0.16);
}

/* Light chat code blocks need separation from the white page without becoming heavy. */
body.chat-shell.theme-light.workspace-mode-chat .code-block {
    overflow: hidden;
    border: 1px solid rgba(48, 53, 67, 0.14);
    border-radius: 12px;
    background: #eef1f5;
    box-shadow: 0 8px 22px rgba(34, 39, 56, 0.075);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.chat-shell.theme-light.workspace-mode-chat .code-header {
    border-bottom: 1px solid rgba(48, 53, 67, 0.12);
    background: #e4e8ed;
}

body.chat-shell.theme-light.workspace-mode-chat .code-block pre {
    background: #f1f3f6;
}

body.chat-shell.theme-light.workspace-mode-chat .code-block code {
    color: #252936;
}

body.chat-shell.theme-light.workspace-mode-chat .code-lang {
    color: #626978;
    font-weight: 600;
}

body.chat-shell.theme-light.workspace-mode-chat .code-copy-btn {
    border: 1px solid rgba(48, 53, 67, 0.14);
    color: #4e5565;
    background: rgba(255, 255, 255, 0.62);
}

body.chat-shell.theme-light.workspace-mode-chat .code-copy-btn:hover {
    border-color: rgba(92, 74, 196, 0.24);
    color: #5543bf;
    background: #ffffff;
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-chip,
body.chat-shell.theme-light.workspace-mode-chat .thinking-level {
    color: #a36b00;
}

body.chat-shell.theme-light.workspace-mode-chat .thinking-status,
body.chat-shell.theme-light.workspace-mode-chat .thinking-toggle {
    color: rgba(77, 65, 41, 0.66);
}

body.chat-shell.theme-light.workspace-mode-chat .message-completion-status {
    border-color: rgba(26, 145, 84, 0.18);
    color: #187746;
    background: rgba(26, 145, 84, 0.09);
}

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

    body.chat-shell.workspace-mode-chat .input-container {
        width: 100%;
        max-width: none;
    }

    body.chat-shell.workspace-mode-chat .chat-input-box {
        max-width: none;
    }

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

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

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

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

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