:root {
  --ink: #1c2321;
  --paper: #f7f8f6;
  --panel: #ffffff;
  --line: #d8dcd8;
  --line-soft: #e7eae6;
  --accent: #0f6e63;
  --accent-hover: #0c5850;
  --accent-dim: #e4f0ee;
  --teal: #10b981;
  --warn: #c2410c;
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 9px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 24px;
  color: var(--accent);
  line-height: 1;
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: 0.2px; font-weight: 700; }
.tagline { margin: 2px 0 0; font-size: 13px; color: #5b625f; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* 状态指示器与呼吸灯 */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #555e5b;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f0f2f0;
}
.status-indicator .led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex: none;
}
.status-indicator.ready .led { background: var(--teal); }
.status-indicator.running .led {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  animation: pulse 1s infinite ease-in-out;
}
.status-indicator.error .led { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ghost-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
}
.ghost-link:hover { border-bottom-color: var(--accent); }

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.panel-toolbar {
  margin-bottom: 12px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.preset-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.preset-tab {
  padding: 8px 18px;
  font-size: 13.5px;
  background: var(--panel);
  border: none;
  border-right: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink);
  font-weight: 500;
  transition: all 0.15s ease;
}
.preset-tab:last-child { border-right: none; }
.preset-tab:hover:not(.is-active) { background: #f3f4f1; }
.preset-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.preset-desc {
  margin: 10px 0 0;
  font-size: 13px;
  color: #555e5b;
}

/* 自定义配置面板 */
.custom-panel {
  margin: 14px 0 6px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 22px;
}
.option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
}
.option span { font-weight: 500; }
.option select, .option input[type="text"], .option input[type="number"] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
}
.option select:focus, .option input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
.option-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.option-check.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.option-check input:disabled {
  cursor: not-allowed;
}
.option-check input {
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}
.option em {
  color: #717875;
  font-style: normal;
  font-size: 12px;
  display: block;
  margin-top: 2px;
}
.option-domain {
  grid-column: 1 / -1;
  background: #fbfbf9;
  padding: 12px;
  border-radius: 6px;
  border: 1px dashed var(--line);
}
.option-domain small {
  color: var(--warn);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

/* 高风险配置提醒条 */
.risk-warning-box {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--warn);
  line-height: 1.45;
}
.risk-warning-box strong { font-weight: 600; }

/* 编辑器工作区 */
.editors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 18px;
}
@media (max-width: 860px) {
  .editors { grid-template-columns: 1fr; }
}

.editor-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  background: #fafaf8;
}
.head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.tip-badge {
  font-size: 11px;
  font-weight: normal;
  color: #7a807c;
  background: #edf0ed;
  padding: 2px 7px;
  border-radius: 4px;
}
.editor-head .meta {
  font-weight: 400;
  color: #7a807c;
  font-family: var(--mono);
  font-size: 12px;
}

.textarea-wrap {
  position: relative;
  display: flex;
  flex: 1;
}
.textarea-wrap.is-dragover textarea {
  background: #ecfdf5;
  border-color: var(--accent);
}

textarea {
  width: 100%;
  min-height: 380px;
  padding: 14px 16px;
  border: none;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  outline: none;
  tab-size: 2;
}
textarea[readonly] { background: #fafaf8; color: #222; }

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fafaf8;
}

.primary-btn {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 22px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.5; cursor: default; }

.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 15px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s ease;
}
.ghost-btn:disabled { opacity: 0.45; cursor: default; }
.ghost-btn:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.ghost-btn:not(:disabled):active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.file-btn {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 15px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.15s ease;
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 统计面板 */
.stats-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stats-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-label {
  font-size: 12px;
  color: #717875;
}
.stats-val {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.stats-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
}
.stats-badge.grow {
  background: #fef3c7;
  color: #92400e;
}
.stats-badge.shrink {
  background: #d1fae5;
  color: #065f46;
}

/* 错误诊断框 */
.error-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--danger);
  font-family: var(--mono);
  white-space: pre-wrap;
  line-height: 1.5;
}

.disclaimer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: #7a807c;
  line-height: 1.6;
}
