*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f5f5f5;
}

.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 768px) {
    .layout {
        flex-direction: row;
    }
}

.sidebar {
    flex: 0 0 auto;
    padding: 1rem;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    max-height: 50vh;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .sidebar {
        width: 320px;
        max-height: none;
        border-bottom: none;
        border-right: 1px solid #e0e0e0;
    }
}

.block {
    margin-bottom: 1.25rem;
}

.block:last-child {
    margin-bottom: 0;
}

.block h2 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.preprompt-block textarea {
    width: 100%;
    padding: 0.5rem;
    font: inherit;
    font-size: 0.9rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    resize: vertical;
    min-height: 120px;
}

.preprompt-block textarea:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.important-block ul,
.crontab-block ul {
    margin: 0;
    padding-left: 1.25rem;
    list-style: disc;
}

.important-block li,
.crontab-block li {
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    align-self: flex-start;
}

.message--user {
    align-self: flex-end;
    background: #1976d2;
    color: #fff;
}

.message--bot {
    background: #e8e8e8;
    color: #1a1a1a;
}

.message-role {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    opacity: 0.9;
}

.message--bot .message-role {
    color: #555;
}

.message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-input-row {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 1rem;
    background: #fff;
    border-top: 1px solid #e0e0e0;
}

.chat-input-row label {
    flex: 0 0 auto;
    font-size: 0.9rem;
    color: #555;
}

.chat-input-row #name {
    flex: 0 0 140px;
    padding: 0.5rem;
    font: inherit;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.chat-input-row #question {
    flex: 1 1 200px;
    min-width: 0;
    padding: 0.5rem;
    font: inherit;
    border: 1px solid #ccc;
    border-radius: 6px;
    resize: none;
    min-height: 44px;
}

.chat-input-row #question:focus,
.chat-input-row #name:focus {
    outline: none;
    border-color: #1976d2;
}

.chat-input-row #send-btn {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: #1976d2;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.chat-input-row #send-btn:hover:not(:disabled) {
    background: #1565c0;
}

.chat-input-row #send-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
