/* Public template gallery (marketing) */
.tpl-wrap { padding: 3rem 0 5rem; background: #fff; }

/* Hero + search */
.tpl-hero { text-align: center; max-width: 680px; margin: 0 auto 2.5rem; }
.tpl-hero-sm { margin-bottom: 1.75rem; }
.tpl-hero-title { font-weight: 800; font-size: clamp(1.9rem, 4vw, 2.8rem); letter-spacing: -0.02em; color: #18181b; margin-bottom: .6rem; }
.tpl-hero-sub { font-size: 1.05rem; color: #52525b; margin-bottom: 1.5rem; }
.tpl-search { position: relative; max-width: 520px; margin: 0 auto; }
.tpl-search i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #9aa3af; }
.tpl-search input { width: 100%; padding: .85rem 1rem .85rem 2.6rem; border: 1px solid #e4e4e7; border-radius: 12px; font-size: 1rem; }
.tpl-search input:focus { outline: none; border-color: var(--sp-accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* Breadcrumb */
.tpl-breadcrumb { font-size: .85rem; color: #9aa3af; margin-bottom: 1.25rem; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.tpl-breadcrumb a { color: #6b7280; text-decoration: none; }
.tpl-breadcrumb a:hover { color: var(--sp-accent); }
.tpl-breadcrumb i { font-size: .7rem; }

/* Category chips */
.tpl-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 2rem; }
.tpl-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; border: 1px solid #e4e4e7; background: #fff; color: #3f3f46; text-decoration: none; font-size: .85rem; font-weight: 500; transition: border-color .15s, color .15s, background .15s; }
.tpl-chip:hover { border-color: var(--sp-accent); color: var(--sp-accent); }
.tpl-chip.active { background: var(--sp-accent); border-color: var(--sp-accent); color: #fff; }
.tpl-chip-count { font-size: .72rem; opacity: .7; }
.tpl-chip.active .tpl-chip-count { opacity: .85; }
.tpl-chips-cap { margin-top: -1rem; gap: .4rem; }
.tpl-chips-cap .tpl-cap-label { align-self: center; font-size: .8rem; font-weight: 600; color: #71717a; margin-right: .15rem; }
.tpl-chip-cap { cursor: pointer; font-size: .8rem; padding: .35rem .8rem; }
.tpl-feature-links { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid #e4e4e7; }
.tpl-feature-links h2 { font-size: 1rem; font-weight: 700; color: #3f3f46; margin-bottom: 1rem; }
.tpl-feature-links ul { list-style: none; display: flex; flex-wrap: wrap; gap: .6rem; padding: 0; margin: 0; }
.tpl-feature-links a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; border: 1px solid #e4e4e7; background: #fff; color: #3f3f46; text-decoration: none; font-size: .85rem; font-weight: 500; transition: border-color .15s, color .15s; }
.tpl-feature-links a:hover { border-color: var(--sp-accent); color: var(--sp-accent); }
.tpl-feature-links a span { font-size: .72rem; opacity: .6; }
.tpl-pagination { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: 2.5rem; }
.tpl-pagination:empty { display: none; }
.tpl-page-btn { min-width: 2.4rem; height: 2.4rem; padding: 0 .6rem; border-radius: 8px; border: 1px solid #e4e4e7; background: #fff; color: #3f3f46; font-size: .9rem; font-weight: 600; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.tpl-page-btn:hover:not(:disabled):not(.active) { border-color: var(--sp-accent); color: var(--sp-accent); }
.tpl-page-btn.active { background: var(--sp-accent); border-color: var(--sp-accent); color: #fff; cursor: default; }
.tpl-page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Grid + cards */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.5rem; }
.tpl-card { border: 1px solid #ececef; border-radius: 16px; overflow: hidden; background: #fff; display: flex; flex-direction: column; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.tpl-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(24,24,27,.1); border-color: #d6d9ff; }
/* 3:2 matches the 1200x800 screenshot (no awkward crop); object-position:top shows the
   hero (large text) rather than the middle of the page. */
.tpl-card-thumb { position: relative; display: block; aspect-ratio: 3/2; overflow: hidden; background: #f4f4f5; }
.tpl-card-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .3s ease; }
.tpl-card:hover .tpl-card-thumb img { transform: scale(1.04); }
.tpl-card-cat { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 999px; background: rgba(17,17,20,.72); color: #fff; font-size: .72rem; font-weight: 600; backdrop-filter: blur(4px); }
.tpl-card-popular { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 999px; background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; font-size: .72rem; font-weight: 700; box-shadow: 0 2px 8px rgba(249,115,22,.4); }
.tpl-card-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(79,70,229,.0); opacity: 0; transition: opacity .2s ease, background .2s ease; }
.tpl-card:hover .tpl-card-overlay { opacity: 1; background: rgba(79,70,229,.32); }
.tpl-card-overlay-btn { background: #fff; color: #18181b; font-weight: 600; font-size: .85rem; padding: .5rem 1rem; border-radius: 999px; }
.tpl-card-body { padding: 1rem 1.1rem 1.15rem; display: flex; flex-direction: column; flex: 1; }
.tpl-card-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 .35rem; }
.tpl-card-title a { color: #18181b; text-decoration: none; }
.tpl-card-title a:hover { color: var(--sp-accent); }
.tpl-card-desc { font-size: .88rem; color: #71717a; margin: 0 0 1rem; flex: 1; }
.tpl-card-foot { display: flex; align-items: center; justify-content: space-between; }
.tpl-card-pages { font-size: .8rem; color: #9aa3af; }
.tpl-card-use { font-size: .85rem; font-weight: 600; color: var(--sp-accent); text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.tpl-card-use:hover { gap: .5rem; color: #4f46e5; }

.tpl-empty { text-align: center; color: #9aa3af; padding: 3rem 1rem; font-size: 1rem; }

/* Detail page */
.tpl-detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 2.5rem; align-items: start; margin-bottom: 3rem; }
.tpl-detail-preview { border-radius: 16px; overflow: hidden; border: 1px solid #e4e4e7; box-shadow: 0 24px 60px rgba(24,24,27,.12); position: sticky; top: 90px; }
.tpl-detail-frame { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: #18181b; }
.tpl-detail-frame > span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.25); flex-shrink: 0; }
.tpl-detail-frame > span:first-child { background: #ef4444; }
.tpl-detail-frame > span:nth-child(2) { background: #eab308; }
.tpl-detail-frame > span:nth-child(3) { background: #22c55e; }
.tpl-preview-tabs { display: flex; gap: 2px; margin: 0 .5rem; overflow-x: auto; flex: 1; }
.tpl-preview-tab { background: transparent; border: 0; color: rgba(255,255,255,.55); font-size: .72rem; font-weight: 600; padding: .25rem .55rem; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.tpl-preview-tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tpl-preview-tab.active { color: #fff; background: rgba(255,255,255,.16); }
.tpl-preview-devices { display: flex; gap: 2px; margin-left: auto; }
.tpl-device-btn { background: transparent; border: 0; color: rgba(255,255,255,.55); padding: .2rem .45rem; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.tpl-device-btn:hover { color: #fff; }
.tpl-device-btn.active { color: #fff; background: rgba(255,255,255,.16); }
/* The iframe renders at a real DEVICE width, then is scaled down to fit the column via
   JS (transform). transform-origin top-left so it pins to the top-left of the stage. */
.tpl-preview-stage { background: #f4f4f5; overflow: hidden; position: relative; }
.tpl-preview-stage.is-mobile { display: flex; justify-content: center; padding: 1rem 0; }
.tpl-preview-iframe { border: 0; display: block; background: #fff; transform-origin: top left; }
.tpl-preview-stage.is-mobile .tpl-preview-iframe { transform-origin: top center; border: 1px solid #e4e4e7; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.tpl-detail-cat { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; color: var(--sp-accent); background: rgba(99,102,241,.1); padding: .3rem .8rem; border-radius: 999px; margin-bottom: .9rem; }
.tpl-detail-title { font-weight: 800; font-size: 2rem; letter-spacing: -0.02em; color: #18181b; margin-bottom: .75rem; }
.tpl-detail-desc { font-size: 1.05rem; color: #52525b; line-height: 1.6; margin-bottom: 1.25rem; }
.tpl-detail-cta { display: inline-flex; align-items: center; gap: .5rem; background: var(--sp-accent); color: #fff !important; border-radius: 100px; padding: .85rem 1.8rem; font-size: 1rem; font-weight: 600; text-decoration: none; transition: background .2s, box-shadow .2s, transform .2s; }
.tpl-detail-cta:hover { background: #4f46e5; box-shadow: 0 8px 28px rgba(99,102,241,.4); transform: translateY(-2px); }
.tpl-detail-note { font-size: .82rem; color: #9aa3af; margin-top: .7rem; }
.tpl-detail-includes { margin-top: 1.75rem; }
.tpl-detail-includes h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .6rem; color: #18181b; }
.tpl-detail-includes ul { list-style: none; padding: 0; margin: 0; }
.tpl-detail-includes li { display: flex; align-items: center; gap: .55rem; padding: .35rem 0; color: #3f3f46; font-size: .92rem; }
.tpl-detail-includes i { color: var(--sp-accent); }

/* FAQ */
.tpl-faq { max-width: 760px; margin: 3.5rem auto 3rem; }
.tpl-faq h2 { font-weight: 800; font-size: 1.4rem; margin-bottom: 1rem; color: #18181b; }
.tpl-faq details { border: 1px solid #ececef; border-radius: 12px; padding: .9rem 1.1rem; margin-bottom: .6rem; }
.tpl-faq summary { font-weight: 600; cursor: pointer; color: #18181b; }
.tpl-faq details p { margin: .6rem 0 0; color: #52525b; font-size: .92rem; }

/* Related + bottom CTA */
.tpl-related { margin-bottom: 3rem; }
.tpl-related h2 { font-weight: 800; font-size: 1.4rem; margin-bottom: 1.25rem; color: #18181b; }
.tpl-bottom-cta { text-align: center; padding: 3rem 1rem; background: #fafafa; border-radius: 16px; }
.tpl-bottom-cta h2 { font-weight: 800; font-size: 1.5rem; margin-bottom: 1.25rem; color: #18181b; }

@media (max-width: 768px) {
    .tpl-detail-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}
