:root {
    color-scheme: light;
    --bg: #f6f7f8;
    --panel: #ffffff;
    --panel-soft: #eef4f2;
    --text: #17201d;
    --muted: #65716d;
    --line: #d8dfdc;
    --accent: #16735f;
    --accent-strong: #0d5948;
    --warning: #a55415;
    --shadow: 0 18px 50px rgba(23, 32, 29, 0.08);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

button,
textarea,
a {
    font: inherit;
}

.shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 0;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 28px;
    border-right: 1px solid var(--line);
    background: #fbfcfb;
}

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

.brand img {
    flex: 0 0 auto;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.quota {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.quota strong {
    color: var(--accent-strong);
    font-size: 15px;
}

.side-actions {
    display: grid;
    gap: 10px;
}

.side-actions a,
.ghost-button,
.quick-prompts button,
.composer button {
    border-radius: 8px;
    border: 1px solid var(--line);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.side-actions a {
    padding: 10px 12px;
    color: var(--text);
    background: var(--panel);
}

.side-actions a:hover,
.ghost-button:hover,
.quick-prompts button:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.chat-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    min-height: 100vh;
    padding: 28px min(5vw, 56px);
}

.chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
}

.chat-header h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.2;
    letter-spacing: 0;
}

.chat-header p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.ghost-button {
    flex: 0 0 auto;
    padding: 8px 12px;
    background: transparent;
    color: var(--muted);
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 18px;
}

.quick-prompts button {
    padding: 8px 12px;
    background: var(--panel);
    color: var(--text);
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding: 12px 4px 22px;
}

.message {
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.bubble {
    max-width: min(760px, 86%);
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message.user .bubble {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: none;
}

.sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(216, 223, 220, 0.8);
    color: var(--muted);
    font-size: 13px;
}

.sources a {
    color: var(--accent-strong);
}

.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.copy-button {
    min-width: 56px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf9;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
}

.copy-button:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.composer textarea {
    width: 100%;
    min-height: 48px;
    max-height: 160px;
    resize: vertical;
    border: 0;
    outline: none;
    color: var(--text);
    line-height: 1.5;
}

.composer button {
    min-height: 48px;
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

.composer button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.status {
    min-height: 22px;
    padding-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.status.warning {
    color: var(--warning);
}

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

@media (max-width: 860px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .quota {
        padding: 0;
        border: 0;
    }

    .side-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .chat-panel {
        min-height: calc(100vh - 136px);
        padding: 18px 14px;
    }

    .chat-header {
        gap: 12px;
    }

    .chat-header p {
        font-size: 14px;
    }

    .bubble {
        max-width: 94%;
    }

    .composer {
        grid-template-columns: 1fr;
    }
}
