.chat-page * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.chat-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #ffffff;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "PingFang SC",
        sans-serif;
    color: #202123;
}

.chat-page .app {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-page .suggestions {
    display: grid;
    grid-template-columns: repeat(2, 260px);
    gap: 12px;
    justify-content: center;
    margin-top: 30px;
}

.chat-page .suggestions button {
    background: #f7f7f8;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px;
    height: 50px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    white-space: normal;
}

.chat-page .suggestions button:hover {
    background: #eeeeee;
}

/* 聊天区域。 */

.chat-page #chat-box {
    width: 760px;
    flex: 1;
    min-height: 0;
    margin: 0 auto;
    overflow-y: auto;
    padding-top: 20px;
    padding-bottom: 120px;
}

.chat-page .welcome {
    text-align: center;
    padding-top: 70px;
    margin-bottom: 40px;
    flex-shrink: 0;
}

.chat-page .welcome h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
}

.chat-page .welcome p {
    margin-top: 10px;
    color: #8e8ea0;
    font-size: 16px;
}

/* 消息。 */

.chat-page .msg {
    width: 100%;
    margin-bottom: 20px;
    padding-top: 10px;
    line-height: 1.8;
    font-size: 16px;
    animation: chat-show .2s ease;
}

.chat-page .user {
    display: flex;
    justify-content: flex-end;
}

.chat-page .user {
    background: #f1f3f5;
    color: #202123;
    padding: 12px 18px;
    border-radius: 18px;
    width: max-content;
    max-width: 70%;
    margin-left: auto;
}

.chat-page .ai {
    padding: 5px 0;
    color: #202123;
}

/* 输入框。 */

.chat-page .input-area {
    flex-shrink: 0;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.chat-page .input-box {
    width: 760px;
    background: white;
    border-radius: 22px;
    padding: 14px 18px;
    display: flex;
    align-items: flex-end;
    box-shadow:
        0 0 0 1px #ddd,
        0 8px 30px rgba(0, 0, 0, .08);
}

.chat-page textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.6;
    height: 72px;
    max-height: 160px;
    padding: 8px 4px;
    display: flex;
    align-items: center;
}

.chat-page .input-box button {
    flex-shrink: 0;
    align-self: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #202123;
    color: white;
    cursor: pointer;
    font-size: 20px;
}

.chat-page .input-box button:hover {
    background: #000;
}

@keyframes chat-show {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 800px) {
    .chat-page #chat-box,
    .chat-page .input-box {
        width: calc(100% - 30px);
    }
}

/* =========================
   Execution Trace
   ========================= */

.execution-trace {
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    padding-bottom: 10px;
    width: 100%;
}

.execution-trace summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.85;
    user-select: none;
}

.execution-trace summary:hover {
    opacity: 1;
}

.trace-list {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.07);
    max-height: 300px;
    overflow-y: auto;
}

.trace-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 5px 0;
    font-size: 12px;
    line-height: 1.5;
}

.trace-name {
    font-weight: 500;
}

.trace-target {
    font-family: monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
    background: rgba(128, 128, 128, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
}

.trace-status {
    margin-left: auto;
    opacity: 0.65;
    font-size: 11px;
}

.trace-item[data-status="completed"] .trace-status,
.trace-item[data-status="sufficient"] .trace-status {
    color: #16a34a;
    opacity: 1;
}

.trace-item[data-status="failed"] .trace-status {
    color: #dc2626;
    opacity: 1;
}

.trace-item[data-status="retrying"] .trace-status,
.trace-item[data-status="insufficient"] .trace-status {
    color: #d97706;
    opacity: 1;
}

.ai-answer {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* =========================
   Agent 执行中的发送按钮
   ========================= */

.chat-page #send:disabled {
    cursor: wait;
    opacity: 1;
}

/* 隐藏箭头文字，但不改变按钮尺寸或输入框布局。 */
.chat-page #send.is-loading,
.chat-page #send.is-loading:hover {
    position: relative;
    color: transparent;
    background: #202123;
    cursor: wait;
}

.chat-page #send.is-loading::after {
    content: "";
    position: absolute;
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    pointer-events: none;
    animation: agent-loading 0.8s linear infinite;
}

@keyframes agent-loading {
    to {
        transform: rotate(360deg);
    }
}

/* 尊重系统减少动态效果的偏好，保留静态忙碌标识。 */
@media (prefers-reduced-motion: reduce) {
    .chat-page #send.is-loading::after {
        animation: none;
    }
}