/* =========================================================================
   Relatably design system. Apple-grade: soft, clean, fast, mobile-first.
   article.css and editor.css are loaded as parallel <link>s in base.html
   (editor.css only on the tool pages) to avoid render-blocking @import.
   ========================================================================= */
:root {
  --bg: #fbfbfd;            /* Apple near-white */
  --bg-sub: #f5f5f7;        /* subtle section tint */
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --text: #1d1d1f;          /* Apple ink, warmer than pure black */
  --muted: #6e6e73;         /* Apple secondary gray */
  --faint: #86868b;         /* tertiary gray */
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.13);
  --hairline: rgba(0, 0, 0, 0.10);
  --accent: #6d4aff;        /* refined violet */
  --accent-hover: #5a36f0;
  --accent-soft: rgba(109, 74, 255, 0.08);
  --accent-2: #ec4899;
  --accent-3: #2563eb;
  --ok: #1d9c5b;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --max: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 17px;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
/* Default size for inline icons. Specific contexts (.btn svg, .tool-icon svg) override. */
svg.ic { width: 1.1em; height: 1.1em; vertical-align: -0.16em; flex: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 22px; }
.section { padding: 72px 0; }
.section-tight { padding: 40px 0; }
/* Alternating tint gives rhythm without shadows. */
.section-alt { background: var(--bg-sub); border-block: 1px solid var(--border); }

h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 600; color: var(--text); }
h1 { font-size: clamp(2.3rem, 5.2vw, 3.6rem); line-height: 1.06; letter-spacing: -0.025em; font-weight: 700; }
h2 { font-size: clamp(1.55rem, 3vw, 2.25rem); line-height: 1.12; letter-spacing: -0.022em; font-weight: 650; }
h3 { font-size: 1.15rem; line-height: 1.25; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }

.lead { font-size: clamp(1.12rem, 1.6vw, 1.28rem); line-height: 1.5; color: var(--muted); letter-spacing: -0.012em; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Skip link for accessibility */
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 200;
  background: var(--surface-solid); color: var(--text);
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border-strong);
}
.skip-link:focus { left: 12px; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; font-size: 1rem; letter-spacing: -0.012em;
  padding: 12px 22px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; transition: transform .22s var(--ease), background .2s, border-color .2s, color .2s;
  text-decoration: none; white-space: nowrap; min-height: 44px;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { color: #fff; background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { color: var(--text); background: rgba(0,0,0,0.04); border-color: transparent; }
.btn-secondary:hover { background: rgba(0,0,0,0.07); }
.btn-ghost { background: transparent; color: var(--accent); border-color: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; min-height: 36px; }
.btn-block { width: 100%; }

/* ---- Surfaces --------------------------------------------------------- */
/* Depth without shadows: a frosted fill + a single hairline ring. */
.glass {
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: border-color .22s var(--ease), background .22s var(--ease), transform .22s var(--ease);
}

/* ---- Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(251, 251, 253, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 1.12rem; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; }
.header-search { flex: 1; max-width: 440px; margin: 0 auto; }
.search-form { display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.05); border: 1px solid transparent;
  border-radius: 12px; padding: 6px 7px 6px 14px; transition: background .2s, border-color .2s; }
.search-form:focus-within { background: var(--surface-solid); border-color: var(--border-strong); }
.search-form svg { width: 17px; height: 17px; color: var(--faint); flex: none; }
.search-form input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 0.94rem; min-width: 0; }
.search-form button { border: 0; cursor: pointer; }
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: auto; }
/* Exclude the CTA so it keeps its primary-button styling (white text). */
.nav-links a:not(.nav-cta) { color: var(--text); font-weight: 450; font-size: 0.94rem; padding: 8px 12px; border-radius: 9px; transition: background .18s; }
.nav-links a:not(.nav-cta):hover { background: rgba(0,0,0,0.05); text-decoration: none; }
.nav-links a.nav-cta { color: #fff; }
.nav-cta { margin-left: 8px; }
.nav-toggle { display: none; margin-left: auto; background: transparent; border: 1px solid var(--border-strong);
  border-radius: 11px; width: 42px; height: 42px; align-items: center; justify-content: center; cursor: pointer; color: var(--text); }
.nav-toggle svg { width: 22px; height: 22px; }

/* ---- Hero ------------------------------------------------------------- */
.hero { padding: 80px 0 48px; }
.hero-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 56px; align-items: center; }
.hero .lead { margin-bottom: 30px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-trust { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 26px; color: var(--muted); font-size: 0.9rem; }
.hero-trust span { display: inline-flex; align-items: center; gap: 7px; }
.hero-trust svg { width: 16px; height: 16px; color: var(--ok); }

/* Live preview card */
.preview-card { padding: 16px; border-radius: var(--radius-lg); }
.preview-canvas {
  aspect-ratio: 1 / 1; border-radius: var(--radius-md); overflow: hidden;
  display: grid; place-items: center; text-align: center; padding: 34px;
  background: linear-gradient(150deg, #ede9fe, #fce7f3 55%, #dbeafe);
  position: relative;
}
.preview-canvas .pq { font-size: clamp(1.15rem, 2.4vw, 1.65rem); font-weight: 600; color: #1f2937; letter-spacing: -0.018em; line-height: 1.25; }
.preview-canvas .pa { margin-top: 14px; font-size: 0.85rem; color: #6b7280; }
.preview-toolbar { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; padding: 0 2px; }
.swatch { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); cursor: pointer; transition: transform .2s var(--ease); }
.swatch:hover { transform: scale(1.1); }
.swatch-photo { background-size: cover; background-position: center; border-color: var(--accent); outline: 1px solid var(--accent); }

/* Bookmark reminder bar (top of every page, dismissible) */
.bm-dismissed .bookmark-bar { display: none; }
.bookmark-bar { background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.bookmark-inner { position: relative; display: flex; align-items: center; justify-content: center; padding: 9px 44px; min-height: 40px; }
.bookmark-bar p { margin: 0; font-size: 0.86rem; color: var(--text); display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: center; text-align: center; line-height: 1.4; }
.bookmark-bar strong { font-weight: 700; }
.bookmark-bar svg.ic { color: var(--accent); width: 1.05em; height: 1.05em; flex: none; }
.bookmark-bar kbd { font-family: var(--font); font-size: 0.74em; font-weight: 600; background: var(--surface-solid); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--text); }
.bookmark-bar p > span { color: var(--muted); }
.bookmark-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; line-height: 0; }
.bookmark-close:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.bookmark-close svg.ic { width: 18px; height: 18px; color: inherit; }
@media (max-width: 640px) {
  /* The bookmark prompt relies on Ctrl/Cmd+D, which mobile browsers do not
     support, so it only consumes the first screen on phones. Hide it there. */
  .bookmark-bar { display: none; }
}
.preview-tag { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,0.9);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 11px; font-size: 0.72rem; font-weight: 600; color: var(--muted); }

/* ---- Section heading -------------------------------------------------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 32px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 8px 0 0; color: var(--muted); }
.section-head .link-more { font-weight: 500; font-size: 0.95rem; white-space: nowrap; }

/* ---- Tool cards ------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.tools-grid { grid-template-columns: repeat(3, 1fr); }
.tools-grid.two { grid-template-columns: repeat(2, 1fr); }

/* Live activity sections */
.activity-grid { grid-template-columns: repeat(2, 1fr); }
.activity-card { display: flex; flex-direction: column; gap: 16px; }
.activity-head { display: flex; align-items: center; gap: 14px; }
.activity-head .t-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none; }
.activity-head .t-icon svg { width: 23px; height: 23px; }
.activity-count { font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.activity-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.activity-feed li { display: flex; align-items: center; gap: 9px; font-size: 0.88rem; color: var(--muted); }
.activity-feed li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.activity-feed li.fresh::before { background: var(--accent); outline: 4px solid var(--accent-soft); }
.activity-card .btn { align-self: flex-start; margin-top: auto; }

/* Homepage wall: published creation thumbnails */
.wall-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.wall-pick {
  display: block; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface, #fff);
}
.wall-pick:hover { border-color: var(--border-strong); transform: translateY(-2px); text-decoration: none; }
.wall-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Published creation page */
.creation-page { max-width: 720px; margin: 0 auto; padding-top: 30px; padding-bottom: 60px; text-align: center; }
.creation-kicker { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }
.creation-title { font-size: 1.6rem; line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 22px; }
.creation-figure { margin: 0 0 18px; }
.creation-figure img {
  max-width: 100%; height: auto; border-radius: 16px; border: 1px solid var(--border);
}
.creation-page .share-bar { justify-content: center; margin: 0 0 26px; }
.creation-cta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 18px; text-align: left; padding: 22px 24px; margin-bottom: 18px;
}
.creation-cta h2 { font-size: 1.15rem; }
.creation-cta-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.creation-note { font-size: 0.82rem; margin: 0; }
@media (max-width: 560px) {
  .wall-grid { grid-template-columns: repeat(3, 1fr); }
  .creation-cta { flex-direction: column; align-items: stretch; }
}
.trust-grid.three { grid-template-columns: repeat(3, 1fr); }
.tool-card { display: flex; flex-direction: row; align-items: flex-start; gap: 18px; padding: 26px; }
.tool-card:hover { transform: translateY(-3px); border-color: var(--border-strong); text-decoration: none; }
.tool-card-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.tool-icon {
  width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; flex: none;
}
.tool-icon svg { width: 25px; height: 25px; }
.tool-card h3 { margin: 0; color: var(--text); }
.tool-card p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.45; }
.tool-card .tool-go { margin-top: auto; display: inline-flex; align-items: center; gap: 5px; font-weight: 500; color: var(--accent); font-size: 0.92rem; }
.tool-card .tool-go svg { width: 15px; height: 15px; transition: transform .25s var(--ease); }
.tool-card:hover .tool-go svg { transform: translateX(4px); }

/* ---- Topic chips / cards ---------------------------------------------- */
.topic-grid { grid-template-columns: repeat(4, 1fr); }
.topic-card { display: flex; align-items: center; gap: 13px; padding: 16px 18px; }
.topic-card:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.topic-card .t-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; }
.topic-card .t-icon svg { width: 20px; height: 20px; }
.topic-card .t-name { font-weight: 550; color: var(--text); }
.topic-card .t-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.35; }

.chip-row { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 10px;
  background: rgba(0,0,0,0.04); border: 1px solid transparent; color: var(--text);
  font-weight: 450; font-size: 0.91rem; transition: background .2s var(--ease), border-color .2s var(--ease);
}
.chip:hover { background: var(--surface-solid); border-color: var(--border-strong); text-decoration: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---- Masonry template gallery ----------------------------------------- */
.masonry { columns: 4 240px; column-gap: 16px; }
.masonry .tpl { break-inside: avoid; margin-bottom: 16px; }
.tpl { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); background: var(--surface-solid); transition: transform .25s var(--ease), border-color .25s var(--ease); display: block; }
.tpl:hover { transform: translateY(-3px); border-color: var(--border-strong); text-decoration: none; }
.tpl-preview { display: grid; place-items: center; text-align: center; padding: 30px 24px; color: #fff; font-weight: 600; letter-spacing: -0.01em; min-height: 150px; }
.tpl-preview .tpl-line { font-size: 1.05rem; }
.tpl-meta { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tpl-meta .tpl-info { min-width: 0; }
.tpl-meta .tpl-title { font-weight: 550; color: var(--text); font-size: 0.95rem; }
.tpl-meta .tpl-sub { font-size: 0.8rem; color: var(--muted); }

.category-grid { align-items: stretch; }
.template-category-card { display: flex; flex-direction: column; gap: 10px; }
.template-category-card h3 { margin: 0; font-size: 1.05rem; }
.template-category-card p { margin: 0; color: var(--muted); }
.tpl-count { width: fit-content; border-radius: 999px; padding: 5px 10px; background: var(--surface); color: var(--accent); font-weight: 650; font-size: 0.82rem; }
.meme-template-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: stretch; }
.meme-template-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 100%; }
.meme-template-thumb { display: grid; place-items: center; aspect-ratio: 1 / 1; background: #f4f4f5; overflow: hidden; }
.meme-template-thumb img,
.meme-template-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.meme-template-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.meme-template-meta > span:first-child { min-width: 0; }
.meme-template-meta .tpl-title,
.meme-template-meta .tpl-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-detail-layout { display: grid; grid-template-columns: minmax(260px, 480px) 1fr; gap: 28px; align-items: start; }
.template-preview-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #f4f4f5; }
.template-preview-card img,
.template-preview-card video { width: 100%; height: auto; display: block; }
.template-facts h2 { margin-top: 0; }

@media (max-width: 760px) {
  .template-detail-layout { grid-template-columns: 1fr; }
  .meme-template-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
}

/* Heights to vary the masonry rhythm */
.tpl:nth-child(3n) .tpl-preview { min-height: 200px; }
.tpl:nth-child(4n) .tpl-preview { min-height: 176px; }

/* ---- Guide / article cards -------------------------------------------- */
.guide-grid { grid-template-columns: repeat(3, 1fr); }
.guide-card { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.guide-card:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.guide-card .g-cluster { font-size: 0.76rem; font-weight: 600; color: var(--accent); letter-spacing: 0.01em; }
.guide-card h3 { margin: 0; color: var(--text); font-size: 1.08rem; }
.guide-card p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.badge-pillar { display: inline-block; font-size: 0.68rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; }

/* ---- Trust strip ------------------------------------------------------ */
.trust-grid { grid-template-columns: repeat(4, 1fr); }
.trust-item { display: flex; flex-direction: row; gap: 16px; align-items: flex-start; padding: 22px; }
.trust-item .t-i { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.trust-item .t-i svg { width: 20px; height: 20px; }
.trust-item h3 { margin: 0 0 2px; font-size: 1rem; }
.trust-item p { margin: 0; font-size: 0.88rem; color: var(--muted); line-height: 1.45; }

/* ---- Breadcrumbs ------------------------------------------------------ */
/* padding-top only, so the .container left/right padding is preserved and the
   breadcrumb lines up with the logo and the page content margin. */
.breadcrumbs { padding-top: 20px; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0; padding: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 7px; }
.breadcrumbs li::after { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--border-strong); border-top: 1.5px solid var(--border-strong); transform: rotate(45deg); }
.breadcrumbs li:last-child::after { display: none; }
.breadcrumbs a { color: var(--muted); display: inline-flex; align-items: center; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs li:first-child a svg { width: 16px; height: 16px; }
.breadcrumbs li:last-child span { color: var(--text); font-weight: 500; }
/* On phones a deep trail (Home > Templates > Category > Title) stacks into 3+
   ugly lines. Keep it to one swipeable line instead, with all crumbs intact. */
@media (max-width: 600px) {
  .breadcrumbs ol { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .breadcrumbs ol::-webkit-scrollbar { display: none; }
  .breadcrumbs li { white-space: nowrap; flex: none; }
}

/* ---- Footer ----------------------------------------------------------- */
.site-footer { margin-top: 0; border-top: 1px solid var(--border); background: var(--bg-sub); }
.footer-brand p { color: var(--muted); font-size: 0.92rem; }
.footer-heading { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); margin: 0 0 14px; font-weight: 600; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.footer-col a { color: var(--muted); font-size: 0.92rem; }
.footer-col a:hover { color: var(--text); }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 0 44px; border-top: 1px solid var(--border); color: var(--faint); font-size: 0.85rem; }
.footer-bottom .footer-legal { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-bottom a { color: var(--faint); }
.footer-bottom a:hover { color: var(--text); }

/* footer columns */
.footer-cols { display: grid; grid-template-columns: repeat(5, 1fr); gap: 28px; padding: 48px 0 32px; }

/* ---- Forms (used by the editors and the contact page) ----------------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=search],
.field input[type=number], .field textarea, .field select {
  width: 100%; font: inherit; font-size: 0.95rem; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text);
  transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 1px; }

/* ---- Legal pages ------------------------------------------------------ */
.legal-contents { columns: 2; column-gap: 28px; margin: 6px 0 0; padding: 0; list-style: none; }
.legal-contents li { break-inside: avoid; margin-bottom: 7px; }
.legal-contents a { font-size: 0.9rem; color: var(--muted); }
.legal-contents a:hover { color: var(--accent); }
.article-body h2[id] { scroll-margin-top: 86px; padding-top: 6px; }
.article-body h3 { margin-top: 1.3em; }
@media (max-width: 600px) { .legal-contents { columns: 1; } }

/* ---- Page intro ------------------------------------------------------- */
.page-head { padding: 36px 0 10px; }
.page-head h1 { margin-bottom: 12px; }
.page-head .lead { max-width: none; }

/* ---- Tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 20px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; background: var(--surface-solid); }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--border); }
th { background: var(--bg-sub); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.01em; color: var(--muted); text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(0,0,0,0.015); }

/* ---- Utility ---------------------------------------------------------- */
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 1000px) {
  .tools-grid, .guide-grid, .trust-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .masonry { columns: 3 200px; }
  .footer-cols { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 30px; }
  .hero { padding: 36px 0 20px; }
  .header-search { display: none; }
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .footer-top { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  /* Mobile type scale: the desktop clamp() floors (h1 2.3rem, h2 1.55rem) are
     too tall for a phone and force long titles onto 3+ lines. Re-scale here so
     headings stay proportionate and readable on small screens. */
  h1 { font-size: clamp(1.7rem, 7vw, 2.15rem); line-height: 1.14; }
  h2 { font-size: 1.34rem; line-height: 1.22; }
  h3 { font-size: 1.05rem; }
  .lead { font-size: 1.05rem; }
  .page-head { padding: 26px 0 8px; }
  .section { padding: 40px 0; }
  /* Collapse every card grid to one column. The .two/.three variants carry an
     extra class, so they must be named explicitly or their higher specificity
     keeps the multi-column track list and overflows the viewport. */
  .tools-grid, .tools-grid.two, .guide-grid, .trust-grid, .trust-grid.three,
  .topic-grid, .activity-grid { grid-template-columns: 1fr; }
  .masonry { columns: 2 150px; column-gap: 12px; }
  .masonry .tpl { margin-bottom: 12px; }
  .footer-cols { grid-template-columns: repeat(2, 1fr); }
  .hero-cta .btn { flex: 1; }
  /* Info cards: icon-on-top wastes vertical space on a phone. Lay them out as a
     compact row (icon left, text right) so more fits on screen. All .trust-item
     uses share the same icon-span + text-div structure, so this is safe. */
  .trust-item { flex-direction: row; align-items: flex-start; gap: 14px; padding: 16px 18px; }
  .trust-item .t-i { width: 38px; height: 38px; }
  /* Same for the larger tool cards: icon beside the text, not stacked on top. */
  .tool-card { flex-direction: row; align-items: flex-start; gap: 16px; padding: 20px; }
  /* Data tables: at phone width the columns get crushed and text wraps one word
     per line. Give the table a min-width so .table-wrap scrolls horizontally and
     each column keeps a readable measure instead. */
  .table-wrap table { min-width: 520px; }
  th, td { padding: 11px 14px; }
  /* Footer: tighten the spacing and drop the bottom-bar Privacy/Terms/Copyright,
     which already appear in the Legal column right above (no duplicate tap rows). */
  .footer-cols { gap: 28px 20px; padding: 36px 0 20px; }
  .footer-bottom { padding: 18px 0 32px; }
  .footer-bottom .footer-legal { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Mobile drawer */
.mobile-drawer { display: none; }
/* Solid, fully opaque fill so page content never shows through (a translucent
   rgba + backdrop-filter does not composite opaquely on every browser). */
.mobile-drawer.open { display: block; position: fixed; inset: 60px 0 0; z-index: 95;
  background: var(--bg); padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mobile-drawer .m-search { margin-bottom: 14px; }
.mobile-drawer nav { display: grid; gap: 10px; }
.mobile-drawer nav a { display: flex; align-items: center; min-height: 54px; padding: 15px 18px;
  border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border);
  color: var(--text); font-weight: 550; font-size: 1.05rem; }
.mobile-drawer nav a:hover, .mobile-drawer nav a:active { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }

/* =========================================================================
   Meme template directory (SSR /meme-templates)
   ========================================================================= */
.tpl-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tpl-cat-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.tpl-cat-shots { display: flex; gap: 6px; }
.tpl-cat-shots img { width: 33%; height: 84px; object-fit: cover; border-radius: 8px; background: #0f172a; }
.tpl-cat-name { font-weight: 650; display: block; }
.tpl-dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tpl-dir-card { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.tpl-dir-card img, .tpl-dir-card video {
  width: 100%; height: 150px; object-fit: cover; border-radius: 10px;
  background: #0f172a; border: 1px solid rgba(17,24,39,0.08);
}
.tpl-dir-name { font-size: 0.82rem; color: var(--text); line-height: 1.25; }
.tpl-dir-card:hover { text-decoration: none; }
.tpl-dir-card:hover .tpl-dir-name { color: var(--accent); }
.tpl-pager { display: flex; align-items: center; gap: 16px; justify-content: center; margin-top: 28px; }
.tpl-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.tpl-detail-media img, .tpl-detail-media video { width: 100%; height: auto; border-radius: 14px; border: 1px solid rgba(17,24,39,0.08); background: #0f172a; }
/* Spec-sheet card: each fact is a row with a muted label and a bold value,
   separated by hairlines — far more scannable than floating label/value pairs. */
.tpl-facts { margin: 22px 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-solid); overflow: hidden; }
.tpl-facts div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 13px 16px; }
.tpl-facts div + div { border-top: 1px solid var(--border); }
.tpl-facts dt { margin: 0; color: var(--muted); font-size: 0.9rem; flex: none; }
.tpl-facts dd { margin: 0; font-weight: 600; text-align: right; }
@media (max-width: 720px) { .tpl-detail-grid { grid-template-columns: 1fr; } }
.tpl-detail-copy { margin: 36px 0 0; }
.tpl-detail-copy h2 { margin-top: 26px; }
.tpl-detail-copy p, .tpl-detail-copy li { line-height: 1.65; }

/* Caption ideas list on a template detail page */
.caption-ideas { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.caption-ideas li {
  background: var(--card, #fff); border: 1px solid var(--border, #e6e8f0);
  border-radius: 10px; padding: 12px 14px; line-height: 1.55;
}

/* Category page explainer ("How to use ... templates") */
.tpl-cat-about { max-width: none; }
.tpl-cat-about h2 { margin-top: 8px; }
.tpl-cat-about p { line-height: 1.65; }

/* "How it works" step cards: a numbered, gradient-badged flow that replaces a
   plain ordered list. Count-agnostic (auto-fit), with a faint watermark numeral. */
.steps { list-style: none; margin: 26px 0 0; padding: 0; counter-reset: step;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.step { counter-increment: step; position: relative; overflow: hidden;
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px 22px;
  display: flex; flex-direction: column; gap: 16px;
  transition: transform .22s var(--ease), border-color .22s; }
.step:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.step-num { width: 46px; height: 46px; flex: none; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.step-text { margin: 0; color: var(--text); line-height: 1.55; }
.step::after { content: counter(step); position: absolute; right: 12px; bottom: -16px;
  font-size: 4.6rem; font-weight: 800; line-height: 1; color: var(--accent);
  opacity: 0.06; pointer-events: none; }
@media (max-width: 600px) {
  .steps { grid-template-columns: 1fr; gap: 12px; }
  .step { flex-direction: row; align-items: center; padding: 16px 18px; }
  .step-num { width: 40px; height: 40px; font-size: 1.05rem; }
}

/* Hero preview card: swatches + a clear call to action */
.preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.preview-actions .preview-toolbar { margin-top: 0; }
.preview-cta { white-space: nowrap; }

/* =========================================================================
   Quote collections directory (/quotes)
   ========================================================================= */
.quote-col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.quote-col-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
.quote-col-card h2 { margin: 0; font-size: 1.15rem; }
.quote-col-sample { color: var(--muted); font-style: italic; line-height: 1.5; margin: 0; }
.quote-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.quote-item { padding: 18px 20px; }
.quote-item blockquote { margin: 0 0 12px; font-size: 1.05rem; line-height: 1.5; color: var(--text); }
.quote-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quote-meta cite { color: var(--muted); font-style: normal; font-weight: 600; }

/* Homepage informational sections */
.about-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 44px; align-items: center; }
.about-block { max-width: none; }
.about-block h2 { margin-bottom: 14px; }
.about-block p { color: var(--muted); line-height: 1.7; margin: 0 0 14px; }
.about-block p a { color: var(--accent); }
.about-card { padding: 28px; display: grid; gap: 22px; }
.about-card .stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 16px; }
.about-card .stat-list strong { display: block; font-size: 1.6rem; color: var(--text); line-height: 1.05; }
.about-card .stat-list span { color: var(--muted); font-size: 0.9rem; }
.about-card .btn { justify-content: center; }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; gap: 28px; } .about-block { max-width: none; } }
a.trust-item { transition: transform .2s var(--ease), border-color .2s var(--ease); }
a.trust-item:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--border-strong); }
a.trust-item .tool-go { margin-top: 10px; display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: 0.9rem; }
