/* 范本模板库 */
.tpl-shell { padding: 8px 0 52px; }
.tpl-filter {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.tpl-search { display: flex; gap: 10px; }
.tpl-search input {
  flex: 1; min-width: 0; height: 50px; padding: 0 16px 0 42px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font-size: 15px; outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2369776f' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
  background-repeat: no-repeat; background-position: 15px center;
}
.tpl-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 107, 91, .12); }
.tpl-search .btn { height: 50px; padding: 0 26px; border-radius: 12px; font-size: 15px; }
.tpl-hot { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tpl-hot button {
  border: 0; background: transparent; color: var(--primary); cursor: pointer;
  font-size: 13px; padding: 2px 4px; font-family: inherit;
}
.tpl-hot button:hover { text-decoration: underline; }
.tpl-row {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.tpl-row-label { flex: none; width: 42px; color: var(--muted); font-size: 13px; line-height: 30px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 99px; padding: 5px 13px; font-size: 13px; cursor: pointer;
  font-family: inherit; line-height: 1.4; transition: .15s ease;
}
.tpl-chip:hover { border-color: var(--primary); color: var(--primary); }
.tpl-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tpl-result-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  margin: 4px 2px 14px; font-size: 13px; color: var(--muted);
}
.tpl-result-head b { color: var(--ink); font-size: 15px; }
.tpl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tpl-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
  transition: .18s ease; min-width: 0;
}
.tpl-card:hover { border-color: #b9cec3; box-shadow: var(--shadow); transform: translateY(-2px); }
.tpl-card.hide { display: none; }
.tpl-badge-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tpl-type {
  font-size: 12px; color: var(--primary); background: var(--primary-light);
  padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}
.tpl-cat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tpl-card h3 { margin: 0; font-size: 16px; line-height: 1.45; }
.tpl-card .tpl-sum {
  margin: 0; font-size: 13px; color: var(--muted); line-height: 1.65;
  flex: 1; min-height: 43px;
}
.tpl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-tags span { font-size: 11.5px; color: var(--muted); background: #f2f5f1; padding: 2px 7px; border-radius: 5px; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.tpl-actions .btn { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }
.tpl-actions .btn-em { background: var(--primary); color: #fff; }
.tpl-actions .btn-em:hover { background: var(--primary-dark); color: #fff; }
.tpl-actions .fmt { font-size: 10.5px; opacity: .7; margin-left: 3px; }
.tpl-empty { display: none; text-align: center; padding: 64px 0; color: var(--muted); }
.tpl-empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.tpl-note {
  margin-top: 24px; padding: 16px 18px; border: 1px dashed var(--line);
  border-radius: 12px; background: #fbfaf3; color: var(--muted);
  font-size: 13px; line-height: 1.85;
}
.tpl-note b { color: var(--ink-2); }
@media (max-width: 980px) {
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .tpl-search { flex-direction: column; }
  .tpl-search .btn { width: 100%; }
  .tpl-grid { grid-template-columns: 1fr; }
  .tpl-row { flex-direction: column; gap: 6px; }
  .tpl-row-label { line-height: 1.4; }
  .tpl-result-head { flex-direction: column; gap: 4px; }
}

/* 原版下载与在线编辑器 */
.tpl-card-downloads {
  display: flex; align-items: center; gap: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted);
}
.tpl-card-downloads > span { flex: none; }
.tpl-card-downloads > div { display: flex; flex-wrap: wrap; gap: 5px 12px; }
.tpl-dl { margin-left: auto; flex: none; color: var(--primary); font-size: 11.5px; white-space: nowrap; }
.tpl-dl[hidden] { display: none !important; }
.tpl-dl b { font-size: 12px; }
.tpl-original-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.tpl-original-link:hover { text-decoration: underline; }
.tpl-editor-open { overflow: hidden; }
.tpl-editor[hidden], .tpl-table-edit[hidden], .tpl-text-edit[hidden] { display: none !important; }
.tpl-editor {
  position: fixed; inset: 0; z-index: 8000; display: flex; align-items: center;
  justify-content: center; padding: 20px; font-family: inherit;
}
.tpl-editor-mask { position: absolute; inset: 0; background: rgba(16, 32, 27, .68); backdrop-filter: blur(4px); }
.tpl-editor-panel {
  position: relative; width: min(1100px, 100%); height: min(900px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden; background: #fff;
  border: 1px solid rgba(255, 255, 255, .55); border-radius: 18px;
  box-shadow: 0 30px 90px rgba(4, 25, 18, .32);
}
.tpl-editor-header {
  flex: none; display: flex; justify-content: space-between; gap: 20px;
  padding: 20px 24px 17px; border-bottom: 1px solid var(--line); background: #fbfdfb;
}
.tpl-editor-kicker { display: block; margin-bottom: 4px; color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: 2px; }
.tpl-editor-header h2 { margin: 0; color: var(--ink); font-size: 21px; line-height: 1.4; }
.tpl-editor-header p { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.tpl-editor-close {
  flex: none; align-self: flex-start; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted);
  font: 26px/30px Arial, sans-serif; cursor: pointer;
}
.tpl-editor-close:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.tpl-editor-main { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px; }
.tpl-editor-toolbar { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 17px; }
.tpl-editor-toolbar > label { flex: 1; min-width: 0; }
.tpl-editor-toolbar label > span, .tpl-text-edit > label {
  display: block; margin-bottom: 7px; color: var(--ink-2); font-size: 13px; font-weight: 700;
}
.tpl-editor-toolbar input {
  width: 100%; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); background: #fff; font: 15px inherit; outline: none;
}
.tpl-editor-toolbar input:focus, .tpl-text-edit textarea:focus, .tpl-table-row input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 107, 91, .1);
}
.tpl-editor-tool-buttons { display: flex; flex: none; gap: 8px; }
.tpl-editor-tool-buttons .btn { height: 42px; padding: 0 15px; border-radius: 9px; font-size: 13px; }
.tpl-text-edit textarea {
  display: block; width: 100%; min-height: 480px; box-sizing: border-box; resize: vertical;
  padding: 18px; border: 1px solid var(--line); border-radius: 11px; outline: none;
  color: #26332e; background: #fff; font: 14px/1.85 "Microsoft YaHei", "PingFang SC", sans-serif;
  white-space: pre-wrap; tab-size: 4;
}
.tpl-table-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tpl-table-edit-head > span { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.tpl-table-edit-head small { display: block; margin-top: 4px; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.tpl-table-edit-head .btn { flex: none; height: 34px; padding: 0 12px; font-size: 12px; }
.tpl-table-rows {
  overflow-x: auto; padding: 10px; border: 1px solid var(--line); border-radius: 11px;
  background: #f7faf8;
}
.tpl-table-row { display: flex; align-items: center; gap: 6px; min-width: 100%; margin-bottom: 6px; }
.tpl-table-row:last-child { margin-bottom: 0; }
.tpl-table-row.has-cells { width: max-content; }
.tpl-table-row input {
  flex: 1 0 105px; width: 105px; min-width: 0; height: 36px; box-sizing: border-box;
  padding: 0 9px; border: 1px solid #dce5e0; border-radius: 6px; outline: none;
  background: #fff; color: var(--ink); font: 12.5px "Microsoft YaHei", "PingFang SC", sans-serif;
}
.tpl-table-row.is-text input { flex: 1 1 auto; width: auto; }
.tpl-row-delete {
  flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: #9a6c67; font: 20px/28px Arial, sans-serif; cursor: pointer;
}
.tpl-row-delete:hover { color: #a33127; background: #fbecea; }
.tpl-editor-footer {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 15px 24px; border-top: 1px solid var(--line); background: #fbfdfb;
}
.tpl-editor-status-wrap { min-width: 0; }
.tpl-editor-status-wrap > b { display: block; margin-bottom: 3px; color: var(--ink-2); font-size: 13px; }
#tplEditorStatus { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.tpl-editor-error { display: none; margin-top: 4px; color: #b42318; font-size: 12px; }
.tpl-editor-error.show { display: block; }
.tpl-editor-downloads { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.tpl-editor-downloads .btn { height: 38px; padding: 0 17px; border-radius: 8px; font-size: 13px; }
.tpl-editor-downloads .btn:disabled { opacity: .55; cursor: wait; }
@media (max-width: 700px) {
  .tpl-editor { padding: 0; }
  .tpl-editor-panel { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
  .tpl-editor-header { padding: 15px 16px 13px; }
  .tpl-editor-header h2 { font-size: 18px; }
  .tpl-editor-header p { font-size: 11.5px; }
  .tpl-editor-main { padding: 15px 16px; }
  .tpl-editor-toolbar { align-items: stretch; flex-direction: column; }
  .tpl-editor-tool-buttons .btn { flex: 1; }
  .tpl-text-edit textarea { min-height: 52vh; padding: 13px; font-size: 13px; }
  .tpl-editor-footer { align-items: stretch; flex-direction: column; gap: 10px; padding: 12px 16px; }
  .tpl-editor-downloads { justify-content: flex-start; }
  .tpl-editor-downloads .btn { flex: 1; min-width: 62px; }
}
