/* 模板工作区：固定导航、规则分区与明确的保存位置。 */
main[data-page="templates"] { max-width: 1680px; padding: 30px 32px 64px; }
[data-page="templates"] .page-head h1 { font-size: 32px; }
[data-page="templates"] .page-head .sub { max-width: none; font-size: 16px; }
.tpl-page { grid-template-columns: 224px minmax(0, 1fr); gap: 24px; align-items: start; }
.tpl-sidebar { position: sticky; top: 24px; display: grid; gap: 24px; min-width: 0; max-height: calc(100dvh - 48px); overflow-y: auto; }
.tpl-sidebar .tpl-list { position: static; display: grid; gap: 6px; }
.tpl-nav-title { display: flex; justify-content: space-between; align-items: center; padding: 0 9px; font-size: 16px; font-weight: 600; color: var(--text-3); margin: 0 0 4px; }
.tpl-nav-title > span { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 0 7px; }
.tpl-sidebar .tpl-list a { display: flex; align-items: center; gap: 12px; padding: 16px 14px; border: 1px solid transparent; border-radius: 10px; background: transparent; }
.tpl-sidebar .tpl-list a > .i { width: 24px; height: 24px; color: var(--text-3); }
.tpl-sidebar .tpl-list a > div { display: grid; gap: 4px; min-width: 0; }
.tpl-sidebar .tpl-list a b { font-size: 16px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.tpl-sidebar .tpl-list a span { font-size: 16px; }
.tpl-sidebar .tpl-list a.on { background: var(--surface); border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.tpl-sidebar .tpl-list a.on > .i { color: var(--brand); }
.tpl-jump { display: grid; gap: 4px; }
.tpl-jump button { font: inherit; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 16px; text-align: left; }
.tpl-jump button:hover, .tpl-jump button:focus-visible { color: var(--brand); background: var(--brand-soft); }
.tpl-jump button > i { font-style: normal; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text-3); }
.tpl-jump button > .i { width: 15px; height: 15px; margin-left: auto; }
.tpl-ai-note { display: grid; grid-template-columns: 22px minmax(0,1fr); align-items: center; gap: 6px; padding: 16px; border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--border)); border-radius: 12px; background: var(--brand-soft); }
.tpl-ai-note .i { color: var(--brand); }
.tpl-ai-note b { font-size: 16px; font-weight: 600; color: var(--brand); }
.tpl-ai-note p { grid-column: 1 / -1; font-size: 16px; line-height: 1.8; color: var(--text-2); margin: 0; }
.tpl-edit { border: 0; background: transparent; box-shadow: none; overflow: visible; min-width: 0; }
.tpl-edit > .tpl-current { padding: 24px 28px; border-radius: 12px; border: 1px solid #21465a; background: #102d40; color: #effaff; align-items: center; }
.tpl-current-label { display: flex; align-items: center; gap: 8px; font-size: 16px; color: #8adce6; margin-bottom: 7px; }
.tpl-current-label > .i { width: 17px; height: 17px; }
.tpl-edit > .tpl-current h2 { font-size: 25px; color: #f3fbff; }
.tpl-edit > .tpl-current p { font-size: 16px; color: #b9d2df; }
.tpl-current .btn.ghost { color: #e6f8ff; background: #ffffff0c; border-color: #658398; }
.tpl-current .btn.ghost:hover { background: #ffffff17; border-color: #91b9c8; }
.tpl-current .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-edit > .tpl-grid { display: grid; gap: 20px; padding: 22px 0 0; }
.tpl-section { scroll-margin-top: 24px; min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.tpl-section > header { display: flex; align-items: flex-start; gap: 13px; padding: 21px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.tpl-section > header > span { display: grid; place-items: center; flex: 0 0 33px; height: 33px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--brand); background: var(--surface); font-size: 16px; font-variant-numeric: tabular-nums; }
.tpl-section h3 { font-size: 22px; font-weight: 650; color: var(--text); margin: 0; }
.tpl-section header p { font-size: 16px; color: var(--text-3); line-height: 1.8; margin: 4px 0 0; }
.tpl-section-body { display: grid; gap: 21px; padding: 24px; min-width: 0; }
.tpl-section .field > span { font-size: 16px; }
.tpl-section .field .hint { font-size: 16px; margin-left: auto; }
.tpl-section .row3 { gap: 18px; }
.tpl-section .tpl-row.price { grid-template-columns: 140px minmax(0,1fr) minmax(0,1fr) 36px; gap: 16px; }
.tpl-section .tpl-row.price label { display: grid; gap: 7px; align-items: center; font-size: 16px; color: var(--text-2); }
.tpl-section .size-table th { font-size: 16px; padding: 12px 14px; }
.tpl-section .size-table td { padding: 10px 14px; }
.tpl-section .size-table input { max-width: 120px; width: 100%; font-size: 16px; }
.tpl-section .table-wrap { border: 1px solid var(--border); border-radius: 10px; }
.tpl-section .palette { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(300px,100%),1fr)); gap: 12px; }
.tpl-section .pchip { padding: 9px; display: grid; grid-template-columns: 34px minmax(0,1fr) minmax(0,1fr) 30px; gap: 7px; border-radius: 10px; min-width: 0; }
.tpl-section .pchip input:not([type=color]) { width: 100%; min-width: 0; font-size: 16px; }
.tpl-section .pchip input[type=color] { width: 34px; height: 40px; }
.tpl-section .pchip .link-btn { padding: 3px; }
.tpl-section #add-color { justify-content: center; min-height: 48px; font-size: 16px; border-style: dashed; }
.tpl-section-colors > header { background: var(--surface); }
.tpl-section .blank { width: 180px; border-radius: 13px; }
.tpl-section .blank em { font-size: 16px; }
.tpl-edit > .tpl-save-bar { position: sticky; bottom: 18px; z-index: 5; justify-content: space-between; margin-top: 22px; padding: 17px 22px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 22px -12px rgba(16,45,64,.25); }
.tpl-save-bar > span { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text-2); }
.tpl-save-bar .btn { min-width: 140px; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
/* 长规则表单采用标题、字段、帮助三个文字角色，违禁词作为清楚的规则子区。 */
.tpl-current-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; color: #d3e5ee; font-size: 16px; }
.tpl-current-meta b { color: #fff; font-weight: 650; font-variant-numeric: tabular-nums; }
.tpl-section .field > span { flex-wrap: wrap; row-gap: 4px; line-height: 1.6; }
.tpl-section .field .hint { color: var(--text-2); font-weight: 400; }
.tpl-section .tpl-row.price { align-items: end; }
.tpl-section .tpl-row.price > input { align-self: end; }
.tpl-section .tpl-row.price > .link-btn { align-self: end; min-height: 42px; }
.tpl-section .check-field > input { width: 19px; height: 19px; min-height: 0; flex: none; }
.tpl-section .check-field > span { line-height: 1.7; }
.tpl-section .tpl-banned { padding-top: 22px; border-top: 1px solid var(--border); }
.tpl-banned-defaults { border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.tpl-banned-defaults summary { cursor: pointer; padding: 14px 16px; font-size: 16px; font-weight: 500; line-height: 1.7; color: var(--text); }
.tpl-banned-defaults summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.tpl-banned-defaults [data-banned-list] { padding: 0 16px 16px; font-size: 16px; line-height: 1.85; overflow-wrap: anywhere; }
.tpl-banned-defaults [data-banned-list] p + p { margin-top: 12px; }
.tpl-section .pchip > .link-btn { min-width: 30px; min-height: 40px; }
.tpl-section .blank em { background: var(--surface); color: var(--text-2); border-top: 1px solid var(--border); padding: 7px 4px; }
.tpl-current .link-btn.red { color: #ffb9b0; }
.tpl-current .link-btn.red:hover { color: #fff; background: #933c42; }
.tpl-save-bar .btn { min-height: 46px; }

/* 导入的主动作与已选文件保持清楚的层级，避免文件名看起来像普通说明。 */
.tpl-import .tpl-drop { display: flex; align-items: center; gap: 16px; padding: 22px; border: 1.5px dashed var(--brand); border-radius: 10px; background: var(--brand-soft); cursor: pointer; }
.tpl-import .tpl-drop > .i { width: 30px; height: 30px; flex: none; color: var(--brand); }
.tpl-import .tpl-drop-copy { display: grid; gap: 5px; flex: 1; min-width: 0; }
.tpl-import .tpl-drop-copy b { font-size: 18px; line-height: 1.5; color: var(--text); }
.tpl-import .tpl-drop-copy > span { font-size: 15px; line-height: 1.6; color: var(--text-2); }
.tpl-import .tpl-drop .btn { flex: none; border-color: var(--brand); color: var(--brand); }
.tpl-import .tpl-drop:hover, .tpl-import .tpl-drop:focus-within, .tpl-import .tpl-drop.is-dragover { border-style: solid; border-color: var(--brand-hover); }
.tpl-import .tpl-drop.is-dragover { outline: 2px solid var(--brand); outline-offset: 3px; }
.tpl-import .tpl-import-files { display: grid; gap: 8px; min-width: 0; }
.tpl-import .tpl-import-files[hidden] { display: none; }
.tpl-import .tpl-import-file-count { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.tpl-import .tpl-import-file-count > span { color: var(--text-2); font-weight: 400; }
.tpl-import .tpl-import-file { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.tpl-import .tpl-import-file > .i { width: 22px; height: 22px; flex: none; color: var(--brand); }
.tpl-import .tpl-import-file > b { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 16px; font-weight: 600; line-height: 1.6; color: var(--text); }
.tpl-import .tpl-import-file > .link-btn { flex: none; display: grid; place-items: center; min-width: 40px; min-height: 40px; color: var(--text-2); }
.tpl-import .tpl-import-file > .link-btn:hover { color: var(--red); background: var(--red-bg); }
.tpl-import .tpl-import-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; }
.tpl-import .tpl-import-submit { min-height: 56px; min-width: 248px; padding: 14px 22px; gap: 12px; font-size: 18px; font-weight: 650; line-height: 1.5; }
.tpl-import .tpl-import-submit > .i { width: 21px; height: 21px; }
.tpl-import .tpl-import-actions > span { color: var(--text-2); font-size: 15px; line-height: 1.7; }
.tpl-import .tpl-import-result:empty { display: none; }
.tpl-import .tpl-import-result:not(:empty) { padding: 16px 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 16px; line-height: 1.8; overflow-wrap: anywhere; }
.tpl-import .tpl-import-result[data-state="success"] { border-color: var(--brand); background: var(--brand-soft); }
.tpl-import .tpl-import-result[data-state="error"] { border-color: var(--red); background: var(--red-bg); color: var(--text); }
.tpl-import .tpl-import-result p { margin: 0 0 6px; }
.tpl-import .tpl-import-result p:last-child { margin-bottom: 0; }
.tpl-import .tpl-import-result ul { margin: 6px 0 12px; padding-left: 24px; }

@media (max-width: 600px) {
  .tpl-import .tpl-drop { flex-wrap: wrap; padding: 18px; gap: 12px; }
  .tpl-import .tpl-drop-copy { flex-basis: calc(100% - 44px); }
  .tpl-import .tpl-drop .btn, .tpl-import .tpl-import-submit { width: 100%; min-width: 0; }
}

@media (max-width: 1350px) {
  .tpl-page { grid-template-columns: 196px minmax(0,1fr); gap: 20px; }
  main[data-page="templates"] { padding-left: 24px; padding-right: 24px; }
  .tpl-section .row3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tpl-section .row3 > :last-child { grid-column: auto; }
}
@media (max-width: 1100px) {
  .tpl-page { grid-template-columns: 180px minmax(0,1fr); }
  .tpl-section .tpl-row.price { grid-template-columns: 110px minmax(0,1fr) minmax(0,1fr) 28px; gap: 10px; }
}
@media (max-width: 900px) {
  .tpl-page { grid-template-columns: minmax(0,1fr); }
  .tpl-sidebar { position: static; }
  .tpl-sidebar .tpl-list { display: flex; flex-wrap: wrap; }
  .tpl-sidebar .tpl-list a { flex: 1; }
  .tpl-jump, .tpl-ai-note { display: none; }
  .tpl-section .tpl-row.price { grid-template-columns: 1fr 1fr 28px; }
  .tpl-section .tpl-row.price > :first-child { grid-column: 1 / -1; }
}

.material-template-page{max-width:1440px;margin:0 auto;min-width:0}
.material-template-page .material-template-notice{display:flex;gap:12px;padding:18px 20px;border:1px solid var(--border);background:var(--surface);border-radius:14px;margin-bottom:24px;color:var(--text)}
.material-template-notice>svg{width:20px;height:20px;flex:none;color:var(--brand);margin-top:2px}
.material-template-notice p,.material-template-tip p{font-size:13px;line-height:1.75;margin:5px 0 0;color:var(--text-3)}
.material-template-grid{display:grid;grid-template-columns:250px minmax(0,1fr);gap:24px;align-items:start}
.material-template-list{min-width:0;position:sticky;top:24px}
.material-template-list>p{font-size:12px;font-weight:700;color:var(--text-3);padding:0 12px;display:flex;justify-content:space-between}
.material-template-list nav{display:grid;gap:8px}
.material-template-list nav a{display:flex;gap:12px;align-items:center;padding:15px 14px;border:1px solid transparent;border-radius:12px;text-decoration:none;color:var(--text);transition:background .16s,border-color .16s}
.material-template-list nav a>svg{width:18px;height:18px;flex:none}
.material-template-list nav a>span{min-width:0;flex:1}
.material-template-list nav a b{display:block;overflow-wrap:anywhere;font-size:14px}
.material-template-list nav a small{display:block;margin-top:5px;color:var(--text-3);font-size:12px}
.material-template-list nav a:hover,.material-template-list nav a[aria-current]{background:var(--surface);border-color:var(--border)}
.material-template-list nav a[aria-current]{box-shadow:0 3px 14px #16324c06;color:var(--brand)}
.material-template-tip{margin:26px 12px 0;padding-top:20px;border-top:1px solid var(--border)}
.material-template-tip>svg{width:18px;height:18px;vertical-align:middle;margin-right:7px;color:var(--brand)}
.material-template-tip>b{font-size:13px}
.material-template-editor{min-width:0;overflow:hidden}
.material-template-editor>header{display:flex;align-items:start;justify-content:space-between;gap:18px;padding:26px;border-bottom:1px solid var(--border)}
.material-template-eyebrow{font-size:11px;letter-spacing:.08em;color:var(--text-3);font-weight:700}
.material-template-editor h2{font-size:23px;line-height:1.4;margin:9px 0 7px;overflow-wrap:anywhere}
.material-template-editor header p{color:var(--text-3);font-size:12px;margin:0}
.material-template-fields{padding:24px 26px;display:grid;gap:24px}
.material-template-fields section{display:grid;gap:20px;padding-top:24px;border-top:1px solid var(--border)}
.material-template-fields h3{display:flex;align-items:center;gap:12px;font-size:15px;margin:0 0 2px}
.material-template-fields h3 span{font-size:11px;font-variant-numeric:tabular-nums;background:var(--surface-2);padding:6px;border-radius:7px;color:var(--text-3)}
.material-template-fields .field{display:grid;gap:8px;min-width:0}
.material-template-fields .field>span{font-size:13px;font-weight:600}
.material-template-fields small{font-size:12px;line-height:1.7;color:var(--text-3)}
.material-template-fields input,.material-template-fields textarea{width:100%;box-sizing:border-box;min-width:0;line-height:1.7;resize:vertical}
.material-template-editor>footer{display:flex;gap:18px;justify-content:space-between;align-items:center;padding:20px 26px;border-top:1px solid var(--border);background:var(--surface-2)}
.material-template-editor>footer p{font-size:12px;line-height:1.7;margin:0;color:var(--text-3)}
.material-template-editor [data-state=error]{color:var(--red)}
.material-template-empty{padding:48px;text-align:center}.material-template-empty>svg{width:34px;height:34px;color:var(--brand)}
.material-template-empty p{color:var(--text-3);line-height:1.7}
@media(max-width:900px){.material-template-grid{grid-template-columns:1fr}.material-template-list{position:static}.material-template-list nav{grid-template-columns:repeat(2,minmax(0,1fr))}.material-template-tip{display:none}.material-template-editor>header{flex-direction:column}}
@media(max-width:520px){.material-template-notice{padding:14px!important}.material-template-list nav{grid-template-columns:1fr}.material-template-editor>header,.material-template-fields,.material-template-editor>footer{padding:18px}.material-template-editor>footer{align-items:stretch;flex-direction:column}.material-template-editor .head-actions{display:flex;flex-wrap:wrap;gap:8px}.material-template-empty{padding:28px 18px}}
@media(prefers-reduced-motion:reduce){.material-template-list nav a{transition:none}}
