.template_preview_module,
.template_preview_shell {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.template_preview_shell {
  flex-direction: column;
  background: #f7f8fb;
  border-left: 1px solid #dde5f0;
}

.template_preview_toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid #dde5f0;
  background: #ffffff;
}

.template_preview_toolbar_title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.template_preview_toolbar_title strong {
  color: #172033;
  font-size: 15px;
  font-weight: 760;
}

.template_preview_toolbar_title span,
.template_preview_status {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

.template_preview_status {
  overflow: hidden;
  text-overflow: ellipsis;
}

.template_preview_surface {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

.template_preview_empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  color: #64748b;
}

.template_preview_empty_title {
  color: #172033;
  font-size: 22px;
  font-weight: 760;
}

.template_preview_empty_text {
  font-size: 13px;
}

.template_preview_document {
  box-sizing: border-box;
  width: min(920px, 100%);
  min-height: 1040px;
  margin: 0 auto;
  padding: 0;
  background: #ffffff;
  border: 1px solid #d8e0ec;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  color: #1f2937;
}

.template_preview_document:not(.is-rendered-template) {
  padding: 18px;
}

.template_preview_document_head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
  text-align: center;
}

.template_preview_document_head h1 {
  margin: 0;
  color: #111827;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 24px;
  font-weight: 760;
  letter-spacing: 0;
}

.template_preview_document_head p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.template_preview_metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.template_preview_metric {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #dbe4f0;
  background: #f8fafc;
}

.template_preview_metric span {
  color: #64748b;
  font-size: 12px;
}

.template_preview_metric strong {
  min-width: 0;
  overflow: hidden;
  color: #172033;
  font-size: 16px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_section {
  margin-top: 22px;
}

.template_preview_section h2 {
  margin: 0 0 10px;
  color: #172033;
  font-size: 15px;
  font-weight: 760;
}

.template_preview_field_group_head,
.template_preview_field_group_title,
.template_preview_field_module_title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.template_preview_field_group_head {
  margin-bottom: 12px;
}

.template_preview_field_group_head h2 {
  margin: 0;
  color: #c4312b;
}

.template_preview_field_group_head span,
.template_preview_field_group_title span,
.template_preview_field_module_title span {
  flex: none;
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
}

.template_preview_field_group {
  margin-top: 14px;
}

.template_preview_field_group_title {
  padding: 8px 0;
  border-bottom: 1px solid #dbe4f0;
}

.template_preview_field_group_title strong {
  color: #172033;
  font-size: 18px;
  font-weight: 780;
}

.template_preview_field_module {
  margin-top: 10px;
  border: 1px solid #dbe4f0;
  background: #ffffff;
}

.template_preview_field_module_title {
  min-height: 36px;
  padding: 8px 12px;
  border-bottom: 1px solid #dbe4f0;
  background: #f8fafc;
}

.template_preview_field_module_title strong {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_party_list,
.template_preview_representative_list,
.template_preview_field_table {
  display: grid;
  border: 1px solid #dbe4f0;
}

.template_preview_field_module .template_preview_field_table {
  border: 0;
}

.template_preview_party_row,
.template_preview_representative_row,
.template_preview_field_row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(90px, 0.55fr) minmax(100px, 0.6fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  border-bottom: 1px solid #e6edf6;
}

.template_preview_party_row:last-child,
.template_preview_representative_row:last-child,
.template_preview_field_row:last-child {
  border-bottom: 0;
}

.template_preview_party_row strong,
.template_preview_party_row span,
.template_preview_party_row em,
.template_preview_representative_row strong,
.template_preview_representative_row span,
.template_preview_representative_row em,
.template_preview_representative_row small,
.template_preview_field_row strong,
.template_preview_field_row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_party_row strong {
  color: #172033;
  font-size: 13px;
}

.template_preview_party_row span,
.template_preview_party_row em {
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.template_preview_representative_row {
  grid-template-columns: minmax(100px, 0.7fr) minmax(170px, 1fr) minmax(90px, 0.55fr) minmax(150px, 0.9fr);
}

.template_preview_field_row {
  grid-template-columns: minmax(180px, 0.52fr) minmax(260px, 1fr);
}

.template_preview_field_name_cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.template_preview_field_detail_btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.template_preview_field_detail_btn:hover {
  border-color: #2563eb;
  background: #dbeafe;
}

.template_preview_representative_row strong {
  color: #172033;
  font-size: 13px;
}

.template_preview_representative_row span,
.template_preview_representative_row em,
.template_preview_representative_row small {
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.template_preview_representative_row small {
  color: #334155;
  font-weight: 650;
}

.template_preview_field_row {
  grid-template-columns: minmax(180px, 0.7fr) minmax(320px, 1.3fr);
}

.template_preview_field_header {
  min-height: 32px;
  background: #f8fafc;
}

.template_preview_field_header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.template_preview_field_row strong {
  color: #172033;
  font-size: 13px;
  font-weight: 700;
}

.template_preview_field_row span {
  color: #b42318;
  font-size: 12px;
  font-weight: 650;
}

.template_preview_document.is-rendered-template {
  width: 760px;
  max-width: none;
  font-family: "Songti SC", "SimSun", serif;
}

.template_preview_tiptap_doc {
  box-sizing: border-box;
  width: 100%;
  min-height: 1040px;
  padding: 46px 54px;
  color: #1f2937;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  white-space: normal;
}

.template_preview_tiptap_doc p {
  margin: 0;
  color: #1f2937;
  min-height: 1.45em;
}

.template_preview_tiptap_doc h1,
.template_preview_tiptap_doc h2,
.template_preview_tiptap_doc h3,
.template_preview_tiptap_doc h4,
.template_preview_tiptap_doc h5,
.template_preview_tiptap_doc h6 {
  margin: 0.4em 0;
  color: #1f2937;
  font-weight: 800;
  line-height: 1.2;
  text-align: inherit;
}

.template_preview_tiptap_doc h1 {
  font-size: 30px;
}

.template_preview_tiptap_doc h2 {
  font-size: 24px;
}

.template_preview_tiptap_doc h3 {
  font-size: 20px;
}

.template_preview_tiptap_doc table {
  margin: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.template_preview_tiptap_doc col[data-template-preview-column="label"] {
  width: 4cm;
}

.template_preview_tiptap_doc th,
.template_preview_tiptap_doc td {
  position: relative;
  box-sizing: border-box;
  min-width: 1em;
  border: 1px solid #cfd8e3;
  padding: 7px 10px;
  vertical-align: middle;
}

.template_preview_tiptap_doc th > p,
.template_preview_tiptap_doc td > p {
  margin: 0;
}

.template_preview_tiptap_doc ul,
.template_preview_tiptap_doc ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}

.template_preview_rendered_empty {
  color: #64748b !important;
}

.template_preview_node_anchor {
  scroll-margin-block: 96px;
  transition: background-color 180ms ease, box-shadow 180ms ease;
}

.template_preview_field_hotspot {
  border-radius: 3px;
  background: rgba(219, 234, 254, 0.42);
  box-shadow: inset 0 -1px 0 rgba(37, 99, 235, 0.45);
  cursor: text;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}

.template_preview_field_hotspot:hover,
.template_preview_field_hotspot:focus-visible {
  background: rgba(191, 219, 254, 0.78);
  box-shadow: inset 0 -2px 0 #2563eb;
  outline: none;
}

.template_preview_node_anchor.has-template-field-hotspot {
  cursor: text;
}

.template_preview_node_anchor.has-template-field-hotspot:hover {
  background-color: rgba(239, 246, 255, 0.72);
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.42);
}

.template_preview_node_anchor.is-template-field-focus,
.template_preview_field_hotspot.is-template-field-focus {
  background-color: rgba(255, 244, 184, 0.72) !important;
  box-shadow: inset 3px 0 0 #f59e0b;
}

.template_preview_node_anchor.is-template-field-focus-primary,
.template_preview_field_hotspot.is-template-field-focus-primary {
  position: relative;
  z-index: 1;
  outline: 2px solid rgba(37, 99, 235, 0.78);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .template_preview_surface {
    padding: 14px;
  }

  .template_preview_document {
    min-height: 760px;
    padding: 32px 24px;
  }

  .template_preview_metrics {
    grid-template-columns: 1fr;
  }
}
