/* 成套模板库：独立样式，不覆盖原有编辑器与书架布局。 */
#shelf-templates { margin-left: auto; white-space: nowrap; }
.modal.template-modal { width: 1040px !important; max-width: 95vw; height: min(900px, 92vh); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.template-head { padding: 22px 26px 8px; align-items: flex-start; }
.template-eyebrow { color: var(--accent); letter-spacing: .18em; font-size: 11px; margin-bottom: 9px; }
.template-head h3 { font-size: 23px; letter-spacing: .04em; }
.template-head p { color: var(--muted); font-size: 12px; margin: 9px 0 4px; }
.template-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 26px 16px; }
.template-filters[hidden] { display: none; }
.template-filter { border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 6px 15px; color: var(--muted); font-size: 12px; }
.template-filter.active { border-color: var(--ink); color: var(--panel); background: var(--ink); }
.template-content { flex: 1; min-height: 0; overflow: auto; padding: 0 26px 22px; background: var(--panel); }
.template-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.template-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; transition: border-color .15s, box-shadow .15s; }
.template-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.template-art { position: relative; height: 220px; background: color-mix(in srgb, var(--template-paper), #fff 25%); overflow: hidden; cursor: pointer; }
.template-art:after { content: ''; position: absolute; left: 10%; right: 10%; height: 8px; bottom: 17px; background: #352c2022; filter: blur(9px); }
.template-cover-mini { position: absolute; top: 22px; left: 24px; z-index: 2; transform: rotate(-5deg); }
.template-body-mini { position: absolute; top: 52px; right: 24px; z-index: 1; transform: rotate(7deg); }
.template-paper { position: relative; display: inline-block; overflow: hidden; background: #fffdf8; box-shadow: 0 5px 12px #392f2426; vertical-align: top; }
.template-paper iframe { border: 0; position: absolute; inset: 0; transform-origin: top left; pointer-events: none; }
.template-category { position: absolute; top: 9px; right: 10px; font-size: 10px; background: #ffffffc9; color: var(--ink); border-radius: 4px; padding: 3px 7px; z-index: 3; }
.template-card-text { padding: 15px; }
.template-card h4 { font-family: var(--serif); font-size: 18px; letter-spacing: .08em; margin: 0 0 8px; }
.template-card p { color: #766d63; font-size: 12px; line-height: 1.8; margin: 0 0 10px; min-height: 43px; }
.template-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }
.template-tags span { font-size: 10px; color: #7d7264; background: #f5f1e9; border-radius: 3px; padding: 3px 5px; }
.template-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.template-card.selected .template-select { background: var(--accent); color: #fff; border-color: var(--accent); }
.template-footer { flex: 0 0 auto; padding: 14px 26px 18px; border-top: 1px solid var(--line); background: var(--panel2); }
.template-selection { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 10px; min-height: 18px; }
.template-footer .form-row { margin-bottom: 5px; }
.template-footer .check-row { font-size: 12px; }
.template-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.template-actions .template-note { margin-right: auto; }
.template-note { font-size: 11px; color: #857c70; line-height: 1.6; margin: 7px 0; }
.template-apply-row { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.template-apply-row select { padding: 7px 10px; border: 1px solid var(--line2); border-radius: 6px; background: white; color: var(--ink); }
.template-error { color: #b23a2a; font-size: 12px; }
.template-error:empty { display: none; }
.template-loading { color: var(--muted); text-align: center; padding: 80px 0; }
.template-detail-head { display: flex; align-items: center; gap: 20px; margin: 18px 0; }
.template-detail-head h4 { font-family: var(--serif); font-size: 21px; margin: 0 0 5px; }
.template-detail-head p { color: var(--muted); font-size: 12px; margin: 0; }
.template-detail-pages { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; padding: 25px 10px 16px; border-radius: 10px; background: #eee9df; }
.template-detail-pages figure { margin: 0; text-align: center; }
.template-detail-pages figcaption { color: var(--muted); font-size: 12px; margin-top: 12px; }
.template-preview-note { text-align: center; margin: 14px 0; }
.template-modal button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media(max-height:760px) { .template-head { padding-top: 14px; } .template-head h3 { font-size: 20px; } .template-footer { padding-top: 10px; padding-bottom: 12px; } }
@media(max-width:900px) { .template-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .template-detail-pages { overflow-x: auto; grid-template-columns: repeat(3,240px); } }
