/* ═══════════════════════════════════════════════════════
   GeoAgent — 白色主题 类 GPT 前端样式
   ═══════════════════════════════════════════════════════ */

/* ────── CSS 变量 ────── */
:root {
    --bg-body:        #ffffff;
    --bg-sidebar:     #f7f7f8;
    --bg-chat:        #ffffff;
    --bg-bubble-user: #3b82f6;
    --bg-bubble-ai:   #f4f4f5;
    --bg-tool-card:   #f9fafb;
    --bg-input-row:   #ffffff;
    --bg-input:       #f4f4f5;
    --bg-hover:       #ececf1;
    --border:         #e5e5ea;
    --border-light:   #eaeaef;
    --text-primary:   #1d1d1f;
    --text-secondary: #6b6b80;
    --text-muted:     #9a9aaf;
    --accent:         #3b82f6;
    --accent-hover:   #2563eb;
    --accent-light:   #eff6ff;
    --success:        #16a34a;
    --success-bg:     #f0fdf4;
    --error:          #dc2626;
    --error-bg:       #fef2f2;
    --warning:        #d97706;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.04);
    --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg:      0 4px 12px rgba(0,0,0,0.08);
    --radius:         16px;
    --radius-sm:      10px;
    --radius-xs:      6px;
    --sidebar-width:  300px;
    --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                      'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei',
                      'Helvetica Neue', Arial, sans-serif;
    --font-mono:      'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono',
                      'Noto Sans SC', monospace;
}

/* ────── 全局重置 ────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ────── 应用布局 ────── */
.app { display: flex; height: 100vh; }

/* ═══════════════ 侧边栏 ═══════════════ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    user-select: none;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 18px 14px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.section-label {
    padding: 18px 18px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* Agent 列表 */
.agent-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px;
}

.agent-item {
    padding: 10px 12px;
    margin: 3px 0;
    border-radius: var(--radius-xs);
    cursor: default;
    transition: background 0.12s;
    border: 1px solid transparent;
}

.agent-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.agent-item .agent-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-mono);
}

.agent-item .agent-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 3px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-item .agent-badge {
    display: inline-block;
    font-size: 0.62rem;
    padding: 2px 7px;
    border-radius: 10px;
    margin-top: 5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-plot    { background: #eff6ff; color: #2563eb; }
.badge-process { background: #f0fdf4; color: #16a34a; }
.badge-query   { background: #fffbeb; color: #d97706; }

.loading-hint {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* 侧边栏操作 */
.sidebar-actions {
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.15s;
    background: var(--bg-body);
    color: var(--text-primary);
}

.btn:hover { background: var(--bg-hover); }

.btn-upload {
    color: var(--accent);
    display: block;
    border-color: var(--accent);
    background: var(--accent-light);
}

.btn-upload:hover { background: #dbeafe; }

.btn-reset { color: var(--text-secondary); }
.btn-reset:hover { color: var(--error); border-color: var(--error); background: var(--error-bg); }

.upload-status {
    padding: 4px 12px 10px;
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.upload-status .success { color: var(--success); }
.upload-status .error   { color: var(--error); }

.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.visit-info {
    margin-top: 4px;
    opacity: 0.85;
}

/* 版本号：页脚最后一行，低调但可辨识 */
.app-version {
    margin-top: 6px;
    font-size: 0.64rem;
    letter-spacing: 0.02em;
    opacity: 0.55;
    font-variant-numeric: tabular-nums;
}

/* 反馈邮箱：侧边栏底部常驻；欢迎页那份让窄屏（侧边栏隐藏）也看得到 */
.feedback-info {
    margin-top: 4px;
}

.feedback-info a,
.welcome-feedback a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.feedback-info a:hover,
.welcome-feedback a:hover {
    text-decoration: underline;
}

.welcome-feedback {
    margin-top: 10px;
}


/* 已上传文件列表（同名覆盖，列表让用户看得见当前实际有什么） */
.uploaded-files {
    padding: 0 18px;
}

.uploaded-title {
    font-size: 0.66rem;
    color: var(--text-muted);
    margin: 6px 0 4px;
    cursor: pointer;
    user-select: none;
}

.uploaded-title:hover {
    color: var(--text);
}

.uploaded-caret {
    opacity: 0.7;
}

.uploaded-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uploaded-size {
    flex: none;
    opacity: 0.7;
}

.replaced-tag {
    font-size: 0.66rem;
    opacity: 0.8;
}

/* ═══════════════ 主聊天区 ═══════════════ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    min-width: 0;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px;
    scroll-behavior: smooth;
}

/* ────── 欢迎消息 ────── */
.welcome-msg {
    max-width: 700px;
    margin: 80px auto 0;
    text-align: center;
}

.welcome-msg h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.welcome-msg > p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 6px;
    line-height: 1.6;
}

.example-prompts {
    margin-top: 24px;
    text-align: left;
}

.example-prompts > p {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.prompt-chip {
    display: block;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: var(--radius-sm);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.84rem;
    transition: all 0.15s;
    line-height: 1.55;
}

.prompt-chip:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ────── 消息气泡 ────── */
.message {
    max-width: 780px;
    margin: 0 auto 20px;
    animation: msgIn 0.25s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 用户消息 — 右对齐，蓝底白字 */
.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .bubble {
    background: var(--bg-bubble-user);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: var(--radius) var(--radius) 6px var(--radius);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 82%;
    box-shadow: var(--shadow-sm);
}

/* 助手消息 */
.message-assistant .bubble {
    padding: 4px 0;
    line-height: 1.72;
    color: var(--text-primary);
}

.message-assistant .bubble p            { margin-bottom: 0.7em; }
.message-assistant .bubble p:last-child { margin-bottom: 0; }

.message-assistant .bubble code {
    background: #f1f1f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: #d946ef;
}

.message-assistant .bubble pre {
    background: #1e1e2e;
    color: #e4e4f0;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    font-size: 0.84em;
    line-height: 1.55;
}

.message-assistant .bubble pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

.message-assistant .bubble ul,
.message-assistant .bubble ol { padding-left: 1.6em; margin: 8px 0; }
.message-assistant .bubble li  { margin-bottom: 5px; }

.message-assistant .bubble table {
    border-collapse: collapse; margin: 12px 0; font-size: 0.86em; width: 100%;
}
.message-assistant .bubble th,
.message-assistant .bubble td {
    border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.message-assistant .bubble th { background: var(--bg-sidebar); font-weight: 600; }
.message-assistant .bubble a  { color: var(--accent); text-decoration: underline; }

/* ────── 工具调用卡片 ────── */
.tool-card {
    margin: 10px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tool-card);
    overflow: hidden;
    animation: msgIn 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.tool-card-header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}

.tool-card-header:hover { background: var(--bg-hover); }

.tool-card-header .icon      { font-size: 1rem; flex-shrink: 0; }
.tool-card-header .tool-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
}

.tool-card-header .tool-status {
    margin-left: auto;
    font-size: 0.74rem;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.tool-card-header .chevron {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.tool-card.open .tool-card-header .chevron { transform: rotate(180deg); }

.tool-card-body {
    display: none;
    padding: 0 16px 16px;
    font-size: 0.78rem;
}

.tool-card.open .tool-card-body { display: block; }

.tool-card-body .params {
    background: #f1f1f4;
    padding: 12px 14px;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.76em;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    max-height: 220px;
    overflow-y: auto;
    line-height: 1.5;
}

.tool-card-body .result-msg {
    padding: 6px 0;
    font-weight: 500;
}

.tool-card-body .result-msg.success { color: var(--success); }
.tool-card-body .result-msg.error   { color: var(--error); }

.tool-card-body .result-output {
    color: var(--text-muted);
    font-size: 0.78em;
    margin-top: 6px;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 160px;
    overflow-y: auto;
    background: #fafafa;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    line-height: 1.45;
}

/* 图片展示 */
.tool-card-body img {
    max-width: 100%;
    border-radius: var(--radius-xs);
    margin-top: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: box-shadow 0.18s, transform 0.18s;
}

.tool-card-body img:hover {
    box-shadow: var(--shadow-lg);
    transform: scale(1.01);
}

/* 工具卡状态动画 */
.tool-card .status-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.tool-card .status-ok  { color: var(--success); }
.tool-card .status-err { color: var(--error); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ────── 思考中指示器 ────── */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 12px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.thinking-dots { display: flex; gap: 4px; }

.thinking-dots span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.7); }
    40%           { opacity: 1;   transform: scale(1.25); }
}

/* ────── 图片内联展示 ────── */
.image-block {
    margin: 14px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    box-shadow: var(--shadow-sm);
}

.image-block img {
    width: 100%;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

.image-block img:hover { opacity: 0.92; }

.image-block .image-caption {
    padding: 8px 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    word-break: break-all;
}

.image-block .img-err {
    padding: 16px;
    color: var(--error);
    font-size: 0.82rem;
}

/* ────── 图片模态框 ────── */
.image-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.image-modal.show { display: flex; }

.image-modal img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

/* ═══════════════ 输入区 ═══════════════ */
.input-area {
    padding: 12px 24px 18px;
    background: var(--bg-chat);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 780px;
    margin: 0 auto;
    background: var(--bg-input-row);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.input-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.input-row textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font);
    line-height: 1.55;
    resize: none;
    max-height: 200px;
    padding: 7px 0;
}

.input-row textarea::placeholder { color: var(--text-muted); }

.input-row button {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

#sendBtn {
    background: var(--accent);
    color: #fff;
}

#sendBtn:hover { background: var(--accent-hover); transform: scale(1.04); }
#sendBtn:disabled { background: #d4d4dc; cursor: not-allowed; transform: none; }

#stopBtn {
    background: var(--error);
    color: #fff;
}

#stopBtn:hover { background: #b91c1c; transform: scale(1.04); }

.input-hint {
    /* 快捷键提示 + ICP 备案号同一行，整行居中 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 780px;
    margin-left: auto; margin-right: auto;
}

.input-hint .hint-sep {
    opacity: 0.5;
}

.input-hint .icp-link {
    color: inherit;
    text-decoration: none;
}

.input-hint .icp-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ═══════════════ 模式切换器 ═══════════════ */
.mode-switcher {
    display: flex;
    gap: 4px;
    padding: 0 18px 14px;
}

.mode-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 500;
    background: var(--bg-body);
    color: var(--text-secondary);
    transition: all 0.15s;
}

.mode-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ═══════════════ RAG 控件区 ═══════════════ */
.rag-section {
    border-top: 1px solid var(--border);
}

.rag-controls {
    padding: 6px 18px 10px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.control-row label {
    white-space: nowrap;
    font-weight: 500;
}

.control-row span {
    font-weight: 700;
    color: var(--accent);
    min-width: 20px;
    text-align: center;
}

#topKSlider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 4px 0 10px;
}

#topKSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

#topKSlider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.btn-rebuild {
    width: 100%;
    margin-top: 6px;
    color: var(--warning);
    border-color: var(--warning);
    background: #fffbeb;
    font-size: 0.76rem;
}

.btn-rebuild:hover {
    background: #fef3c7;
    border-color: #b45309;
}

.btn-rebuild:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.rag-stats {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 6px 0 2px;
    text-align: center;
}

.rag-stats span {
    font-weight: 600;
    color: var(--accent);
}

/* ═══════════════ 检索工具列表 ═══════════════ */
.retrieved-tools {
    padding: 4px 10px;
    max-height: 260px;
    overflow-y: auto;
}

.retrieved-tool-item {
    padding: 6px 8px;
    margin: 3px 0;
    border-radius: var(--radius-xs);
    background: var(--bg-tool-card);
    border: 1px solid var(--border-light);
}

.retrieved-tool-item .tool-name {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
}

.retrieved-tool-item .tool-desc {
    font-size: 0.66rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

/* ────── 响应式 ────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .messages  { padding: 12px; }
    .input-area { padding: 8px 12px 12px; }
    .message { max-width: 100%; }
    .input-row { max-width: 100%; }
    .welcome-msg { margin-top: 40px; }
}

/* ────── 滚动条 ────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4dc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0bc; }

/* ══════════ 管线阶段卡片（stage_complete / skip / retry） ══════════
   pipeline 模式下每条 stage_complete 渲染成一张卡片：阶段名 + 阶段总结 + 产物清单。 */
.stage-card {
    margin: 14px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--accent-light);
    overflow: hidden;
    animation: msgIn 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.stage-card-header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.18);
}

.stage-card-header .stage-icon { font-size: 1rem; flex-shrink: 0; }

.stage-card-header .stage-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
    flex: 1;
}

.stage-card-header .stage-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.stage-card-body { padding: 12px 16px; }

.stage-card-body .stage-summary {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-primary);
}

.stage-card-body .stage-summary p   { margin: 0 0 6px; }
.stage-card-body .stage-summary ol,
.stage-card-body .stage-summary ul  { margin: 4px 0; padding-left: 20px; }
.stage-card-body .stage-summary li  { margin: 2px 0; }

.stage-artifacts {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(59, 130, 246, 0.25);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stage-artifact {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.78rem;
}

.stage-artifact .stage-artifact-key {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--accent);
}

.stage-artifact code {
    color: var(--text-secondary);
    word-break: break-all;
    font-size: 0.76rem;
}

/* 跳过 / 重试：轻量提示，不占整张卡片 */
.stage-note {
    margin: 8px 0;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--border);
    background: var(--bg-tool-card);
    border-radius: 4px;
}

.stage-note-retry {
    border-left-color: #f59e0b;
    color: #92400e;
    background: #fffbeb;
}

/* ─────────────────── 阶段闸门（step 模式） ─────────────────── */
/* 复用 .stage-card 的外形；这里只补“表单 + 操作按钮”的部分。
   卡片内容全部由后端载荷生成，这里不写死任何阶段/参数。 */
.gate-card {
    border-color: #f59e0b;
    background: #fffdf5;
}

.gate-card-failed {
    border-color: #ef4444;
    background: #fff7f7;
}

.gate-card.gate-resolved {
    opacity: 0.78;
}

.gate-status:empty { display: none; }
.gate-status {
    margin-bottom: 8px;
    font-size: 0.82rem;
}

.gate-done { color: #047857; font-weight: 600; }
.gate-warn { color: #b45309; font-weight: 600; }

.gate-error {
    margin: 6px 0 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.gate-next {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px dashed rgba(245, 158, 11, 0.5);
    border-radius: 8px;
    background: #fffdf8;
}

.gate-next-title {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.gate-next-tools {
    margin-bottom: 8px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.9;
}

.gate-next-tools code {
    display: inline-block;
    margin: 0 4px 2px 0;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-tool-card, #f3f4f6);
    font-size: 0.72rem;
}

.gate-param-tool + .gate-param-tool {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.gate-param-tool-name {
    font-family: var(--font-mono, monospace);
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.gate-param-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0;
    font-size: 0.82rem;
}

.gate-param-label {
    min-width: 56px;
    color: var(--text-secondary);
}

.gate-param-row input[type="number"],
.gate-param-row select {
    width: 96px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.82rem;
}

.gate-param-row input:disabled,
.gate-param-row select:disabled {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.gate-param-bounds {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.gate-param-fixed {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 0.74rem;
}

.gate-param-free code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-tool-card);
    font-size: 0.74rem;
}

.gate-param-free-note {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.gate-note-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gate-note-row input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}

.gate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.gate-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.gate-btn:hover:not(:disabled) {
    background: var(--bg-hover, #f3f4f6);
    border-color: var(--accent);
}

.gate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gate-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 600;
}

.gate-btn-primary:hover:not(:disabled) {
    background: var(--accent-hover, #2563eb);
}

.gate-btn-danger {
    color: #b91c1c;
    border-color: #fca5a5;
}

.gate-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gate-jump select {
    max-width: 150px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
}

/* 侧栏：闸门模式开关 */
.gate-section { margin-top: 4px; }

.gate-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-primary);
    cursor: pointer;
}

.gate-hint {
    margin: 4px 0 8px 22px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
