﻿:root {
    --bg: #0b0c10;
    --card: #12141b;
    --border: #2a2e3a;
    --text: #e8eaf0;
    --muted: #a7adbd;
    --btn: #2b6fff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background: var(--bg);
    color: var(--text);
}

.container {
    width: min(980px, 96vw);
    margin: 14px auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
}

.access-denied {
    border-color: #7f1d1d;
    background: rgba(127, 29, 29, .18);
}

.access-denied-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fecaca;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
}

    .row.wrap {
        flex-wrap: wrap;
    }

.grow {
    flex: 1;
}

input, button, textarea {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #0f1117;
    color: var(--text);
    padding: 10px 12px;
    font-size: 16px;
}

textarea {
    width: 100%;
    min-height: 44px;
    resize: vertical;
}

.btn {
    background: var(--btn);
    border: none;
    padding: 10px 14px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
}



.small {
    color: var(--muted);
    font-size: 13px;
}

.status-alert {
    color: #f87171;
    font-weight: 600;
}

.chat {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble {
    white-space: pre-wrap;
    line-height: 1.5;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #0f1117;
}

    .bubble.user {
        border-color: #3a4666;
    }

.bubble.assistant {
    border-color: #2c3a2f;
}

.bubble.thinking {
    color: var(--muted);
    font-style: italic;
}

.bubble.thinking::after {
    content: " ...";
    display: inline-block;
    animation: thinkingDots 1.1s steps(4, end) infinite;
}

details summary {
    cursor: pointer;
    color: var(--muted);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.hidden {
    display: none;
}

.modal-card {
    width: min(920px, 96vw);
    max-height: 86vh;
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

pre.pre {
    white-space: pre-wrap;
    background: #0f1117;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.cite-card {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 10px;
    margin: 8px 0;
    background: rgba(0,0,0,.55);
}

.cite-head {
    font-weight: 700;
    font-size: 13px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}

/* --------- Layout: full height + bottom composer --------- */
html, body {
    height: 100%;
}

body {
    margin: 0;
}

.container.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px); /* iOS safe area */
}

/* Chat area grows and scrolls */
.chat {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Bottom composer fixed */
.composer {
    position: sticky; /* sticky better than fixed for mobile + virtual keyboard */
    bottom: 0;
    z-index: 10;
    background: var(--card-bg, #fff);
    box-shadow: 0 -6px 16px rgba(0,0,0,.06);
}

/* citations panel collapsible */
.cites-panel {
    display: none;
    margin-top: 10px;
}

    .cites-panel.show {
        display: block;
    }

/* bubbles: keep your existing bubble styles; add prefix look */
.bubble {
    white-space: pre-wrap;
    line-height: 1.5;
}

    .bubble .prefix {
        font-weight: 700;
        margin-right: 6px;
    }

/* small button */
.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}

/* --------- UI nudge / highlight --------- */
.btn-attn {
    box-shadow: 0 0 0 3px rgba(0,0,0,.12);
    transform: translateY(-1px);
}

@keyframes pulseAttn {
    0% {
        box-shadow: 0 0 0 0 rgba(0,0,0,.25);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0,0,0,0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0,0,0,0);
    }
}

@keyframes thinkingDots {
    0% {
        opacity: .25;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: .25;
    }
}

.btn-pulse {
    animation: pulseAttn 700ms ease-out 1;
}

.btn-secondary {
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    color: var(--text);
}

    .btn-secondary:hover {
        background: rgba(255,255,255,.10);
    }

    .btn-secondary:active {
        transform: translateY(1px);
    }

.btn:hover {
    filter: brightness(1.06);
}

.btn:active {
    transform: translateY(1px);
}

button:disabled,
.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.api-endpoint-badge {
    min-width: 260px;
    padding: 12px 14px;
    border: 1px solid #3a4666;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(43,111,255,.14), rgba(43,111,255,.04));
}

.api-endpoint-badge code {
    display: block;
    margin-top: 6px;
    color: #d8e4ff;
    word-break: break-all;
}

.api-chat-log {
    padding: 16px;
    gap: 14px;
}

.api-chat-log:empty::before {
    content: "对话会显示在这里。";
    color: var(--muted);
}

.api-chat-input {
    min-height: 88px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.chat-role {
    font-size: 12px;
    color: var(--muted);
    padding: 0 4px;
}

.chat-bubble {
    max-width: min(820px, 100%);
    white-space: pre-wrap;
    line-height: 1.6;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #0f1117;
}

.chat-message.user .chat-bubble {
    border-color: #3a4666;
    background: linear-gradient(180deg, rgba(43,111,255,.18), rgba(43,111,255,.08));
}

.chat-message.assistant .chat-bubble {
    border-color: #2c3a2f;
    background: linear-gradient(180deg, rgba(40,167,69,.14), rgba(40,167,69,.05));
}

/* fix sticky composer background */
.composer {
    background: var(--card);
    box-shadow: 0 -6px 16px rgba(0,0,0,.20);
}

@media (max-width: 720px) {
    .api-endpoint-badge {
        min-width: 0;
        width: 100%;
    }

    .api-chat-input {
        min-height: 110px;
    }

    .chat-bubble {
        max-width: 100%;
    }
}

/* make attention visible in dark theme */
.btn-attn {
    box-shadow: 0 0 0 3px rgba(43,111,255,.35);
    transform: translateY(-1px);
}

@keyframes pulseAttn {
    0% {
        box-shadow: 0 0 0 0 rgba(43,111,255,.45);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(43,111,255,0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(43,111,255,0);
    }
}
