* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #101114;
    color: #f2f2f2;
}

.page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 32px 16px;
}

.panel {
    width: 100%;
    max-width: 980px;
    background: #181a20;
    border: 1px solid #2a2d36;
    border-radius: 16px;
    padding: 24px;
}

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

.header h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
}

.header p {
    margin: 0;
    color: #a9adba;
}

.status {
    padding: 8px 12px;
    border-radius: 999px;
    background: #242832;
    color: #c9cedb;
    font-size: 14px;
    white-space: nowrap;
}

.settings {
    display: grid;
    grid-template-columns: 1fr 1fr 160px 100px;
    gap: 12px;
    margin-bottom: 20px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #c9cedb;
    font-size: 14px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #343845;
    background: #101114;
    color: #f2f2f2;
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #6f7cff;
}

.chat {
    min-height: 360px;
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid #2a2d36;
    border-radius: 12px;
    padding: 16px;
    background: #12141a;
    margin-bottom: 16px;
}

.message {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.user {
    background: #202436;
    border: 1px solid #303650;
}

.message.ai {
    background: #17251d;
    border: 1px solid #294734;
}

.message.error {
    background: #311b1b;
    border: 1px solid #633232;
}

.message-meta {
    font-size: 13px;
    color: #a9adba;
    margin-bottom: 6px;
}

.retrieval {
    margin-top: 10px;
    font-size: 13px;
    color: #a9adba;
}

.ask-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

button {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    background: #2a2d36;
    color: #f2f2f2;
}

button[type="submit"] {
    background: #5865f2;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

    .header {
        flex-direction: column;
    }

    .actions {
        flex-direction: column-reverse;
    }
}