﻿* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #faf5ee;
  color: #2b1d18;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ftest-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ftest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: #fff;
  border-bottom: 1px solid #d8d4cc;
}

.ftest-header h1 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 1.1rem;
  color: #a6331b;
}

.ftest-header nav a {
  margin-right: 1rem;
  color: #82655a;
  text-decoration: none;
  font-size: 0.88rem;
}
.ftest-header nav a:hover { color: #a6331b; }

.ftest-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: #faf9f7;
  border-bottom: 1px solid #e0dcd4;
}

.btn {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
}

.btn-primary {
  background: #a6331b;
  color: #fff;
  border-color: #a6331b;
}

.btn-warn {
  color: #8b2e2e;
  border-color: #c99;
  background: #fff5f5;
}

.btn-warn:hover {
  background: #fde8e8;
}

#ftestStatus {
  flex: 1;
  font-size: 0.82rem;
  color: #666;
  min-width: 200px;
}

.ftest-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  background: #faf9f7;
}

.ftest-tab {
  padding: 0.45rem 1rem;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #eee;
  cursor: pointer;
  font-size: 0.85rem;
}

.ftest-tab.active {
  background: #fff;
  font-weight: 600;
  color: #a6331b;
}

.ftest-main {
  flex: 1;
  padding: 1rem;
  min-height: 0;
  overflow: auto;
}

.ftest-panel {
  display: none;
  background: #fff;
  border: 1px solid #e0dcd4;
  border-radius: 0 10px 10px 10px;
  padding: 1rem;
  min-height: 400px;
}

.ftest-panel.active {
  display: block;
}

.matrix-wrap {
  overflow: auto;
  max-height: 75vh;
}

.matrix-table {
  border-collapse: collapse;
  font-size: 0.72rem;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid #ddd;
  padding: 0.25rem 0.35rem;
  min-width: 52px;
  max-width: 88px;
  text-align: center;
  vertical-align: middle;
}

.matrix-table th {
  background: #f0ede8;
  position: sticky;
  top: 0;
  z-index: 2;
}

.matrix-table th.row-head {
  left: 0;
  z-index: 3;
  text-align: right;
  min-width: 72px;
}

.matrix-table td.row-head {
  background: #f0ede8;
  font-weight: 600;
  text-align: right;
  position: sticky;
  left: 0;
  z-index: 1;
}

.matrix-table td.self {
  background: #e8f5e9;
}

.matrix-table td.has-rel {
  background: #fff8e6;
}

.matrix-table td.src-explicit {
  background: #e8f5e9;
}

.matrix-table td.src-inferred {
  background: #fff8e6;
}

.matrix-table td.src-none {
  background: #f0f0f0;
  color: #888;
}

.matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.matrix-mode {
  font-size: 0.82rem;
  cursor: pointer;
}

.tag-explicit, .tag-inferred, .tag-none {
  display: inline-block;
  padding: 0 0.35rem;
  border-radius: 3px;
  font-size: 0.72rem;
  margin: 0 0.15rem;
}

.tag-explicit { background: #e8f5e9; }
.tag-inferred { background: #fff8e6; }
.tag-none { background: #f0f0f0; }

.reasoning-panel {
  margin-bottom: 0.75rem;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: #faf9f7;
}

.reasoning-panel.hidden {
  display: none;
}

.reasoning-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: #a6331b;
}

.reasoning-panel pre {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.matrix-stats {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: #666;
}

.family-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.family-card {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 0.75rem;
  background: #faf8f5;
  font-size: 0.82rem;
}

.family-card h4 {
  margin: 0 0 0.35rem;
  color: #a6331b;
}

.family-card .tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #e8f5e9;
  margin-right: 0.25rem;
}

.family-card .tag.divorced {
  background: #fce8e8;
}

.tree-section {
  margin-top: 1rem;
}

.tree-section h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: #333;
}

.tree-canvas-wrap {
  overflow: auto;
  border: 1px solid #e0dcd4;
  border-radius: 8px;
  background: #faf8f5;
  margin-bottom: 1rem;
}

.tree-canvas-wrap canvas {
  display: block;
}

.legend {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 1rem;
}

.legend span {
  margin-right: 1rem;
}

.legend .line-solid::before {
  content: "—";
  color: #b38f59;
  margin-right: 0.2rem;
}

.legend .line-dash::before {
  content: "- -";
  color: #999;
  margin-right: 0.2rem;
}

.legend .line-adopt::before {
  content: "—";
  color: #c45c26;
  margin-right: 0.2rem;
}

.ai-log-dock {
  flex-shrink: 0;
  border-top: 2px solid #a6331b;
  background: #1e1e1e;
  color: #e8e8e8;
  display: flex;
  flex-direction: column;
  height: 220px;
  min-height: 120px;
  max-height: 45vh;
}

.ai-log-dock.collapsed {
  height: 36px;
  min-height: 36px;
}

.ai-log-dock.collapsed .ai-log-body {
  display: none;
}

.ai-log-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: #2d2d2d;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.ai-log-header .title {
  flex: 1;
  font-weight: 600;
  color: #9fdf9f;
}

.ai-log-header .btn {
  background: #444;
  color: #eee;
  border-color: #555;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
}

.ai-log-body {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0.75rem;
}

.ai-log-body pre {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

.families-toolbar {
  margin-bottom: 0.75rem;
}

.families-placeholder {
  color: #888;
  font-size: 0.88rem;
  padding: 1rem;
  text-align: center;
  border: 1px dashed #ccc;
  border-radius: 8px;
}

.refine-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.refine-modal.hidden {
  display: none;
}

.refine-dialog {
  background: #fff;
  border-radius: 12px;
  width: min(640px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.refine-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e8e4dc;
}

.refine-dialog-head h2 {
  margin: 0;
  font-size: 1rem;
  color: #a6331b;
}

.refine-close {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
}

.refine-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
}

.refine-tab {
  padding: 0.35rem 0.85rem;
  border: 1px solid #ddd;
  border-radius: 8px 8px 0 0;
  background: #f5f3ef;
  cursor: pointer;
  font-size: 0.82rem;
}

.refine-tab.active {
  background: #fff;
  border-bottom-color: #fff;
  color: #a6331b;
  font-weight: 600;
}

.refine-body {
  flex: 1;
  overflow: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e8e4dc;
}

.refine-hint {
  font-size: 0.78rem;
  color: #777;
  margin: 0 0 0.5rem;
}

.refine-messages {
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  background: #faf9f7;
  border: 1px solid #e8e4dc;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.refine-msg {
  margin: 0.35rem 0;
  line-height: 1.45;
}

.refine-msg.user {
  color: #333;
}

.refine-msg.assistant {
  color: #a6331b;
}

.refine-msg.err {
  color: #b33;
}

.refine-composer textarea {
  width: 100%;
  resize: vertical;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

.refine-busy {
  font-size: 0.8rem;
  color: #856404;
  margin: 0.5rem 0 0;
}

.refine-busy.hidden {
  display: none;
}

.refine-dialog-foot {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e8e4dc;
}

#btnOpenRefine:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 第一步：文字抽取三表 */
.step1-main {
  padding: 1rem;
  overflow: auto;
}

.step1-input h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #a6331b;
}

#familyText {
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 200px;
}

.step1-results.hidden {
  display: none;
}

.step1-results {
  margin-top: 1.5rem;
}

.result-block {
  margin-bottom: 1.25rem;
}

.result-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: #333;
}

.result-block h3 .stat {
  font-weight: normal;
  color: #888;
  font-size: 0.85rem;
}

.data-table-wrap {
  overflow: auto;
  border: 1px solid #e0dcd4;
  border-radius: 8px;
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  border: 1px solid #e8e4dc;
  padding: 0.4rem 0.55rem;
  text-align: left;
}

.data-table th {
  background: #f0ede8;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:nth-child(even) td {
  background: #faf9f7;
}

.empty-table {
  padding: 1rem;
  color: #888;
  margin: 0;
  text-align: center;
}

.json-raw {
  margin-top: 1rem;
  font-size: 0.82rem;
}

.json-raw pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 0.75rem;
  border-radius: 8px;
  overflow: auto;
  max-height: 280px;
  font-size: 0.72rem;
}

.warnings {
  color: #856404;
  background: #fff8e6;
  border: 1px solid #e6d9a8;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-top: 0.75rem;
}

.warnings.hidden {
  display: none;
}

.ftest-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  background: #faf9f7;
  border-bottom: 1px solid #e0dcd4;
}

.step-panel {
  display: none;
  padding: 1rem;
  overflow: auto;
  flex: 1;
}

.step-panel.active {
  display: block;
}

.step-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#btnToStep2 {
  margin-top: 1rem;
}

.step2-meta {
  font-size: 0.85rem;
  color: #444;
  margin: 0.75rem 0;
}

.step2-meta.hidden {
  display: none;
}

#jsonInput {
  width: 100%;
  box-sizing: border-box;
  font-family: Consolas, monospace;
  font-size: 0.8rem;
  padding: 0.65rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  resize: vertical;
}

.tree-preview {
  margin-top: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  height: min(70vh, 600px);
  background: #faf8f5;
}

.tree-preview.hidden {
  display: none;
}

.tree-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.tree-preview.tower-preview-embed {
  height: min(85vh, 920px);
}

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-tag.tag-current {
  background: #e8f5e9;
  color: #2e6b3e;
  border: 1px solid #a5d6a7;
}

.status-tag.tag-blood {
  background: #f5f5f5;
  color: #666;
  border: 1px dashed #bbb;
}

/* 流水线分步展示 */
.pipeline-steps {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pipeline-steps.hidden {
  display: none;
}

.pipeline-step {
  border: 1px solid #d8e4dc;
  border-radius: 10px;
  background: #fafcf9;
  overflow: hidden;
}

.pipeline-step summary {
  cursor: pointer;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #a6331b;
  background: #eef6f0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pipeline-step summary::-webkit-details-marker {
  display: none;
}

.pipeline-step summary::before {
  content: "▶";
  font-size: 0.65rem;
  color: #888;
  transition: transform 0.15s;
}

.pipeline-step[open] summary::before {
  transform: rotate(90deg);
}

.pipeline-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #a6331b;
  color: #fff;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.pipeline-step .step-summary-text {
  font-weight: normal;
  font-size: 0.8rem;
  color: #666;
  margin-left: auto;
}

.pipeline-step-body {
  padding: 0.75rem 0.9rem 1rem;
  border-top: 1px solid #e0ece4;
}

.pipeline-step-body .data-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.cell-text-preview {
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #333;
}

.path-names {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.8rem;
  color: #444;
}

.gen-group {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.gen-group strong {
  color: #a6331b;
}

.step5-hint {
  font-size: 0.85rem;
  color: #555;
  margin: 0;
}

.input-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.rec-hint {
  font-size: 0.78rem;
  color: #856404;
  margin: 0.35rem 0 0;
}

.rec-hint.hidden {
  display: none;
}

.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem;
  background: #f0f7f2;
  border: 1px solid #c8dccf;
  border-radius: 8px;
}

.json-edit-panel {
  margin-bottom: 1rem;
}

.json-edit-panel.hidden {
  display: none;
}

#jsonEdit {
  width: 100%;
  box-sizing: border-box;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 0.78rem;
  padding: 0.65rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  resize: vertical;
  min-height: 200px;
}

/* 四表下方：指令修改 JSON */
.table-command-dock {
  margin: 1.25rem 0 1rem;
  padding: 1rem 1rem 1.1rem;
  background: linear-gradient(180deg, #f8faf9 0%, #eef5f0 100%);
  border: 2px solid #3d7a55;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(45, 90, 60, 0.12);
  position: sticky;
  bottom: 0.5rem;
  z-index: 5;
}

.table-command-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: #2d5a3c;
}

.table-command-messages {
  max-height: 140px;
  overflow-y: auto;
  margin: 0.5rem 0 0.65rem;
  padding: 0.5rem 0.65rem;
  background: #fff;
  border: 1px solid #d4e4d9;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.table-command-messages:empty {
  display: none;
}

.table-command-msg {
  margin: 0.25rem 0;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.table-command-msg.user {
  background: #e8f4ec;
  color: #1a4a2a;
}

.table-command-msg.assistant {
  background: #f5f5f5;
  color: #444;
}

.table-command-msg.err {
  background: #fde8e8;
  color: #a33;
}

#tableCommandInstruction {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #9cb8a8;
  border-radius: 8px;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}

.table-command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
}

.table-command-busy {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #3d7a55;
  font-weight: 500;
}

.table-command-busy.hidden {
  display: none;
}

.ftest-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.draft-status {
  font-size: 0.78rem;
  color: #5a7a62;
  margin-right: 0.25rem;
}

.draft-status:empty {
  display: none;
}

.btn.recording {
  background: #fde8e8;
  border-color: #e88;
  color: #a33;
}

