:root {
    --bg-dark: #050508;
    --bg-panel: #12121a;
    --neon-green: #39ff14;
    --neon-cyan: #00f7ff;
    --text-light: #e0e0e0;
    --text-dim: #6f7f95;
    --green-glow: 0 0 10px rgba(57, 255, 20, 0.5), 0 0 20px rgba(57, 255, 20, 0.3);
    --cyan-glow: 0 0 10px rgba(0, 247, 255, 0.5), 0 0 20px rgba(0, 247, 255, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace, 'Segoe UI', Tahoma;
}

body {
    background: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--bg-panel);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2a2a3a
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px
}

.logo {
    height: 40px;
    filter: drop-shadow(0 0 5px var(--neon-green))
}

.model-name {
    color: var(--neon-green);
    font-weight: bold
}

.promo-banner {
    background: rgba(57, 255, 20, 0.03);
    color: var(--neon-green);
    text-align: center;
    padding: 10px;
    font-weight: bold;
    border-top: 1px solid var(--neon-green);
    border-bottom: 1px solid var(--neon-green)
}

#chat-container {
    flex: 1;
    padding: 18px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-image: linear-gradient(var(--bg-panel) 2px, transparent 2px), linear-gradient(90deg, var(--bg-panel) 2px, transparent 2px);
    background-size: 40px 40px;
    background-position: -2px -2px
}

.message {
    max-width: 72%;
    padding: 12px 16px;
    line-height: 1.45;
    font-size: 1rem;
    position: relative;
    
    /* ⭐️ 核心修正：提升 white-space: pre-wrap; 到基础 .message 样式 */
    /* 这确保了所有消息（包括流式结束后）都能正确显示换行符 */
    white-space: pre-wrap;
}

/* 针对流式输出创建的临时容器，用于接收实时文本 */
.message.ai.streaming {
    align-self: flex-start;
    background: #1a1a24;
    border-left: 3px solid var(--neon-cyan);
    /* white-space: pre-wrap; 现在可以移除或保留，因为它会从 .message 继承 */
}

.message.ai {
    align-self: flex-start;
    background: #1a1a24;
    border-left: 3px solid var(--neon-cyan);
}

.message.user {
    align-self: flex-end;
    background: rgba(57, 255, 20, 0.08);
    border-right: 3px solid var(--neon-green);
    color: var(--neon-green)
}

.input-area {
    background: var(--bg-panel);
    padding: 12px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #222
}

textarea {
    flex: 1;
    padding: 10px;
    background: var(--bg-dark);
    border: 1px solid #333;
    color: var(--neon-green);
    height: 56px;
    resize: none;
    border-radius: 4px
}

.send-btn {
    border: 2px solid var(--neon-green);
    background: transparent;
    color: var(--neon-green);
    padding: 0 20px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px
}

.send-btn:active {
    transform: scale(0.98)
}

.watermark {
    padding: 8px 12px;
    background: var(--bg-panel);
    text-align: center;
    color: var(--text-dim);
    font-size: 12px
}

/* loading spinner */
.typing {
    display: inline-block;
    width: 38px;
    text-align: left;
}

.typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    background: var(--neon-cyan);
    border-radius: 50%;
    opacity: 0.4;
    animation: blink 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
    animation-delay: 0.15s
}

.typing span:nth-child(3) {
    animation-delay: 0.30s
}

@keyframes blink {
    0% {
        opacity: .2;
        transform: translateY(0)
    }

    50% {
        opacity: 1;
        transform: translateY(-4px)
    }

    100% {
        opacity: .2;
        transform: translateY(0)
    }
}