#template_preview_view_mount,
#template_preview_view_mount > .template_preview_view,
.template_preview_page {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

#template_preview_view_mount > .template_preview_view {
  position: static;
  inset: auto;
}

.template_preview_page {
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid #d8e0ec;
}

.template_preview_side {
  display: flex;
  flex: 0 0 320px;
  flex-direction: column;
  gap: 14px;
  width: 320px;
  min-width: 320px;
  padding: 18px;
  overflow: auto;
  border-right: 1px solid #d8e0ec;
  background: #ffffff;
}

.template_preview_side_head {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_side_head h1 {
  margin: 0;
  color: #172033;
  font-size: 18px;
  font-weight: 780;
  letter-spacing: 0;
}

.template_preview_side_head span,
.template_preview_hint,
.template_preview_case_summary {
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

.template_preview_label {
  display: grid;
  gap: 8px;
  color: #172033;
  font-size: 13px;
  font-weight: 720;
}

.template_preview_label select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-weight: 520;
}

.template_preview_picker_button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 50px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.template_preview_picker_button:hover {
  border-color: #9db7db;
  background: #f8fbff;
}

.template_preview_picker_button strong,
.template_preview_picker_button small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_picker_button strong {
  font-size: 13px;
  font-weight: 760;
}

.template_preview_picker_button small {
  color: #64748b;
  font-size: 12px;
  font-weight: 520;
}

.template_preview_actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.template_preview_actions button {
  min-height: 34px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  background: #f8fafc;
  color: #172033;
  font: inherit;
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
}

.template_preview_actions button:hover {
  background: #edf4ff;
  border-color: #9db7db;
}

.template_preview_case_summary {
  display: grid;
  gap: 8px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid #dbe4f0;
  background: #f8fafc;
}

.template_preview_case_summary strong {
  display: block;
  overflow: hidden;
  color: #172033;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_case_summary span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template_preview_hint.is-error {
  color: #b42318;
}

.template_preview_hint.is-success {
  color: #067647;
}

.template_preview_main {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.template_preview_main > [data-role="template_preview_mount"] {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.template_preview_case_picker_dialog {
  position: fixed;
  inset: 0;
  z-index: 1700;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .32);
}

.template_preview_case_picker_dialog[hidden] {
  display: none;
}

.template_preview_case_picker_panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(820px, calc(100vw - 36px));
  height: min(680px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
}

.template_preview_case_picker_panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_case_picker_panel h2 {
  margin: 0;
  color: #172033;
  font-size: 16px;
  font-weight: 780;
}

.template_preview_case_picker_panel header span {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.template_preview_case_picker_close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  font-size: 18px;
  cursor: pointer;
}

.template_preview_case_picker_body {
  min-height: 0;
  overflow: hidden;
}

.template_preview_case_picker_body .pmt_binding_workspace {
  height: 100%;
  min-height: 0;
}

.template_preview_field_detail_dialog {
  position: fixed;
  inset: 0;
  z-index: 1850;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .38);
}

.template_preview_field_detail_dialog[hidden] {
  display: none;
}

.template_preview_field_detail_panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(620px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
}

.template_preview_field_detail_panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_field_detail_panel p {
  margin: 0 0 4px;
  color: #c4312b;
  font-size: 12px;
  font-weight: 760;
}

.template_preview_field_detail_panel h2 {
  margin: 0;
  color: #172033;
  font-size: 17px;
  font-weight: 780;
}

.template_preview_field_detail_actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template_preview_field_detail_panel header button {
  display: inline-grid;
  place-items: center;
  width: auto;
  min-width: 32px;
  height: 32px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
}

.template_preview_field_detail_panel header button[aria-label] {
  width: 32px;
  padding: 0;
  font-size: 18px;
}

.template_preview_field_detail_panel header button:hover {
  border-color: #9db7db;
  background: #f8fbff;
}

.template_preview_field_detail_panel header .template_preview_edit_toggle {
  height: 32px;
  border-color: transparent;
}

.template_preview_field_detail_panel header .template_preview_edit_toggle:hover {
  border-color: transparent;
  background: transparent;
}

.template_preview_field_detail_list {
  display: grid;
  gap: 0;
  min-height: 0;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
}

.template_preview_field_detail_list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_field_detail_list dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 680;
}

.template_preview_field_detail_list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 13px;
  font-weight: 650;
}

.template_preview_field_detail_list .is-value-row dd {
  display: grid;
  gap: 8px;
}

.template_preview_field_detail_list textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
}

.template_preview_field_detail_list textarea:focus {
  border-color: #2563eb;
  outline: 2px solid rgba(37, 99, 235, .16);
}

.template_preview_field_detail_list small {
  color: #b42318;
  font-size: 12px;
  font-weight: 680;
}

.template_preview_write_prompt_dialog {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
}

.template_preview_write_prompt_dialog[hidden] {
  display: none;
}

.template_preview_write_prompt_panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(560px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
}

.template_preview_write_prompt_panel > header,
.template_preview_write_prompt_footer {
  padding: 14px 16px;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_write_prompt_panel > header p {
  margin: 0 0 4px;
  color: #c4312b;
  font-size: 12px;
  font-weight: 760;
}

.template_preview_write_prompt_panel > header h2 {
  margin: 0;
  color: #172033;
  font-size: 16px;
  font-weight: 780;
}

.template_preview_write_prompt_body {
  display: grid;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.template_preview_write_prompt_body > p {
  margin: 0;
  color: #172033;
  font-size: 14px;
  font-weight: 680;
}

.template_preview_write_prompt_body dl {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid #e5edf6;
}

.template_preview_write_prompt_body div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #e5edf6;
}

.template_preview_write_prompt_body div:last-child {
  border-bottom: 0;
}

.template_preview_write_prompt_body dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 680;
}

.template_preview_write_prompt_body dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 13px;
  font-weight: 650;
}

.template_preview_write_prompt_footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #e5edf6;
  border-bottom: 0;
}

.template_preview_write_prompt_footer button {
  min-height: 34px;
  border: 1px solid #cbd7e6;
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: #172033;
  font: inherit;
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
}

.template_preview_write_prompt_footer button:hover {
  border-color: #9db7db;
  background: #f8fbff;
}

.template_preview_write_prompt_footer button.is-primary {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.template_preview_case_picker_body .pmt_case_binding_case_list {
  min-height: 0;
}

@media (max-width: 980px) {
  .template_preview_page {
    flex-direction: column;
  }

  .template_preview_side {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-height: 270px;
    border-right: 0;
    border-bottom: 1px solid #d8e0ec;
  }
}
