* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: linear-gradient(135deg, #e6f2ff 0%, #ffffff 100%);
  color: #1f2937;
}

/* Custom Scrollbars (global) */
:root{
  --sb-track: #eef6ff;    /* 滚动条轨道 */
  --sb-thumb: #cfe6ff;    /* 滚动条拇指 */
  --sb-thumb-hover: #9cc8ff; /* 悬停颜色 */
}
/* Firefox */
* { scrollbar-color: var(--sb-thumb) var(--sb-track); scrollbar-width: thin; }
/* WebKit (Chromium/Edge/Safari) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--sb-track); border-radius: 8px; }
*::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); border-radius: 8px; border: 2px solid var(--sb-track); }
*::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
*::-webkit-scrollbar-corner { background: transparent; }
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.header { text-align: center; color: #0f172a; margin-bottom: 32px; }
.header h1 { font-size: 28px; margin: 8px 0; }
.header p { color: #475569; }
.header .subnote { color: #6b7280; font-size: 12px; margin-top: 4px; }
.header .subnote a { color: #1e90ff; text-decoration: none; font-weight: 600; }
.header .subnote a:hover { color: #1778d6; text-decoration: underline; }
.header .github-link { display: flex; align-items: center; justify-content: center; gap: 6px; }
.header .github-link svg { color: #6b7280; }

.main-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 24px; /* 顶部稍大，整体更靠下 */
  box-shadow: 0 12px 24px rgba(30, 144, 255, 0.12);
  border: 1px solid #e5f1ff;
}

 .config-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.config-header h2 { margin: 0; font-size: 18px; color: #0f172a; }

/* 统一二级与三级标题字号与样式 */
.test-section h2 { margin: 12px 0 18px; font-size: 18px; color: #0f172a; }
.column h3 { margin: 16px 0 16px; color: #0f172a; font-size: 18px; }

/* 分区之间增加垂直间距 */
.test-section { margin-top: 36px; }
.config-section { margin-bottom: 36px; }

.input-row { margin-top: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-weight: 600; color: #334155; }
.input-group input, .input-group select {
  padding: 12px 14px; border: 1.5px solid #cfe6ff; border-radius: 10px; font-size: 15px; outline: none; transition: border-color .2s ease;
}
.input-group input:focus, .input-group select:focus { border-color: #1e90ff; }

/* Password input wrapper */
.password-input-wrapper { position: relative; display: flex; align-items: center; }
.password-input-wrapper input { padding-right: 40px; flex: 1; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: #6b7280; padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; z-index: 10; }
.password-toggle:hover { color: #1e90ff; background: #f8fbff; }
.password-toggle:focus { outline: 2px solid #1e90ff; outline-offset: 1px; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0 24px; }
.btn-group { display: flex; gap: 10px; }
.btn { padding: 10px 16px; border: none; border-radius: 8px; cursor: pointer; background: #f1f5f9; color: #0f172a; font-weight: 600; }
.btn:hover { background: #e2e8f0; }
.btn-primary { background: #1e90ff; color: #fff; }
.btn-primary:hover { background: #1778d6; }
.btn-secondary { background: #e7f2ff; color: #0f172a; border: 1px solid #cfe6ff; }
.btn-secondary:hover { background: #d9ecff; }

.test-section h2 { margin: 8px 0; }
.muted { color: #64748b; margin: 6px 0 18px; }

/* segmented control for test type */
.segmented { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.seg-btn { border: 1px solid #cfe6ff; background: #ffffff; color: #0f172a; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.seg-btn:hover { background: #f4f9ff; }
.seg-btn.active { background: #1e90ff; color: #ffffff; border-color: #1e90ff; }

/* user input textarea */
.input-textarea { width: 100%; padding: 12px 14px; border: 1.5px solid #cfe6ff; border-radius: 10px; font-size: 15px; line-height: 1.6; resize: vertical; min-height: 80px; }
.input-textarea:focus { outline: none; border-color: #1e90ff; }

.split-columns { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; margin-top: 12px; }
.split-columns > .column { min-width: 0; overflow: hidden; }
@media (max-width: 900px) { .split-columns { grid-template-columns: 1fr; } }

.column h3 { margin: 8px 0; color: #0f172a; }

.blocks-container, .timeline { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card, .code-block { background: #ffffff; border: 1px solid #e5f1ff; border-radius: 12px; padding: 14px; position: relative; max-width: 100%; }
.card .title, .code-block .title { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 10px; letter-spacing: .2px; }

.code-block pre, .card pre { margin: 0; white-space: pre; overflow-x: auto; max-width: 100%; font-family: ui-monospace, monospace; font-size: 13px; line-height: 1.6; color: #0b2542; background: #f8fbff; border: 1px solid #e5f1ff; border-radius: 8px; padding: 10px; }

.copy-btn { position: absolute; right: 10px; top: 10px; font-size: 12px; padding: 4px 8px; border-radius: 6px; background: #ffffff; border: 1px solid #cfe6ff; cursor: pointer; }
.copy-btn:hover { background: #f0f7ff; }

.error-message { color: #dc2626; margin-top: 12px; }
.error-inline { background: #fff1f2; border: 1px solid #fecdd3; color: #b91c1c; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.error-inline pre { font-family: ui-monospace, monospace; font-size: 13px; }
.info-inline { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.success-message { color: #059669; margin-top: 8px; display: none; }
.subheading { margin: 10px 0; color: #0f172a; }

/* Timeline message styles */
.message { border-left: 4px solid #cfe6ff; padding-left: 10px; }
.message.user { border-left-color: #1e90ff; }
.message.assistant { border-left-color: #22c55e; }
.message.tool { border-left-color: #7c3aed; }
.message .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: #334155; font-size: 12px; }
.message .role { font-weight: 700; }
.message .label { opacity: .8; }

/* waiting inline loader under latest message */
.waiting-inline { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 4px; padding-left: 10px; }
.waiting-inline .label { color: #64748b; font-size: 12px; user-select: none; }
.waiting-inline .dots { display: inline-flex; align-items: center; gap: 6px; }
.waiting-inline .dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; animation: dotPulse 1.2s ease-in-out infinite; }
.waiting-inline .dot:nth-child(1){ animation-delay: 0s; }
.waiting-inline .dot:nth-child(2){ animation-delay: .15s; }
.waiting-inline .dot:nth-child(3){ animation-delay: .3s; }

@keyframes dotPulse {
  0%, 100% { background: #cbd5e1; transform: scale(.85); }
  50% { background: #475569; transform: scale(1); }
}

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 1000; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-content { background: #ffffff; width: 92%; max-width: 860px; margin: 0; padding: 24px 24px 28px; border-radius: 14px; box-shadow: 0 10px 24px rgba(30,144,255,0.18); border: 1px solid #e5f1ff; max-height: 82vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-header h2 { margin: 0; }
.close { color: #64748b; font-size: 24px; font-weight: 700; cursor: pointer; line-height: 20px; }
.close:hover { color: #0f172a; }

.config-modal-body { display: grid; grid-template-columns: 1fr 0.55fr; gap: 16px; flex: 1; min-height: 0; }
@media (max-width: 900px) { .config-modal-body { grid-template-columns: 1fr; } }
.modal-left, .modal-right { min-width: 0; }
.modal-left { overflow: auto; }
.modal-right { display: flex; flex-direction: column; min-height: 0; }
.modal-right .config-list { flex: 1; min-height: 0; overflow: auto; max-height: none; }
@media (max-width: 900px) { .modal-right .config-list { max-height: 45vh; } }

.config-list { max-height: 300px; overflow-y: auto; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.config-item { padding: 12px; border: 1px solid #e5f1ff; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: #fbfdff; }
.config-item:hover { background: #f4f9ff; }
.config-info { flex: 1; }
.config-name { font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.config-url { color: #475569; font-size: 12px; word-break: break-all; }
.config-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { padding: 6px; background: #ffffff; border: 1px solid #cfe6ff; color: #0f172a; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f0f7ff; }
.star-config { color: #94a3b8; }
.star-config:hover { color: #fbbf24; background: #fff7e6; border-color: #fde68a; }
.star-config.starred { color: #f59e0b; background: #fff7e6; border-color: #fde68a; }
.delete-config { position: relative; padding: 6px; color: #94a3b8; border-color: #cfe6ff; background: #ffffff; width: auto; height: auto; }
.delete-config:hover { background: #f8fbff; color: #ef4444; }
.delete-config svg { width: 16px; height: 16px; display: block; }
.delete-config .q-badge { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; color: #ffffff; font-size: 9px; line-height: 12px; display: none; align-items: center; justify-content: center; transform: translate(25%,25%); }
.delete-config.confirm { color: #ef4444; border-color: #fecaca; background: #fff5f5; }
.delete-config.confirm .q-badge { display: inline-flex; }

/* 默认标识徽章（可用于名称右侧） */
.badge-default { display: inline-flex; align-items: center; gap: 4px; background: #fff7e6; color: #b45309; border: 1px solid #fde68a; border-radius: 999px; padding: 0 6px; font-size: 11px; line-height: 18px; margin-left: 6px; }

/* modal inputs spacing */
.modal .input-group { margin-bottom: 12px; }

/* modal actions */
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

/* App alert modal (custom prompt) */
.app-modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 1100; align-items: center; justify-content: center; }
.app-modal.open { display: flex; }
.app-modal .box { width: 92%; max-width: 420px; margin: 0; padding: 18px; border-radius: 12px; background: #ffffff; border: 1px solid #e5f1ff; box-shadow: 0 10px 24px rgba(30,144,255,0.18); animation: modalPop .18s ease-out; max-height: 70vh; overflow: auto; }
.app-modal .title { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.app-modal .content { color: #334155; line-height: 1.6; white-space: pre-wrap; }
.app-modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.app-modal .actions .btn { padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; border: 1px solid #cfe6ff; background: #e7f2ff; color: #0f172a; }
.app-modal .actions .btn:hover { background: #d9ecff; }
.app-modal .actions .btn-primary { background: #1e90ff; color: #fff; border-color: #1e90ff; }
.app-modal .actions .btn-primary:hover { background: #1778d6; }

@keyframes modalPop { from { transform: translateY(4px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
