.bots {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 360px;
    color: var(--theme-text-primary);
}

.bots-header {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm, 12px);
    padding: var(--theme-space-sm, 12px);
    border-bottom: 1px solid var(--theme-border-subtle, #e4e4e7);
    flex-shrink: 0;
}

.bots-header-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bots-header-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-xs, 6px);
}

.bots-title {
    margin: 0;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.bots-title--ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.bots-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--theme-color-primary, #2e7df1);
    font: inherit;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: var(--theme-radius-sm, 6px);
}

.bots-back:hover,
.bots-back:focus-visible {
    background: var(--theme-bg-secondary, #f5f5f5);
    outline: none;
}

.bots-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--theme-text-secondary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.bots-icon-button:hover,
.bots-icon-button:focus-visible {
    background: var(--theme-bg-secondary, #f5f5f5);
    color: var(--theme-text-primary);
    outline: none;
}

.bots-primary-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--theme-radius-md, 10px);
    background: var(--theme-color-primary, #2e7df1);
    color: var(--theme-text-inverse, #fff);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.bots-primary-button:hover,
.bots-primary-button:focus-visible {
    filter: brightness(1.08);
    outline: none;
}

.bots-primary-button:active {
    transform: scale(0.97);
}

.bots-primary-button--compact {
    padding: 6px 12px;
    font-size: 0.9em;
}

.bots-status-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-xs, 6px);
}

.bots-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bots-status-badge--active {
    background: var(--theme-color-success-soft, rgba(34, 178, 99, 0.15));
    color: var(--theme-color-success, #22b263);
}

.bots-status-badge--paused {
    background: var(--theme-color-warning-soft, rgba(255, 167, 38, 0.15));
    color: var(--theme-color-warning, #cc7a00);
}

.bots-status-action {
    padding: 4px 10px;
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    background: var(--theme-bg-primary, #fff);
    color: var(--theme-text-primary);
    font: inherit;
    font-size: 0.85em;
    border-radius: var(--theme-radius-sm, 6px);
    cursor: pointer;
}

.bots-status-action:hover,
.bots-status-action:focus-visible {
    background: var(--theme-bg-secondary, #f5f5f5);
    outline: none;
}

.bots-notice {
    margin: auto;
    padding: var(--theme-space-md, 16px);
    color: var(--theme-text-secondary);
    font-style: italic;
    text-align: center;
}

.bots-config {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--theme-space-md, 16px);
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-sm, 12px);
}

.bots-config-label {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--theme-text-primary);
}

.bots-config-textarea {
    width: 100%;
    min-height: 160px;
    padding: var(--theme-space-sm, 12px);
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    border-radius: var(--theme-radius-md, 10px);
    background: var(--theme-bg-primary, #fff);
    color: var(--theme-text-primary);
    font: inherit;
    font-size: 0.95em;
    line-height: 1.5;
    resize: vertical;
}

.bots-config-textarea:focus {
    border-color: var(--theme-color-primary, #2e7df1);
    outline: none;
    box-shadow: 0 0 0 3px var(--theme-color-primary-soft, rgba(46, 125, 241, 0.15));
}

.bots-files {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bots-files-empty {
    padding: var(--theme-space-sm, 12px);
    color: var(--theme-text-secondary);
    font-style: italic;
    font-size: 0.9em;
    background: var(--theme-bg-secondary, #f5f5f5);
    border-radius: var(--theme-radius-sm, 6px);
}

.bots-file {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm, 12px);
    padding: 8px 12px;
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    border-radius: var(--theme-radius-sm, 6px);
    background: var(--theme-bg-primary, #fff);
}

.bots-file-icon {
    display: inline-flex;
    color: var(--theme-color-primary, #2e7df1);
}

.bots-file-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bots-file-name {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--theme-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bots-file-size {
    font-size: 0.75em;
    color: var(--theme-text-secondary);
}

.bots-file-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.bots-file-remove:hover,
.bots-file-remove:focus-visible {
    background: var(--theme-color-danger-soft, rgba(220, 53, 69, 0.15));
    color: var(--theme-color-danger, #dc3545);
    outline: none;
}

.bots-upload-row {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm, 12px);
}

.bots-upload-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    border-radius: var(--theme-radius-sm, 6px);
    background: var(--theme-bg-primary, #fff);
    color: var(--theme-text-primary);
    font: inherit;
    font-size: 0.9em;
    cursor: pointer;
}

.bots-upload-button:hover,
.bots-upload-button:focus-visible {
    background: var(--theme-bg-secondary, #f5f5f5);
    outline: none;
}

.bots-upload-hint {
    font-size: 0.8em;
    color: var(--theme-text-secondary);
}

.bots-config-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--theme-space-sm, 12px);
    border-top: 1px solid var(--theme-border-subtle, #e4e4e7);
}

.bots-threads {
    list-style: none;
    margin: 0;
    padding: var(--theme-space-sm, 12px);
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bots-threads-empty {
    margin: auto;
    color: var(--theme-text-secondary);
    font-style: italic;
}

.bots-thread {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm, 12px);
    padding: var(--theme-space-sm, 12px);
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    border-radius: var(--theme-radius-md, 10px);
    background: var(--theme-bg-primary, #fff);
}

.bots-thread-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--theme-color-primary-soft, rgba(46, 125, 241, 0.12));
    color: var(--theme-color-primary, #2e7df1);
    flex-shrink: 0;
}

.bots-thread-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.bots-thread-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--theme-space-sm, 12px);
}

.bots-thread-title {
    font-weight: 600;
    font-size: 0.95em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bots-thread-time {
    font-size: 0.75em;
    color: var(--theme-text-secondary);
    flex-shrink: 0;
}

.bots-thread-preview {
    font-size: 0.85em;
    color: var(--theme-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bots-thread-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.bots-thread-remove:hover,
.bots-thread-remove:focus-visible {
    background: var(--theme-color-danger-soft, rgba(220, 53, 69, 0.15));
    color: var(--theme-color-danger, #dc3545);
    outline: none;
}

.bots-messages {
    list-style: none;
    margin: 0;
    padding: var(--theme-space-sm, 12px);
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-sm, 12px);
    background: var(--theme-bg-secondary, #f5f5f5);
}

.bots-messages-empty {
    margin: auto;
    color: var(--theme-text-secondary);
    font-style: italic;
}

.bots-message {
    display: flex;
    gap: var(--theme-space-sm, 12px);
    align-items: flex-start;
}

.bots-message--user {
    flex-direction: row-reverse;
}

.bots-message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--theme-bg-tertiary, #ececec);
    color: var(--theme-text-secondary);
}

.bots-message--assistant .bots-message-avatar {
    background: var(--theme-color-primary-soft, rgba(46, 125, 241, 0.12));
    color: var(--theme-color-primary, #2e7df1);
}

.bots-message-bubble {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(640px, 80%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--theme-space-sm, 12px) var(--theme-space-md, 16px);
    background: var(--theme-bg-primary, #fff);
    border-radius: var(--theme-radius-md, 10px);
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.bots-message--user .bots-message-bubble {
    background: var(--theme-color-primary-soft, rgba(46, 125, 241, 0.12));
    border-color: var(--theme-color-primary-soft, rgba(46, 125, 241, 0.18));
}

.bots-message-body {
    color: var(--theme-text-primary);
    font-size: 0.95em;
    line-height: 1.5;
    word-break: break-word;
}

.bots-message--user .bots-message-body {
    white-space: pre-wrap;
}

.bots-message-body p {
    margin: 0 0 0.5em 0;
}

.bots-message-body p:last-child {
    margin-bottom: 0;
}

.bots-message-body pre,
.bots-message-body code {
    background: var(--theme-bg-secondary, #f5f5f5);
    border-radius: var(--theme-radius-sm, 6px);
    font-size: 0.9em;
}

.bots-message-body pre {
    padding: 8px 12px;
    overflow-x: auto;
}

.bots-message-body code {
    padding: 1px 4px;
}

.bots-message-time {
    font-size: 0.7em;
    color: var(--theme-text-secondary);
}

.bots-cursor {
    display: inline-block;
    width: 6px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--theme-color-primary, #2e7df1);
    animation: bots-cursor-blink 0.9s steps(1) infinite;
}

@keyframes bots-cursor-blink {
    50% { opacity: 0; }
}

.bots-composer {
    flex-shrink: 0;
    padding: var(--theme-space-sm, 12px);
    background: var(--theme-bg-primary);
    border-top: 1px solid var(--theme-border-subtle, #e4e4e7);
}

.bots-composer-row {
    display: flex;
    align-items: flex-end;
    gap: var(--theme-space-sm, 12px);
    padding: var(--theme-space-xs, 6px) var(--theme-space-sm, 12px);
    border-radius: 999px;
    background: var(--theme-bg-secondary, #f5f5f5);
    border: 1px solid var(--theme-border-subtle, #e4e4e7);
}

.bots-composer-row:focus-within {
    border-color: var(--theme-color-primary, #2e7df1);
    box-shadow: 0 0 0 3px var(--theme-color-primary-soft, rgba(46, 125, 241, 0.15));
}

.bots-composer-textarea {
    flex: 1 1 auto;
    min-height: 24px;
    max-height: 180px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: var(--theme-text-primary);
    font: inherit;
    font-size: 0.95em;
    line-height: 1.4;
    resize: none;
    outline: none;
}

.bots-composer-textarea:disabled {
    opacity: 0.6;
}

.bots-composer-button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--theme-color-primary, #2e7df1);
    color: var(--theme-text-inverse, #fff);
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.bots-composer-button:hover:not(:disabled),
.bots-composer-button:focus-visible:not(:disabled) {
    filter: brightness(1.08);
    outline: none;
}

.bots-composer-button:active:not(:disabled) {
    transform: scale(0.96);
}

.bots-composer-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.bots-composer-notice {
    margin: 0;
    padding: var(--theme-space-sm, 12px);
    border-radius: var(--theme-radius-sm, 6px);
    background: var(--theme-bg-secondary, #f5f5f5);
    color: var(--theme-text-secondary);
    font-size: 0.9em;
    text-align: center;
    font-style: italic;
}

@media (max-width: 560px) {
    .bots {
        min-height: 0;
    }
    .bots-message-bubble {
        max-width: 88%;
    }
    .bots-config {
        padding: var(--theme-space-sm, 12px);
    }
}
