/* ============================================================
   KinaQuest · Templates hub
   Shared by templates/index.html and every category page
   (office.html, stories.html, excel.html …). Host the HTML
   anywhere; only this file and templates.js need to travel.
   ============================================================ */

/* ---------- Tokens (same palette as ../kinaquest.css) ---------- */
:root {
  --bg:            #fbfbff;
  --surface:       #ffffff;
  --surface-alt:   #f4f3ff;
  --accent:        #4f35e8;
  --accent-2:      #8b4df0;
  --accent-soft:   #ede9ff;
  --ink:           #0f0f2b;
  --ink-2:         #4a5578;
  --ink-3:         #7c86a8;
  --line:          #e4e3f6;
  --shadow:        0 2px 14px rgba(79, 53, 232, .08);
  --shadow-hover:  0 10px 34px rgba(79, 53, 232, .16);
  --r-lg: 18px;
  --r-md: 12px;
  --font: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Lora', Georgia, serif;
  --wrap: 1180px;
  --pad: clamp(16px, 4vw, 32px);
}
:root[data-theme="dark"] {
  --bg:#0d0d1a; --surface:#14142a; --surface-alt:#1a1a2e; --accent:#8b73ff; --accent-2:#b18cff;
  --accent-soft:#1e1a3a; --ink:#eeeeff; --ink-2:#a9aed0; --ink-3:#6c72a0; --line:#27274a;
  --shadow:0 2px 14px rgba(0,0,0,.35); --shadow-hover:0 10px 34px rgba(0,0,0,.5);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
body::before { /* faint wash behind the hero */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 520px; z-index: -1;
  background: radial-gradient(60% 100% at 18% 0%, var(--accent-soft), transparent 70%);
  opacity: .7; pointer-events: none;
}
h1, h2, h3, h4, h5, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header, .tabs ul, main { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--pad); }
.site-header {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: clamp(16px, 4vw, 48px); padding-block: 18px 14px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__icon { width: 40px; height: 40px; }
.brand__name { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; }

.search {
  display: flex; align-items: center; gap: 12px; height: 50px; padding-inline: 18px;
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: .95rem; color: var(--ink); outline: none; }
.search input::placeholder { color: var(--ink-3); }

.header-actions { display: flex; align-items: center; gap: 22px; }
.submit-link { color: var(--accent); font-weight: 600; font-size: .95rem; white-space: nowrap; }
.submit-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.avatar-btn {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface); transition: border-color .2s;
}
.avatar-btn:hover { border-color: var(--accent); }
.avatar-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }

/* ---------- Category tabs ---------- */
.tabs { border-bottom: 1px solid var(--line); max-width: none; padding: 0; }
.tabs ul { display: flex; gap: clamp(10px, 1.6vw, 24px); overflow-x: auto; scrollbar-width: none; }
.tabs ul::-webkit-scrollbar { display: none; }
.tabs a {
  display: block; padding: 14px 10px 13px; font-size: .95rem; font-weight: 500; color: var(--ink);
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color .15s;
}
.tabs a:hover { color: var(--accent); }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.tabs li:first-child a { padding-left: 10px; }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(36px, 7vw, 64px) 8px; }
.hero h1 { font-size: clamp(2.5rem, 7.2vw, 4.6rem); font-weight: 800; letter-spacing: -.045em; line-height: 1.05; }
.grad { background: linear-gradient(90deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero h1::after { content: "."; color: var(--accent); }
.hero__sub { margin-top: 14px; font-size: clamp(1.1rem, 2.4vw, 1.6rem); color: var(--ink-2); font-weight: 400; }

/* ---------- Sections ---------- */
.section { padding-top: clamp(32px, 5vw, 52px); }
.section h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700; letter-spacing: -.025em; margin-bottom: 22px; }
main { padding-bottom: 72px; }

/* ---------- Template cards ---------- */
.card-grid { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .card-grid { grid-template-columns: minmax(0, 1fr); } }

.tcard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; transition: transform .2s, box-shadow .2s, border-color .2s; }
.tcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--accent-2); }
.tcard[hidden] { display: none; }
.tcard__link { display: block; }
.tcard__preview { height: 300px; overflow: hidden; background: var(--surface-alt); padding: 14px 14px 0; }
.tcard__meta { padding: 18px 20px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.tcard__meta h3 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.tcard__type { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--ink-2); font-size: .93rem; }

.bookmark {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 0 var(--r-lg) 0 var(--r-md); background: var(--surface); cursor: pointer; color: var(--ink);
}
.bookmark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.bookmark:hover { color: var(--accent); }
.bookmark[aria-pressed="true"] { color: var(--accent); }
.bookmark[aria-pressed="true"] svg { fill: currentColor; }

.empty { margin-top: 8px; color: var(--ink-2); }

/* ---------- Format badges ---------- */
.fmt { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: #fff; font-weight: 800; font-size: .8rem; flex: none; }
.fmt--word  { background: #2b6cde; }
.fmt--excel { background: #1d8a4f; }
.fmt--pdf   { background: #e5393b; font-size: .5rem; letter-spacing: -.02em; }

/* ============================================================
   CARD PREVIEWS — pure CSS mock pages (no image requests)
   ============================================================ */
.pv-cv, .pv-xl, .pv-story, .pv-biz { height: 100%; background: #fff; color: #1b1b2f; border-radius: 6px 6px 0 0; box-shadow: 0 1px 8px rgba(30,30,80,.1); overflow: hidden; font-size: 9px; line-height: 1.45; }

/* CV */
.pv-cv { display: grid; grid-template-columns: 38% 1fr; }
.pv-cv__side { background: #1c2340; color: #e8ebff; padding: 14px 10px; }
.pv-cv__photo { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; background: linear-gradient(135deg, #d9a37c, #8a5a3c); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; border: 3px solid #fff; }
.pv-cv__side h4 { font-size: 10px; margin: 10px 0 4px; }
.pv-cv__side p { font-size: 7px; opacity: .85; overflow-wrap: anywhere; }
.pv-cv__side li { font-size: 7.5px; margin-top: 3px; } .pv-cv__side li::before { content: "• "; }
.pv-cv__main { padding: 14px 12px; }
.pv-cv__main strong { display: block; font-size: 15px; letter-spacing: -.02em; }
.pv-cv__main > span { font-size: 10px; color: #555; }
.pv-cv__main hr { border: 0; border-top: 1px solid #ddd; margin: 12px 0 8px; }
.pv-cv__main h4 { font-size: 10px; margin: 8px 0 3px; }
.pv-cv__main p, .pv-cv__main li { font-size: 7.5px; color: #444; } .pv-cv__main li { margin: 2px 0 0 8px; list-style: disc; }

/* Excel */
.pv-xl { padding: 0 0 8px; }
.pv-xl__title { background: #0f7b43; color: #fff; font-weight: 700; font-size: 13px; padding: 8px 10px; }
.pv-xl table { width: calc(100% - 16px); margin: 8px; border-collapse: collapse; font-size: 8px; }
.pv-xl th, .pv-xl td { border: 1px solid #ddd; padding: 3px 5px; text-align: left; }
.pv-xl th { background: #f1f1f1; }
.pv-xl .up { color: #1d9a5a; } .pv-xl .down { color: #d93636; }
.pv-xl .total td { background: #d8eedf; font-weight: 700; }
.pv-xl__legend { text-align: center; font-size: 8px; margin-top: 8px; }
.pv-xl__legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 3px 0 8px; }
.pv-xl__legend .b { background: #3b82f6; } .pv-xl__legend .g { background: #3fb872; }
.pv-xl__chart { display: flex; align-items: flex-end; justify-content: space-around; height: 64px; margin: 6px 14px 0; border-bottom: 1px solid #ddd; }
.pv-xl__chart span { position: relative; width: 28px; height: 100%; }
.pv-xl__chart span::before, .pv-xl__chart span::after { content: ""; position: absolute; bottom: 0; width: 12px; border-radius: 2px 2px 0 0; }
.pv-xl__chart span::before { left: 0; height: var(--b); background: #3b82f6; }
.pv-xl__chart span::after  { right: 0; height: var(--g); background: #3fb872; }

/* Story */
.pv-story { padding: 46px 22px 0; text-align: center; font-family: var(--serif); background: #fffefc; }
.pv-story h4 { font-size: 21px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 14px; }
.pv-story .sub { font-size: 9.5px; margin-top: 6px; color: #333; }
.pv-story .orn { display: flex; align-items: center; gap: 6px; margin: 18px auto 22px; width: 78%; }
.pv-story .orn i { flex: 1; height: 1px; background: #2a3a7a; } .pv-story .orn b { width: 5px; height: 5px; background: #2a3a7a; transform: rotate(45deg); }
.pv-story .body { text-align: left; font-size: 10px; line-height: 1.75; color: #222; }

/* Proposal */
.pv-biz { position: relative; padding: 14px 16px; background: #fff; }
.pv-biz__tower { position: absolute; top: 0; right: 0; width: 46%; height: 62%; background: linear-gradient(160deg, #cfe6ff, #2d7be0 70%, #0c3c8a); clip-path: polygon(40% 0, 100% 0, 100% 100%, 0 70%); }
.pv-biz__logo { display: flex; gap: 6px; align-items: center; font-size: 7px; font-weight: 600; line-height: 1.2; position: relative; }
.pv-biz__logo i { width: 18px; height: 18px; background: #1d6fe0; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.pv-biz h4 { font-size: 22px; line-height: 1.05; letter-spacing: -.02em; margin: 22px 0 8px; position: relative; max-width: 60%; }
.pv-biz .tag { font-size: 8px; color: #333; position: relative; }
.pv-biz hr { border: 0; height: 2px; width: 70%; background: #3b82d0; margin: 14px 0 12px; position: relative; }
.pv-biz h5 { font-size: 9.5px; margin-bottom: 3px; position: relative; }
.pv-biz .body { font-size: 7.5px; color: #333; max-width: 80%; position: relative; }

/* ---------- Collections ---------- */
.collections { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 900px) { .collections { grid-template-columns: minmax(0, 1fr); } }
.collection {
  position: relative; display: flex; align-items: center; gap: 22px; min-height: 124px; padding: 22px 26px;
  border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; background: var(--surface);
  transition: transform .2s, box-shadow .2s;
}
.collection:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.collection--office  { background: linear-gradient(120deg, #eef4ff, #e6ecff); }
.collection--stories { background: linear-gradient(120deg, #f4f0ff, #ece6ff); }
.collection--excel   { background: linear-gradient(120deg, #eefaf3, #e1f6ea); }
:root[data-theme="dark"] .collection--office  { background: linear-gradient(120deg, #161c33, #141a2e); }
:root[data-theme="dark"] .collection--stories { background: linear-gradient(120deg, #1c1736, #171330); }
:root[data-theme="dark"] .collection--excel   { background: linear-gradient(120deg, #112219, #0f1d16); }
.collection__icon { width: 74px; height: 74px; flex: none; }
.collection__text { flex: 1; min-width: 0; }
.collection__text strong { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.collection__text span { color: var(--ink-2); font-size: .95rem; }
.collection__go { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); flex: none; transition: transform .2s, background .2s; }
.collection:hover .collection__go { transform: translateX(4px); background: var(--accent); }
.collection:hover .collection__go svg { stroke: #fff; }
.collection__go svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Narrow screens ---------- */
@media (max-width: 720px) {
  .site-header { grid-template-columns: 1fr auto; row-gap: 14px; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .submit-link { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ============================================================
   FULL-PAGE SECTIONS (below the hero)
   ============================================================ */
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section__head h2 { margin-bottom: 0; }
.more { color: var(--accent); font-weight: 600; font-size: .95rem; }
.more:hover { text-decoration: underline; text-underline-offset: 4px; }
.fmt--ppt { background: #d9582b; }

/* Explore by purpose */
.purposes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .purposes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .purposes { grid-template-columns: minmax(0, 1fr); } }
.purpose { display: flex; align-items: center; gap: 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); transition: border-color .2s, box-shadow .2s; }
.purpose:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.purpose strong { display: block; font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.purpose small { color: var(--ink-2); font-size: .85rem; }
.purpose__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; flex: none; }
.purpose__icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.p-violet { background: #ede9ff; color: #5b3ef5; } .p-blue { background: #e4eeff; color: #2b6cde; }
.p-amber { background: #fff1d6; color: #b7791f; } .p-green { background: #def5e8; color: #1d8a4f; }
.p-teal { background: #d9f4f2; color: #0f8a84; } .p-rose { background: #ffe3e8; color: #d43a5a; }
:root[data-theme="dark"] .purpose__icon { background: var(--accent-soft); color: var(--accent-2); }

/* New badge */
.badge-new { position: absolute; bottom: 18px; right: 18px; padding: 3px 10px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700; z-index: 1; }

/* Recently-added previews */
.pv-inv, .pv-plan, .pv-paper, .pv-slide { height: 100%; background: #fff; color: #1b1b2f; border-radius: 6px 6px 0 0; box-shadow: 0 1px 8px rgba(30,30,80,.1); overflow: hidden; padding: 22px 18px 0; font-size: 9px; }
.pv-inv__top { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #1c2340; padding-bottom: 8px; }
.pv-inv__top b { font-size: 17px; letter-spacing: .02em; }
.pv-inv__bill { display: grid; gap: 5px; margin: 16px 0; width: 55%; }
.pv-inv__bill i, .pv-inv__rows i, .pv-inv__rows u, .lines i { display: block; height: 5px; border-radius: 3px; background: #dcdcea; }
.pv-inv__rows { display: grid; gap: 9px; }
.pv-inv__rows span { display: grid; grid-template-columns: 1fr 22%; gap: 10px; padding-bottom: 9px; border-bottom: 1px solid #eee; }
.pv-inv__total { margin-top: 14px; text-align: right; font-size: 10px; } .pv-inv__total b { font-size: 14px; margin-left: 8px; color: #4f35e8; }

.pv-plan { padding: 0 0 8px; }
.pv-plan__title { background: #1d8a4f; color: #fff; font-weight: 700; font-size: 13px; padding: 8px 12px; }
.pv-plan__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 10px; }
.pv-plan__grid b { text-align: center; font-size: 8px; color: #555; }
.pv-plan__grid span { height: 46px; border-radius: 4px; background: #f3f3f8; }
.pv-plan__grid .c1 { background: #bfe3cf; } .pv-plan__grid .c2 { background: #c9dafc; } .pv-plan__grid .c3 { background: #ffe0b3; }

.pv-paper h4 { font-family: var(--serif); font-size: 15px; text-align: center; line-height: 1.25; }
.pv-paper .au { text-align: center; font-size: 7.5px; color: #666; margin: 6px 0 14px; }
.pv-paper h5 { font-size: 9px; margin-bottom: 6px; }
.pv-paper .lines { display: grid; gap: 6px; margin-bottom: 12px; }
.pv-paper .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pv-slide { background: #f4f1ff; padding: 18px; display: grid; grid-template-rows: 1fr auto; gap: 12px; }
.pv-slide__main { background: linear-gradient(135deg, #4f35e8, #8b4df0); color: #fff; border-radius: 8px; padding: 26px 18px; }
.pv-slide__main h4 { font-size: 24px; letter-spacing: -.03em; line-height: 1.05; margin-bottom: 8px; }
.pv-slide__main p { font-size: 9px; opacity: .85; }
.pv-slide__thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-bottom: 14px; }
.pv-slide__thumbs i { height: 44px; background: #fff; border-radius: 5px; box-shadow: 0 1px 4px rgba(30,30,80,.12); }

/* Books & Intelligent Writer (kept quieter than the template sections) */
.eco { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 820px) { .eco { grid-template-columns: minmax(0, 1fr); } }
.eco > div { background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px 26px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.eco h3 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; }
.eco p { color: var(--ink-2); font-size: .95rem; max-width: 46ch; }
.shelf { display: flex; gap: 16px; }
.book { display: flex; align-items: flex-end; width: 104px; aspect-ratio: 2 / 3; padding: 10px; border-radius: 3px 8px 8px 3px; color: #fff; font-family: var(--serif); font-weight: 600; font-size: .72rem; line-height: 1.2; overflow-wrap: anywhere; box-shadow: 4px 6px 14px rgba(30,30,80,.22), inset 5px 0 0 rgba(255,255,255,.18); transition: transform .2s; }
.book:hover { transform: translateY(-4px); }
.book--1 { background: linear-gradient(160deg, #4f35e8, #2a1a8f); } .book--2 { background: linear-gradient(160deg, #0f8a84, #0a4f58); } .book--3 { background: linear-gradient(160deg, #d9582b, #8f2d3f); }
.writer-demo { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font-family: var(--serif); font-size: .9rem; }
.writer-demo b { display: block; font-family: var(--font); font-size: .8rem; color: var(--ink-3); margin-bottom: 4px; font-weight: 600; }
.writer-demo i { display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: kq-blink 1.1s steps(2) infinite; }
@keyframes kq-blink { 50% { opacity: 0; } }
.eco .more { margin-top: auto; }

/* Contribute */
.contribute { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: clamp(24px, 4vw, 40px); border-radius: var(--r-lg); background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; }
.contribute h2 { margin-bottom: 8px; font-size: clamp(1.3rem, 2.8vw, 1.8rem); max-width: 22ch; }
.contribute p { opacity: .9; max-width: 52ch; }
.btn { flex: none; display: inline-block; padding: 14px 26px; border-radius: 999px; background: #fff; color: #3a22c9; font-weight: 700; transition: transform .2s; }
.btn:hover { transform: translateY(-2px); }
@media (max-width: 700px) { .contribute { flex-direction: column; align-items: flex-start; } }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.site-footer__inner { max-width: var(--wrap); margin-inline: auto; padding: 44px var(--pad) 24px; display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 32px; }
@media (max-width: 900px) { .site-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); } .site-footer__brand { grid-column: 1 / -1; } }
.site-footer__brand p { margin-top: 10px; color: var(--ink-2); font-size: .9rem; max-width: 30ch; }
.site-footer h2 { font-size: .95rem; font-weight: 700; margin-bottom: 12px; }
.site-footer li + li { margin-top: 8px; }
.site-footer nav a { color: var(--ink-2); font-size: .9rem; }
.site-footer nav a:hover { color: var(--accent); }
.site-footer__copy { max-width: var(--wrap); margin-inline: auto; padding: 4px var(--pad) 28px; color: var(--ink-3); font-size: .85rem; }

/* ---------- More collection tiles ---------- */
.collection--word       { background: linear-gradient(120deg, #eef4ff, #e3ecff); }
.collection--powerpoint { background: linear-gradient(120deg, #fff3ee, #ffe8df); }
.collection--pdf        { background: linear-gradient(120deg, #fff0f0, #ffe4e5); }
.collection--cv-resume  { background: linear-gradient(120deg, #fff0f3, #ffe4ea); }
.collection--business   { background: linear-gradient(120deg, #eafaf8, #dcf4f1); }
.collection--academic   { background: linear-gradient(120deg, #fff8e8, #fff0cf); }
:root[data-theme="dark"] .collection--word       { background: linear-gradient(120deg, #141c33, #121a30); }
:root[data-theme="dark"] .collection--powerpoint { background: linear-gradient(120deg, #271913, #20150f); }
:root[data-theme="dark"] .collection--pdf        { background: linear-gradient(120deg, #271416, #201113); }
:root[data-theme="dark"] .collection--cv-resume  { background: linear-gradient(120deg, #271420, #20111a); }
:root[data-theme="dark"] .collection--business   { background: linear-gradient(120deg, #102220, #0e1c1a); }
:root[data-theme="dark"] .collection--academic   { background: linear-gradient(120deg, #251f10, #1e190d); }

/* ---------- Browse by collection: one scrollable row ---------- */
.collections {
  display: flex; grid-template-columns: none; gap: 18px; overflow-x: auto;
  scroll-snap-type: x proximity; scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  padding: 6px var(--pad) 14px; margin: -6px calc(var(--pad) * -1) -14px;
}
.collections > li { display: flex; flex: 0 0 clamp(300px, 32vw, 370px); scroll-snap-align: start; }
.collections > li > .collection { flex: 1; }
.collection__icon { width: 64px; height: 64px; }
.collection__text strong { font-size: 1.3rem; }

/* ---------- Template preview + download dialog (download.js) ---------- */
html.tdlg-open { overflow: hidden; }
.tdlg { border: 0; padding: 0; background: transparent; color: var(--ink); width: min(940px, calc(100vw - 24px)); max-height: calc(100vh - 24px); margin: auto; }
.tdlg::backdrop { background: rgba(15, 15, 43, .6); backdrop-filter: blur(3px); }
.tdlg__box { position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); max-height: calc(100vh - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 24px 70px rgba(10, 10, 40, .35); overflow: hidden; }
.tdlg__close { position: absolute; top: 10px; right: 12px; z-index: 2; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface); color: var(--ink-2); font-size: 1.6rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.tdlg__close:hover { color: var(--accent); }
.tdlg__preview { display: grid; place-items: start center; padding: 24px 22px; background: var(--surface-alt); overflow: auto; }
.tdlg__wrap { position: relative; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-hover); }
.tdlg__stage { transform-origin: top left; }
.tdlg__img { display: block; max-width: 100%; height: auto; border-radius: 10px; box-shadow: var(--shadow-hover); }
.tdlg__bigfmt { width: 96px; height: 96px; font-size: 2.2rem; border-radius: 22px; align-self: center; }
.tdlg__info { display: flex; flex-direction: column; gap: 12px; padding: 30px 30px 26px; overflow: auto; }
.tdlg__meta { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink-3); font-size: .85rem; font-weight: 600; letter-spacing: .02em; }
.tdlg__title { margin: 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -.02em; }
.tdlg__desc { margin: 0; color: var(--ink-2); }
.tdlg__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--ink-2); font-size: .92rem; }
.tdlg__list li { position: relative; padding-left: 24px; }
.tdlg__list li::before { content: "\2713"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }
.tdlg__price { margin: 4px 0 0; font-size: 1.1rem; font-weight: 700; }
.tdlg__actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tdlg__dl { appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; color: #fff; padding: 13px 26px; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: var(--shadow); }
.tdlg__dl:hover { filter: brightness(1.07); }
.tdlg__dl[disabled] { opacity: .65; cursor: progress; }
.tdlg__dl:focus-visible, .tdlg__close:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.tdlg__status { min-height: 1.4em; margin: 0; font-size: .9rem; color: var(--ink-2); }
.tdlg__status a { color: var(--accent); font-weight: 600; text-decoration: underline; }
@media (max-width: 760px) {
  .tdlg__box { grid-template-columns: 1fr; overflow: auto; }
  .tdlg__preview { max-height: 250px; padding: 16px; }
  .tdlg__info { padding: 22px 20px 22px; overflow: visible; }
}

/* ---------- Download button (injected by download.js) ---------- */
.download {
  position: absolute; right: 12px; bottom: 12px; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); transition: background .2s, color .2s;
}
.download svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.download:hover, .download:focus-visible { background: var(--accent); color: #fff; }
