.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 8px;
}


.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 16px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-radius: 4px;
}

.messageHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.messageActions {
    display: flex;
    gap: 4px;
}

.iconButton {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;

    &:hover:not(:disabled) {
        color: var(--text);
        background: var(--bg-hover);
    }

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
}

.saveButton:hover:not(:disabled) {
    color: var(--accent);
}

.cancelButton:hover:not(:disabled) {
    color: var(--error, #f44336);
}

.editContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editTextarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text);
    outline: none;
    resize: vertical;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.editActions {
    display: flex;
    gap: 4px;
}

.message[data-role="user"] {
    background: var(--bg-active);
}

.message[data-role="assistant"] {
    background: var(--bg-panel);
}

.message[data-role="system"] {
    background: var(--bg-hover);
}

.message[data-role="tool"] .content {
    font-size: 12px;
    font-style: italic;
    opacity: 0.5;
}

.role {
    font-size: 11px;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.role > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

.reasoningContent {
    font-size: 13px;
    font-style: italic;
    opacity: 0.5;
    border-left: 2px solid currentColor;
    padding-left: 0.5em;
    margin-bottom: 0.5em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.content {
    font-size: 15px;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.toolCalls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.toolBadge {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--bg-active);
    color: var(--text-dim);
    border-radius: var(--radius);
    font-weight: 500;
    text-transform: none;

    .role & {
        padding: 0 3px;
    }
}

.loading {
    color: var(--text-muted);
    font-style: italic;
}

.errorMessage {
    background: rgba(244, 67, 54, 0.1);
    border-left: 2px solid var(--error, #f44336);
}

.errorText {
    font-size: 13px;
    color: var(--error, #f44336);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.inputContainer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.inputWrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s ease;

    &:focus-within {
        border-color: var(--accent);
    }
}

.input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;

    &::placeholder {
        color: var(--text-muted);
    }
}

.inputFooter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.inputFooterLeft {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.inputFooterRight {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tokenCounter {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.toggleContainer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;

    input[type="checkbox"] {
        cursor: pointer;
        accent-color: var(--accent);
    }
}

.actionButton {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    height: 28px;
    width: 28px;

    &:hover:not(:disabled) {
        color: var(--text);
        border-color: var(--text-muted);
    }

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
}

.sendButton {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    color: var(--bg);
    background: var(--accent);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    height: 28px;
    width: 28px;

    &:hover:not(:disabled) {
        background: var(--accent-alt);
    }

    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
}

.stopButton {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    color: var(--bg);
    background: var(--error, #f44336);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    height: 28px;
    width: 28px;

    &:hover {
        background: #d32f2f;
    }
}
