/* Template gallery — personalise card + filter bar.
   Everything is scoped under .tfx so the shared .chip / .search styles used elsewhere (editor, feedback) are untouched. */
   .tfx { --h: 44px; --r: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 28px; color: var(--ink); }
   .tfx svg { flex: none; }
   .tfx .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
   
   /* ---------- 1 · Personalise ---------- */
   .tfx-pz { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 3fr); gap: 18px 32px; align-items: center; padding: 18px 22px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 14px 34px -26px rgba(31, 63, 48, .55); }
   .tfx-pz-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
   .tfx-badge { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--forest), var(--forest-2) 60%, #3f7054); box-shadow: inset 0 0 0 1px rgba(184, 149, 90, .5), 0 10px 18px -10px rgba(31, 63, 48, .8); }
   .tfx-pz-head b { display: block; font-size: 1rem; line-height: 1.25; letter-spacing: -.01em; }
   .tfx-pz-head small { display: block; margin-top: 2px; color: var(--muted); font-size: .82rem; line-height: 1.4; }
   .tfx-pz-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(150px, 190px) auto; gap: 12px; align-items: end; }
   .tfx-field { min-width: 0; }
   .tfx-field label { display: block; margin: 0 0 6px 2px; font-size: max(12px, .75rem); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
   .tfx-field label i { font-style: normal; font-weight: 600; letter-spacing: 0; text-transform: none; opacity: .7; }
   .tfx-field input { width: 100%; height: var(--h); padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .93rem; color: var(--ink); color-scheme: light; transition: border-color .15s, box-shadow .15s, background .15s; }
   .tfx-field input::placeholder { color: #8b9a8f; }
   .tfx-field input:hover { border-color: #cfd7c8; }
   .tfx-field input:focus { outline: none; border-color: var(--forest-2); box-shadow: 0 0 0 4px rgba(45, 90, 66, .14); }
   
   /* ---------- 2 · Filter panel ---------- */
   .tfx-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 14px 34px -26px rgba(31, 63, 48, .55); }
   .tfx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
   
   .tfx-search { position: relative; flex: 1 1 320px; min-width: 0; }
   .tfx-search > svg { position: absolute; left: 15px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
   .tfx-search input[type="search"] { width: 100%; height: var(--h); padding: 0 76px 0 44px; border-radius: var(--r); border: 1px solid var(--line); background: #fbf9f2; font: inherit; font-size: .93rem; color: var(--ink); appearance: none; -webkit-appearance: none; transition: border-color .15s, box-shadow .15s, background .15s; }
   .tfx-search input[type="search"]::-webkit-search-cancel-button { display: none; }
   .tfx-search input::placeholder { color: #8b9a8f; }
   .tfx-search input:hover { border-color: #cfd7c8; }
   .tfx-search input:focus { outline: none; background: #fff; border-color: var(--forest-2); box-shadow: 0 0 0 4px rgba(45, 90, 66, .14); }
   .tfx-search kbd { position: absolute; right: 12px; top: 50%; translate: 0 -50%; min-width: 24px; height: 24px; padding: 0 7px; display: grid; place-items: center; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 7px; background: #fff; font: 600 .74rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); pointer-events: none; }
   .tfx-search input:focus ~ kbd, .tfx-search.has-q kbd { display: none; }
   .tfx-search .tfx-x { position: absolute; right: 8px; top: 50%; translate: 0 -50%; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); }
   .tfx-search .tfx-x:hover { background: #efeadb; color: var(--ink); }
   
   /* segmented control: All / Free / Premium */
   .tfx-compare { flex: 1 1 100%; margin: 4px 0 0; }
   .tfx-seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sage-wash, #eef3e7); }
   .tfx-seg a { display: inline-flex; align-items: center; gap: 6px; height: calc(var(--h) - 10px); padding: 0 16px; border-radius: 10px; font-size: .88rem; font-weight: 600; color: var(--muted); white-space: nowrap; transition: color .15s, background .15s, box-shadow .15s; }
   .tfx-seg a:hover { color: var(--ink); }
   .tfx-seg a.on { background: #fff; color: var(--forest); box-shadow: 0 1px 2px rgba(18, 36, 26, .12), 0 6px 14px -8px rgba(31, 63, 48, .55); }
   .tfx-seg a:focus-visible, .tfx-btn:focus-visible, .tfx .chip:focus-visible, .tfx-tag:focus-visible { outline: 3px solid rgba(45, 90, 66, .45); outline-offset: 2px; }
   
   /* sort */
   .tfx-sort { position: relative; display: flex; align-items: center; gap: 8px; height: var(--h); padding: 0 12px 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; transition: border-color .15s, box-shadow .15s; }
   .tfx-sort:hover { border-color: #cfd7c8; }
   .tfx-sort:focus-within { border-color: var(--forest-2); box-shadow: 0 0 0 4px rgba(45, 90, 66, .14); }
   .tfx-sort select { height: 100%; padding: 0 22px 0 0; border: 0; outline: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23526759' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right center / 14px; font: inherit; font-weight: 700; color: var(--ink); appearance: none; -webkit-appearance: none; cursor: pointer; }
   
   /* category chips (scrollable, edge fades + arrows) */
   .tfx-cats { min-width: 0; --ml: 0px; --mr: 0px; position: relative; }
   .tfx-cats .scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 1px 4px; scroll-behavior: smooth; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--ml), #000 calc(100% - var(--mr)), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 var(--ml), #000 calc(100% - var(--mr)), transparent 100%); }
   .tfx .chip, .tfx .chips .chip { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: .88rem; font-weight: 600; letter-spacing: 0; white-space: nowrap; box-shadow: none; transform: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
   .tfx .chip:hover, .tfx .chips .chip:hover { background: var(--sage-wash, #eef3e7); border-color: var(--sage); transform: none; }
   .tfx .chip.active, .tfx .chip[aria-current] { background: var(--forest); border-color: var(--forest); color: var(--ivory, #faf6ec); box-shadow: 0 8px 16px -10px rgba(31, 63, 48, .85); }
   .tfx-arrow { position: absolute; top: 2px; z-index: 2; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink-2); cursor: pointer; box-shadow: 0 8px 18px -10px rgba(31, 63, 48, .6); transition: transform .15s, color .15s; }
   .tfx-arrow:hover { color: var(--forest); transform: scale(1.06); }
   .tfx-arrow.l { left: 0; } .tfx-arrow.r { right: 0; } .tfx-arrow[hidden] { display: none; }
   
   /* ---------- 3 · Results bar ---------- */
   .tfx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 0 4px; }
   .tfx-count { font-size: .9rem; color: var(--muted); } .tfx-count b { color: var(--ink); font-weight: 700; }
   .tfx-tags { display: inline-flex; flex-wrap: wrap; gap: 8px; }
   .tfx-tag { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 12px; border-radius: 999px; border: 1px solid rgba(45, 90, 66, .25); background: var(--sage-soft); color: var(--forest); font-size: .8rem; font-weight: 600; transition: background .15s; }
   .tfx-tag:hover { background: #d3e0cc; }
   .tfx-tag svg { opacity: .65; }
   .tfx-clearall { font-size: .84rem; font-weight: 600; color: var(--forest-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(45, 90, 66, .35); }
   .tfx-clearall:hover { text-decoration-color: currentColor; }
   .tfx-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
   .tfx-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 15px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, color .15s, transform .15s, box-shadow .15s; }
   .tfx-btn:hover { border-color: var(--sage); background: var(--sage-wash, #eef3e7); transform: translateY(-1px); }
   .tfx-btn:active { transform: none; }
   .tfx-btn svg { color: var(--rose); }
   .tfx-btn #favCount { font-weight: 700; color: var(--muted); }
   .tfx-btn.active, .tfx-btn[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: var(--ivory, #faf6ec); box-shadow: 0 10px 18px -12px rgba(31, 63, 48, .9); }
   .tfx-btn.active svg, .tfx-btn[aria-pressed="true"] svg { color: #f3b9b3; fill: currentColor; }
   .tfx-btn.active #favCount, .tfx-btn[aria-pressed="true"] #favCount { color: inherit; opacity: .85; }
   .tfx-btn--quiet { height: var(--h); background: transparent; border-color: transparent; color: var(--muted); }
   .tfx-btn--quiet svg { color: currentColor; }
   .tfx-btn--quiet:hover { background: #efeadb; border-color: transparent; color: var(--ink); }
   
   /* ---------- responsive ---------- */
   @media (max-width: 1020px) {
       .tfx-pz { grid-template-columns: 1fr; }
   }
   @media (max-width: 720px) {
       .tfx-pz { padding: 16px; }
       .tfx-pz-fields { grid-template-columns: 1fr 1fr; }
       .tfx-pz-fields .tfx-field:nth-child(3) { grid-column: 1 / 2; }
       .tfx-pz-fields .tfx-btn--quiet { grid-column: 2 / 3; justify-content: center; }
       .tfx-panel { padding: 12px; }
       .tfx-search { flex-basis: 100%; }
       .tfx-search kbd { display: none; }
       .tfx-seg { flex: 1 1 100%; } .tfx-seg a { flex: 1; justify-content: center; padding: 0 8px; }
       .tfx-sort { flex: 1 1 100%; } .tfx-sort select { flex: 1; text-align: right; }
       .tfx-actions { margin-left: 0; width: 100%; } .tfx-actions .tfx-btn { flex: 1 1 0; justify-content: center; padding: 0 10px; }
       .tfx-arrow { display: none !important; }
   }
   @media (max-width: 420px) { .tfx-pz-fields { grid-template-columns: 1fr; } .tfx-pz-fields .tfx-field:nth-child(3), .tfx-pz-fields .tfx-btn--quiet { grid-column: auto; } }
   @media (prefers-reduced-motion: reduce) { .tfx *, .tfx-cats .scroll { transition: none !important; scroll-behavior: auto; } }
   