* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    background: #1e1e1e;
    color: #ccc;
    overflow: hidden;
}

.ai-header {
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    background: #252526;
    flex-shrink: 0;
}

.ai-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

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

.ai-header h1 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.ai-toggle-config {
    padding: 3px 8px;
    font-size: 11px;
    background: #3c3c3c;
    color: #ccc;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
}

.ai-toggle-config:hover { background: #4a4a4a; }

.ai-subtitle {
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.config-grid.collapsed { display: none; }

.config-grid label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #888;
}

.config-grid input,
.config-grid select {
    padding: 5px 6px;
    background: #3c3c3c;
    border: 1px solid #444;
    border-radius: 3px;
    color: #ddd;
    font-size: 12px;
}

.config-grid input:focus,
.config-grid select:focus {
    outline: none;
    border-color: #0e639c;
}

.config-grid button {
    grid-column: span 2;
    padding: 6px;
    background: #0e639c;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.config-grid button:hover { background: #1177bb; }

.chat-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: #1e1e1e;
}

.input-area {
    padding: 10px;
    border-top: 1px solid #333;
    background: #252526;
    flex-shrink: 0;
}

/* ── AI Composer（Cursor 风格）── */
.ai-composer {
    padding: 10px 12px 12px;
    border-top: 1px solid #2d2d2d;
    background: #1e1e1e;
    flex-shrink: 0;
}

.ai-composer-box {
    border: 1px solid #3c3c3c;
    border-radius: 10px;
    background: #252526;
    overflow: visible;
    position: relative;
}

.ai-composer-box:focus-within {
    border-color: #4a4a4a;
    box-shadow: 0 0 0 1px rgba(14, 99, 156, 0.25);
}

.ai-composer textarea,
.ai-composer #prompt {
    width: 100%;
    min-height: 44px;
    max-height: 200px;
    padding: 12px 14px 8px;
    background: transparent;
    border: none;
    border-radius: 10px 10px 0 0;
    color: #e8e8e8;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
}

.ai-composer textarea:focus,
.ai-composer #prompt:focus {
    outline: none;
}

.ai-composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px 8px;
}

.ai-composer-left {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ai-context-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
    color: #9d9d9d;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.ai-context-toggle:hover {
    background: #333;
    color: #ccc;
}

.ai-context-toggle input {
    margin: 0;
    accent-color: #2d5a3d;
    cursor: pointer;
}

.ai-errors-badge {
    min-width: 14px;
    padding: 0 4px;
    border-radius: 8px;
    background: #8b2942;
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
}

.ai-model-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #9d9d9d;
    font-size: 12px;
    cursor: pointer;
}

.ai-model-switch:hover {
    background: #333;
    color: #ccc;
}

.ai-model-switch-label,
#ai-model-switch-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.ai-model-switch-chevron {
    flex-shrink: 0;
    opacity: 0.7;
}

.ai-model-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 50;
    min-width: 220px;
    max-width: 280px;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    background: #252526;
    border: 1px solid #454545;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.ai-model-menu-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #ccc;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.ai-model-menu-item:hover {
    background: #333;
}

.ai-model-menu-item.is-active {
    background: rgba(14, 99, 156, 0.2);
    color: #fff;
}

.ai-model-menu-name {
    font-weight: 500;
    color: #e8e8e8;
}

.ai-model-menu-prov {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.ai-model-menu-divider {
    height: 1px;
    margin: 4px 6px;
    background: #3c3c3c;
}

.ai-model-menu-item--muted {
    color: #888;
    font-size: 11px;
}

.ai-composer-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #888;
    cursor: pointer;
}

.ai-icon-btn:hover {
    background: #333;
    color: #ccc;
}

.ai-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #2d5a3d;
    color: #d8f3e4;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ai-send-btn:hover {
    background: #3d7a52;
    color: #f0fdf4;
}

.ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-send-btn .ai-stop-icon {
    display: none;
}

.ai-send-btn.is-streaming {
    background: #6b3535;
    color: #ffe8e8;
}

.ai-send-btn.is-streaming:hover {
    background: #8a4545;
    color: #fff;
}

.ai-send-btn.is-streaming .ai-send-icon {
    display: none;
}

.ai-send-btn.is-streaming .ai-stop-icon {
    display: block;
}

.input-area textarea {
    width: 100%;
    height: 80px;
    padding: 8px;
    background: #3c3c3c;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ddd;
    resize: vertical;
    min-height: 60px;
    max-height: 160px;
    font-size: 13px;
    line-height: 1.4;
}

.input-area textarea:focus {
    outline: none;
    border-color: #0e639c;
}

.input-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.input-actions button {
    flex: 1;
    padding: 8px;
    background: #0e639c;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.input-actions button:hover { background: #1177bb; }

.input-actions button.secondary {
    flex: 0 0 auto;
    min-width: 64px;
    background: #3c3c3c;
}

.input-actions button.secondary:hover { background: #4c4c4c; }

.code-container {
    margin: 8px 0;
    border: 1px solid #444;
    border-radius: 4px;
    overflow: hidden;
}

.code-block {
    padding: 10px;
    background: #1a1a1a;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    color: #d4d4d4;
}

.code-container .copy-btn,
.code-container .execute-btn {
    padding: 6px 12px;
    border: none;
    font-size: 11px;
    cursor: pointer;
}

.code-container .copy-btn { background: #444; color: #ccc; }
.code-container .execute-btn { background: #0e639c; color: #fff; }

.ai-exec-result {
    margin: 8px 0 10px;
    border-radius: 8px;
    border: 1px solid #3c3c3c;
    overflow: hidden;
    font-size: 12px;
}

.ai-exec-result.is-ok {
    border-color: rgba(46, 160, 67, 0.45);
    background: rgba(46, 160, 67, 0.08);
}

.ai-exec-result.is-err {
    border-color: rgba(248, 81, 73, 0.45);
    background: rgba(248, 81, 73, 0.08);
}

.ai-exec-result__head {
    padding: 8px 12px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-exec-result.is-ok .ai-exec-result__head {
    color: #3fb950;
}

.ai-exec-result.is-err .ai-exec-result__head {
    color: #f85149;
}

.ai-exec-result__body {
    margin: 0;
    padding: 10px 12px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #c9d1d9;
    max-height: 160px;
    overflow: auto;
}

.ai-exec-result.is-ok .ai-exec-result__body:empty {
    display: none;
}
