:root {
    --bg0: #070914;
    --bg1: #0b0f22;
    --card: rgba(255, 255, 255, 0.06);
    --card2: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.12);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.62);

    --accent: #7aa7ff;
    --accent2: #b794ff;
    --good: #59d4a8;
    --warn: #ffd36b;
    --bad: #ff6b86;

    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --radius2: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 600px at 20% 10%, rgba(122, 167, 255, 0.22), transparent 55%),
        radial-gradient(900px 600px at 80% 20%, rgba(183, 148, 255, 0.16), transparent 55%),
        radial-gradient(900px 600px at 50% 95%, rgba(89, 212, 168, 0.10), transparent 55%),
        linear-gradient(180deg, var(--bg0), var(--bg1));
}

.app {
    width: min(920px, 100%);
    margin: 0 auto;
    padding: 22px 18px 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

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

.brand__mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), transparent 40%),
        linear-gradient(135deg, rgba(122, 167, 255, 0.95), rgba(183, 148, 255, 0.92));
    box-shadow: 0 12px 30px rgba(122, 167, 255, 0.22);
}

.brand__title {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.2px;
}

.brand__subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 999px;
    user-select: none;
}

.status__dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.status[data-mode="working"] .status__dot {
    background: var(--warn);
    box-shadow: 0 0 0 4px rgba(255, 211, 107, 0.12);
}

.status[data-mode="ok"] .status__dot {
    background: var(--good);
    box-shadow: 0 0 0 4px rgba(89, 212, 168, 0.12);
}

.status[data-mode="error"] .status__dot {
    background: var(--bad);
    box-shadow: 0 0 0 4px rgba(255, 107, 134, 0.12);
}

.status__text {
    font-size: 12px;
    color: var(--muted);
}

.chat {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.04));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.messages {
    height: min(64vh, 620px);
    padding: 16px 14px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0;
    max-width: 92%;
}

.msg.user {
    margin-left: auto;
    align-items: flex-end;
}

.msg.bot {
    margin-right: auto;
    align-items: flex-start;
}

.bubble {
    padding: 10px 12px;
    border-radius: var(--radius2);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.06);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg.user .bubble {
    background: linear-gradient(135deg, rgba(122, 167, 255, 0.24), rgba(183, 148, 255, 0.18));
    border-color: rgba(122, 167, 255, 0.25);
}

.msg.bot .bubble {
    background: rgba(0, 0, 0, 0.22);
    border-color: rgba(255, 255, 255, 0.10);
}

.meta {
    font-size: 11px;
    color: var(--muted);
    padding: 0 4px;
}

.composer {
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.18);
    padding: 12px 12px 10px;
}

.quick {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.inputRow {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 140px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    outline: none;
}

.input:focus {
    border-color: rgba(122, 167, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(122, 167, 255, 0.12);
}

.btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 10px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    user-select: none;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.09);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(122, 167, 255, 0.95), rgba(183, 148, 255, 0.92));
    border-color: rgba(255, 255, 255, 0.18);
    color: #061023;
    font-weight: 700;
    min-width: 86px;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
}

.hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kbd {
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.78);
}

.hint .dot {
    opacity: 0.5;
}

.footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

.footer__sep {
    opacity: 0.35;
}

/* typing dots */
.typing {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.typing .dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
    animation: bounce 900ms infinite ease-in-out;
}

.typing .dot:nth-child(2) {
    animation-delay: 120ms;
}

.typing .dot:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.55;
    }

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

/* mobile polish */
@media (max-width: 520px) {
    .messages {
        height: 66vh;
    }

    .brand__subtitle {
        display: none;
    }

    .btn-primary {
        min-width: 76px;
    }
}