* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6f8; color: #1c2330; font-size: 14px; line-height: 1.6;
}
.hidden { display: none !important; }

header {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid #e3e6ec;
  padding: 10px 20px; position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 4px; }
.tab-btn {
  border: none; background: none; padding: 6px 14px; font-size: 14px;
  border-radius: 6px; cursor: pointer; color: #555;
}
.tab-btn.active { background: #1c2330; color: #fff; }
.key-warning { color: #b45309; font-size: 12px; margin-left: auto; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 120px; }

h2 { font-size: 16px; margin: 18px 0 10px; }
h3 { font-size: 14px; margin: 12px 0 8px; }
.card {
  background: #fff; border: 1px solid #e3e6ec; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px;
}
.muted { color: #7a8194; font-size: 12px; }
button {
  font-family: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid #cdd3de; background: #fff; color: #1c2330;
  padding: 5px 12px; border-radius: 6px;
}
button:hover { background: #f0f2f6; }
button.primary { background: #1c2330; color: #fff; border-color: #1c2330; }
button.primary:hover { background: #333e54; }
button.danger { color: #b91c1c; border-color: #e5b4b4; }
button.small { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], textarea, select {
  font-family: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid #cdd3de; border-radius: 6px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
label { font-size: 12px; color: #555; }

/* ---------- 连连看矩阵(竖列) ---------- */
.matrix-grid { display: flex; align-items: stretch; overflow-x: auto; padding: 4px 0; }
.matrix-col {
  flex: 1; min-width: 175px; max-width: 280px;
  background: #fafbfc; border: 1px solid #e6e9f0; border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.col-sep {
  align-self: center; flex: 0 0 auto; font-size: 22px; font-weight: 700;
  color: #b6bccb; padding: 0 6px; user-select: none;
}
.col-head { text-align: center; border-bottom: 1px solid #eceef4; padding-bottom: 8px; }
.col-head .slot-name { font-weight: 700; font-size: 14px; }
.col-head .db-anchor { font-size: 12px; margin-top: 2px; }
.db-anchor.ok { color: #15803d; }
.db-anchor.placeholder { color: #b45309; }
.chips-v { display: flex; flex-direction: column; gap: 6px; }
.chips-v .chip { display: block; text-align: center; }
.chip {
  border: 1px solid #cdd3de; border-radius: 10px; padding: 5px 10px;
  cursor: pointer; user-select: none; background: #fff; font-size: 13px;
  transition: all .1s; word-break: break-all;
}
.chip:hover { border-color: #1c2330; }
.chip.selected { background: #1c2330; color: #fff; border-color: #1c2330; }
.chip.selected::after { content: " ✓"; font-weight: 700; }
.chip .orig-badge {
  display: inline-block; background: #dbeafe; color: #1d4ed8;
  font-size: 10px; line-height: 1.4; padding: 0 5px; border-radius: 6px;
  margin-right: 4px; vertical-align: 1px;
}
.chip.selected .orig-badge { background: #3b4a66; color: #bfdbfe; }
.chip.wildcard { border-style: dashed; color: #7c3aed; border-color: #c4b5fd; }
.chip.wildcard.selected { background: #7c3aed; color: #fff; }
.chip.add-new { border-style: dashed; color: #7a8194; }
.chip.add-new:hover { color: #1c2330; }
.mini-tag { font-size: 10px; padding: 0 5px; border-radius: 6px; margin-left: 4px; white-space: nowrap; }
.mini-tag.exists { background: #eef1f6; color: #7a8194; }
.mini-tag.isnew { background: #dcfce7; color: #166534; }
.chip .star { color: #d97706; margin-right: 2px; }
.chip .cross { color: #dc2626; margin-right: 2px; }
.chip.selected .star, .chip.selected .cross { color: #fde68a; }

/* 公式栏 */
.formula-bar {
  background: #fffbe8; border: 1px solid #eadfa0;
  border-radius: 10px; padding: 10px 14px; margin-top: 12px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 14px;
}
/* 工作台悬浮公式操作栏:始终可见,选完即点,无需滚动 */
.formula-bar.fixed {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 1068px; z-index: 60; margin: 0;
  box-shadow: 0 8px 28px rgba(28, 35, 48, .22);
}
.formula-text { flex: 1; min-width: 200px; font-weight: 500; word-break: break-all; }
.formula-text .empty-slot { color: #b0a86e; }

/* 暂存区 / 结果 */
.staged-item, .result-card { border: 1px solid #e3e6ec; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fafbfc; }
.staged-item { display: flex; align-items: center; gap: 10px; }
.staged-item .formula { flex: 1; word-break: break-all; }
.result-card { background: #fff; }
.result-card h4 { font-size: 14px; margin-bottom: 6px; }
.plan-section { margin: 8px 0; }
.plan-section .plan-label { font-weight: 600; font-size: 12px; color: #4b5563; }
.wildcard-fill {
  background: #f3efff; border: 1px dashed #c4b5fd; border-radius: 8px;
  padding: 8px 10px; margin: 6px 0; font-size: 13px;
}
.status-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #eef1f6; color: #555; }
.status-badge.queued { background: #fef3c7; color: #92400e; }
.status-badge.generating { background: #dbeafe; color: #1d4ed8; }
.status-badge.error { background: #fee2e2; color: #b91c1c; }
.status-badge.generated { background: #dcfce7; color: #166534; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eef0f4; vertical-align: top; }
th { color: #7a8194; font-weight: 500; font-size: 12px; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 8px; margin-right: 3px; white-space: nowrap; }
.tag.original { background: #dbeafe; color: #1d4ed8; }
.tag.advantage { background: #fef3c7; color: #92400e; }
.tag.constraint { background: #fee2e2; color: #b91c1c; }
.tag.ai_invented { background: #f3efff; color: #6d28d9; }

/* 确认页 */
.confirm-slot { border: 1px solid #e3e6ec; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.param-edit-row { display: flex; gap: 6px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.param-edit-row input[type=text] { flex: 1; min-width: 160px; }
.tag-toggle { font-size: 12px; display: inline-flex; align-items: center; gap: 2px; cursor: pointer; white-space: nowrap; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }

/* 库管理:库 Tab 切换 */
.lib-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.lib-tab {
  border: 1px solid #cdd3de; border-radius: 8px; padding: 6px 12px;
  cursor: pointer; background: #fff; font-size: 13px; user-select: none;
}
.lib-tab:hover { border-color: #1c2330; }
.lib-tab.active { background: #1c2330; color: #fff; border-color: #1c2330; }
.lib-tab .cnt { opacity: .65; font-size: 12px; margin-left: 4px; }
.lib-tab.special { border-style: dashed; }

/* 创意列表展开 */
.creative-full {
  background: #fafbfc; border: 1px solid #e8eaf0; border-radius: 8px;
  padding: 10px 12px; white-space: pre-wrap; word-break: break-word;
}
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e1;
  border-top-color: #1d4ed8; border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2330; color: #fff; padding: 8px 18px; border-radius: 8px;
  font-size: 13px; z-index: 100; max-width: 80vw;
}

/* 确认页(竖列编辑态) */
.confirm-col-tools { display: flex; flex-direction: column; gap: 4px; }
.confirm-param {
  background: #fff; border: 1px solid #e3e6ec; border-radius: 8px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; font-size: 12px;
}
.confirm-param .tag-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 640px) {
  .matrix-grid { flex-direction: column; }
  .matrix-col { max-width: none; }
  .col-sep { padding: 2px 0; }
}
