/* AI 模型配置弹窗 */
.ai-config-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    padding: 16px;
}

.ai-config-overlay[hidden] {
    display: none !important;
}

.ai-config-modal {
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #1a1f26;
    border: 1px solid #30363d;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    color: #c9d1d9;
    font-size: 13px;
}

.ai-config-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
}

.ai-config-modal__title {
    font-size: 15px;
    font-weight: 600;
    color: #f0f3f6;
}

.ai-config-modal__close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.ai-config-modal__close:hover {
    background: #30363d;
    color: #fff;
}

.ai-config-tabs {
    display: flex;
    gap: 0;
    margin: 0 16px 12px;
    padding: 3px;
    background: #0d1117;
    border-radius: 8px;
    border: 1px solid #30363d;
}

.ai-config-tab {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ai-config-tab.is-active {
    background: #21262d;
    color: #f0f3f6;
    font-weight: 500;
}

.ai-config-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 12px;
}

.ai-config-panel[hidden] {
    display: none !important;
}

.ai-config-field {
    margin-bottom: 14px;
}

.ai-config-field label,
.ai-config-field .ai-config-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: #8b949e;
}

.ai-config-required {
    color: #f85149;
    margin-right: 2px;
}

.ai-config-field select,
.ai-config-field input[type="text"],
.ai-config-field input[type="password"] {
    width: 100%;
    padding: 9px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #e6edf3;
    font-size: 13px;
}

.ai-config-field select:focus,
.ai-config-field input:focus {
    outline: none;
    border-color: #388bfd;
}

.ai-config-field-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #6e7681;
    line-height: 1.45;
}

.ai-config-info {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(56, 139, 253, 0.08);
    border: 1px solid rgba(56, 139, 253, 0.25);
    border-radius: 8px;
    font-size: 11px;
    color: #79c0ff;
    line-height: 1.45;
}

.ai-config-info::before {
    content: 'ℹ';
    flex-shrink: 0;
    font-weight: 700;
}

.ai-config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.ai-config-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #8b949e;
    cursor: pointer;
    user-select: none;
}

.ai-config-toggle input {
    accent-color: #238636;
}

.ai-config-key-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.ai-config-key-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.ai-config-key-row .ai-config-key-input-wrap {
    flex: 1;
}

.ai-config-key-input-wrap input {
    width: 100%;
    padding-right: 36px;
}

.ai-config-key-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.ai-config-key-toggle:hover {
    color: #c9d1d9;
    background: rgba(177, 186, 196, 0.12);
}

.ai-config-key-toggle[hidden] {
    display: none !important;
}

.ai-config-key-toggle .ai-key-eye-closed {
    display: none;
}

.ai-config-key-toggle.is-visible .ai-key-eye-open {
    display: none;
}

.ai-config-key-toggle.is-visible .ai-key-eye-closed {
    display: block;
}

.ai-config-key-row input {
    flex: 1;
}

.ai-config-link-btn {
    flex-shrink: 0;
    padding: 0 12px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #21262d;
    color: #58a6ff;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.ai-config-link-btn:hover {
    background: #30363d;
    border-color: #484f58;
}

.ai-config-advanced {
    margin-top: 4px;
    border-top: 1px solid #21262d;
    padding-top: 10px;
}

.ai-config-advanced summary {
    list-style: none;
    cursor: pointer;
    font-size: 12px;
    color: #8b949e;
    user-select: none;
}

.ai-config-advanced summary::-webkit-details-marker {
    display: none;
}

.ai-config-advanced summary::before {
    content: '› ';
    display: inline-block;
    transition: transform 0.15s;
}

.ai-config-advanced[open] summary::before {
    transform: rotate(90deg);
}

.ai-config-advanced__inner {
    margin-top: 12px;
}

.ai-config-modal__foot {
    padding: 12px 16px 16px;
    border-top: 1px solid #21262d;
}

.ai-config-modal__foot .ai-config-field {
    margin-bottom: 10px;
}

.ai-config-submit {
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-radius: 8px;
    background: #f0f3f6;
    color: #0d1117;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.ai-config-submit:hover {
    background: #fff;
}

.ai-config-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-config-custom-model {
    margin-top: 8px;
}

.ai-config-custom-model[hidden] {
    display: none !important;
}

/* 头部当前模型摘要 */
.ai-config-summary {
    font-size: 11px;
    color: #6e7681;
    margin-top: 2px;
    line-height: 1.4;
    word-break: break-all;
}

.ai-config-summary.is-ready {
    color: #8b949e;
}

.ai-config-summary .ai-config-summary-model {
    color: #58a6ff;
}

/* ── 模型列表 ── */
.ai-config-modal--wide {
    max-width: 480px;
}

.ai-model-list-wrap {
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    background: #0d1117;
}

.ai-model-list-head,
.ai-model-list-row {
    display: grid;
    grid-template-columns: 1fr 88px 100px;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
}

.ai-model-list-head {
    font-size: 11px;
    color: #6e7681;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}

.ai-model-list-section-title {
    padding: 8px 12px 4px;
    font-size: 11px;
    color: #8b949e;
}

.ai-model-list-row {
    font-size: 12px;
    border-bottom: 1px solid #21262d;
}

.ai-model-list-row:last-child {
    border-bottom: none;
}

.ai-model-list-row.is-active {
    background: rgba(14, 99, 156, 0.1);
}

.ai-model-list-name {
    color: #e6edf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-model-list-prov {
    color: #8b949e;
    font-size: 11px;
}

.ai-model-list-ops {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.ai-model-op {
    padding: 3px 8px;
    border: 1px solid #30363d;
    border-radius: 4px;
    background: #21262d;
    color: #c9d1d9;
    font-size: 11px;
    cursor: pointer;
}

.ai-model-op:hover {
    background: #30363d;
}

.ai-model-op--danger {
    color: #f85149;
    border-color: rgba(248, 81, 73, 0.35);
}

.ai-model-op--danger:hover {
    background: rgba(248, 81, 73, 0.12);
}

.ai-model-list-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
    color: #6e7681;
    line-height: 1.5;
}

/* ── 通用确认 / 提示弹窗（AI 侧）── */
.copilot-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 110000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.58);
    padding: 16px;
}

.copilot-dialog-overlay[hidden] {
    display: none !important;
}

.copilot-dialog {
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #1a1f26;
    border: 1px solid #30363d;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    color: #c9d1d9;
    overflow: hidden;
}

.copilot-dialog--wide {
    max-width: 520px;
}

.copilot-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #21262d;
}

.copilot-dialog__title {
    font-size: 15px;
    font-weight: 600;
    color: #f0f3f6;
}

.copilot-dialog__close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
}

.copilot-dialog__close:hover {
    background: #30363d;
    color: #fff;
}

.copilot-dialog__body {
    padding: 14px 16px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
}

.copilot-dialog__text {
    margin: 0;
    color: #c9d1d9;
    white-space: pre-wrap;
}

.copilot-dialog__hint {
    margin: 0 0 10px;
    color: #8b949e;
    font-size: 12px;
}

.copilot-dialog__hint strong {
    color: #58a6ff;
}

.copilot-dialog__code {
    margin: 0;
    padding: 12px;
    max-height: 240px;
    overflow: auto;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.45;
    color: #e6edf3;
    white-space: pre-wrap;
    word-break: break-all;
}

.copilot-dialog__warn {
    margin: 10px 0 0;
    font-size: 11px;
    color: #e3b341;
}

.copilot-dialog__skip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: #8b949e;
    cursor: pointer;
    user-select: none;
}

.copilot-dialog__skip input {
    margin: 0;
    accent-color: #238636;
    cursor: pointer;
}

.copilot-dialog__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 1px solid #21262d;
}

.copilot-dialog__btn {
    min-width: 72px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
}

.copilot-dialog__btn--ghost {
    background: #21262d;
    border-color: #30363d;
    color: #c9d1d9;
}

.copilot-dialog__btn--ghost:hover {
    background: #30363d;
}

.copilot-dialog__btn--primary {
    background: #238636;
    color: #fff;
}

.copilot-dialog__btn--primary:hover {
    background: #2ea043;
}

.copilot-dialog__btn--danger {
    background: #da3633;
}

.copilot-dialog__btn--danger:hover {
    background: #f85149;
}

/* ── 通用确认 / 提示弹窗（AI 侧）── */
.copilot-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 110000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.58);
    padding: 16px;
}

.copilot-dialog-overlay[hidden] {
    display: none !important;
}

.copilot-dialog {
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #1a1f26;
    border: 1px solid #30363d;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    color: #c9d1d9;
    overflow: hidden;
}

.copilot-dialog--wide {
    max-width: 520px;
}

.copilot-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #21262d;
}

.copilot-dialog__title {
    font-size: 15px;
    font-weight: 600;
    color: #f0f3f6;
}

.copilot-dialog__close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
}

.copilot-dialog__close:hover {
    background: #30363d;
    color: #fff;
}

.copilot-dialog__body {
    padding: 14px 16px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
}

.copilot-dialog__text {
    margin: 0;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}

.copilot-dialog__hint {
    margin: 0 0 10px;
    color: #8b949e;
    font-size: 12px;
}

.copilot-dialog__hint strong {
    color: #58a6ff;
}

.copilot-dialog__code {
    margin: 0 0 10px;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.45;
    color: #e6edf3;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow: auto;
}

.copilot-dialog__warn {
    margin: 0;
    font-size: 11px;
    color: #e3b341;
}

.copilot-dialog__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px 14px;
    border-top: 1px solid #21262d;
}

.copilot-dialog__btn {
    min-width: 72px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
}

.copilot-dialog__btn--ghost {
    background: #21262d;
    border-color: #30363d;
    color: #c9d1d9;
}

.copilot-dialog__btn--ghost:hover {
    background: #30363d;
}

.copilot-dialog__btn--primary {
    background: #238636;
    color: #fff;
}

.copilot-dialog__btn--primary:hover {
    background: #2ea043;
}

.copilot-dialog__btn--danger {
    background: #da3633;
}

.copilot-dialog__btn--danger:hover {
    background: #f85149;
}
