/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --theme: #7c3aed;
  --theme-fg: var(--theme);
  --theme-light: color-mix(in srgb, var(--theme) 12%, white);
  --theme-dark: color-mix(in srgb, var(--theme) 80%, black);
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12), 0 8px 32px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Dark theme variables ────────────────────────────────────────────────── */
.dark-vars {
  --theme-light: color-mix(in srgb, var(--theme) 22%, #16162a);
  --theme-dark: color-mix(in srgb, var(--theme) 80%, white);
  --text: #e2e8f0;
  --text-muted: #8892b0;
  --bg: #0e0e18;
  --card-bg: #16162a;
  --border: #2a2a42;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.5), 0 8px 32px rgba(0,0,0,.4);
}
/* System preference — applies unless user has explicitly chosen light */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) { --theme-fg: color-mix(in srgb, var(--theme) 35%, #e2e8f0); --theme-light: color-mix(in srgb, var(--theme) 22%, #16162a); --theme-dark: color-mix(in srgb, var(--theme) 80%, white); --text: #e2e8f0; --text-muted: #8892b0; --bg: #0e0e18; --card-bg: #16162a; --border: #2a2a42; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --shadow-hover: 0 4px 12px rgba(0,0,0,.5), 0 8px 32px rgba(0,0,0,.4); }
}
/* Explicit dark — overrides system preference */
html[data-theme="dark"] { --theme-fg: color-mix(in srgb, var(--theme) 35%, #e2e8f0); --theme-light: color-mix(in srgb, var(--theme) 22%, #16162a); --theme-dark: color-mix(in srgb, var(--theme) 80%, white); --text: #e2e8f0; --text-muted: #8892b0; --bg: #0e0e18; --card-bg: #16162a; --border: #2a2a42; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --shadow-hover: 0 4px 12px rgba(0,0,0,.5), 0 8px 32px rgba(0,0,0,.4); }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--theme-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-inner {
  display: flex; align-items: center; gap: 1.5rem;
  padding-top: .75rem; padding-bottom: .75rem;
}
.site-brand { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.site-logo { height: 56px; width: auto; object-fit: contain; }
.site-name { font-size: 1.25rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.site-name:hover { text-decoration: none; }
.header-designer-name { font-size: 1.4rem; font-weight: 800; color: var(--text); letter-spacing: -.03em; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.site-nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.nav-link {
  padding: .4rem .75rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  background: none; border: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active { background: var(--theme-light); color: var(--theme-fg); text-decoration: none; }
.nav-dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + .5rem); right: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 200px;
  box-shadow: var(--shadow); z-index: 200;
  max-height: 360px; overflow-y: auto;
}
.nav-dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem 1rem; color: var(--text); font-size: .875rem;
  transition: background .1s;
}
.dropdown-item:hover { background: var(--theme-light); text-decoration: none; }
.dropdown-item-all { font-weight: 600; color: var(--theme-fg); }
.dropdown-divider { height: 1px; background: var(--border); margin: .25rem 0; }
.tag-count {
  background: var(--theme-light); color: var(--theme-fg);
  border-radius: 9999px; padding: .1rem .4rem; font-size: .75rem;
}

/* ── Search ─────────────────────────────────────────────────────────────── */
.header-search {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9999px; padding: .3rem .5rem .3rem 1rem;
  gap: .25rem;
}
.header-search input {
  border: none; background: none; outline: none;
  font-size: .875rem; width: 180px; color: var(--text);
}
.header-search button {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: .1rem .25rem;
  display: flex; align-items: center;
}
.header-search button:hover { color: var(--theme-fg); }
.nav-hamburger {
  display: none; background: none; border: none;
  font-size: 1.25rem; cursor: pointer; padding: .25rem;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.site-main { padding: 2rem 0 4rem; min-height: calc(100vh - 64px - 80px); }

/* ── Designs Grid ────────────────────────────────────────────────────────── */
.designs-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 4), minmax(0, 1fr));
  gap: 1.5rem; margin-top: 1.5rem;
}

/* ── Infinite scroll ─────────────────────────────────────────────────────── */
.scroll-sentinel { height: 1px; }
.scroll-loader {
  display: flex; justify-content: center; align-items: center;
  gap: .6rem; padding: 2rem; color: var(--text-muted); font-size: .9rem;
}
.scroll-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--theme);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scroll-end {
  text-align: center; padding: 1.5rem; color: var(--text-muted);
  font-size: .85rem; border-top: 1px solid var(--border); margin-top: 1rem;
}

/* ── Design Card ─────────────────────────────────────────────────────────── */
.design-card {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.design-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-image-wrap { display: block; background: var(--bg); }
.card-image-wrap img { width: 100%; height: auto; display: block; }
.card-image-placeholder {
  width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  color: var(--border);
}
.card-body { padding: 1rem 1.25rem 1.25rem; }
.card-category {
  display: inline-block; font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--theme-fg); margin-bottom: .35rem;
}
.card-category:hover { text-decoration: none; opacity: .8; }
.card-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: .5rem; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--theme-fg); text-decoration: none; }
.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .5rem; }
.card-date { font-size: .8rem; color: var(--text-muted); }

/* ── Tag Pill ─────────────────────────────────────────────────────────────── */
.tag-pill {
  display: inline-block; padding: .15rem .6rem; border-radius: 9999px;
  background: var(--theme-light); color: var(--theme-fg);
  font-size: .75rem; font-weight: 500;
  transition: background .15s;
}
.tag-pill:hover, .tag-pill.active { background: var(--theme); color: var(--theme-text, #fff); text-decoration: none; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: .5rem; padding: .75rem 1rem;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: 1rem;
}
.filter-label { font-weight: 600; font-size: .875rem; color: var(--text-muted); }
.filter-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .75rem; background: var(--theme-light);
  color: var(--theme-fg); border-radius: 9999px; font-size: .8rem;
}
.filter-chip a { color: var(--theme-fg); font-weight: 700; }
.clear-filters { margin-left: auto; font-size: .8rem; color: var(--text-muted); }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex; justify-content: center; gap: .5rem; margin-top: 2.5rem;
}
.page-btn {
  padding: .4rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text);
  font-size: .875rem; background: var(--card-bg);
  transition: background .15s, color .15s;
}
.page-btn:hover { background: var(--theme-light); color: var(--theme-fg); text-decoration: none; }
.page-btn.active { background: var(--theme); color: var(--theme-text, #fff); border-color: var(--theme); }

/* ── Design Detail ───────────────────────────────────────────────────────── */
.design-detail { padding-bottom: 4rem; }
.design-hero { margin-bottom: 2rem; border-radius: var(--radius); overflow: hidden; }
.design-hero-img { width: 100%; max-height: 480px; object-fit: contain; }
.design-header { margin-bottom: 2rem; }
.design-meta-top { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.design-category {
  display: inline-block; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--theme-fg);
}
.design-date { font-size: .875rem; color: var(--text-muted); }
.design-title { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; margin-bottom: .75rem; }
.design-tags { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ── Platform Links ──────────────────────────────────────────────────────── */
.design-links { margin: 2rem 0; padding: 1.5rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.links-heading { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.links-grid { display: flex; flex-wrap: wrap; gap: .75rem; }
/* Inline social/platform icons inherit the button's text color (theme-matching) */
.platform-btn .link-icon,
.social-btn .link-icon { width: 18px; height: 18px; flex: none; fill: currentColor; }
.platform-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 600;
  transition: opacity .15s, transform .1s;
  color: #fff; text-decoration: none;
}
.platform-btn:hover { opacity: .9; transform: translateY(-1px); text-decoration: none; }
.link-patreon       { background: #000000; }
.link-patreon-store { background: #202020; }
.link-thangs      { background: #479dea; }
.link-mmf         { background: #55bba2; }
.link-cults       { background: #7432e5; }
.link-printables  { background: #e77c56; }
.link-makerworld  { background: #ffffff; color: #111111; border: 1px solid #e5e7eb; }
.link-website     { background: var(--theme); color: var(--theme-text, #fff); }

/* ── Design Description ──────────────────────────────────────────────────── */
.design-description {
  max-width: 760px; font-size: 1.0625rem; line-height: 1.75;
}
.design-description h1,.design-description h2,.design-description h3,
.design-description h4 { margin: 1.5em 0 .5em; line-height: 1.3; }
.design-description p { margin-bottom: 1em; }
.design-description ul,.design-description ol { margin: .75em 0 .75em 1.5em; }
.design-description li { margin-bottom: .25em; }
.design-description blockquote {
  border-left: 4px solid var(--theme); padding: .5em 1em;
  color: var(--text-muted); margin: 1em 0; font-style: italic;
}
.design-description pre {
  background: #1e1e2e; color: #cdd6f4;
  padding: 1em 1.25em; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 1em 0; font-size: .875em;
}
.design-description code { background: var(--bg); padding: .1em .35em; border-radius: 4px; font-size: .875em; }
.design-description pre code { background: none; padding: 0; }
.design-description .md-img { border-radius: var(--radius-sm); margin: 1em 0; max-height: 600px; object-fit: contain; }
.design-description hr { border: none; border-top: 2px solid var(--border); margin: 2em 0; }
.design-description a { color: var(--theme-fg); text-decoration: underline; }

/* ── Related Designs ─────────────────────────────────────────────────────── */
.related-section { padding: 2.5rem 0 3rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.related-heading { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.5rem; }
.related-grid { margin-top: 0; }

/* ── Collections ─────────────────────────────────────────────────────────── */
.page-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; margin: 1.5rem 0 1rem; }
.collections-featured-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem; margin-top: 1rem; margin-bottom: 2rem;
}
.collection-card-featured {
  background: var(--theme); color: var(--theme-text, #fff);
  border-radius: var(--radius); padding: 1.5rem 1.25rem;
  display: flex; flex-direction: column; gap: .4rem;
  text-decoration: none;
  transition: box-shadow .2s, opacity .15s, transform .2s;
  box-shadow: var(--shadow);
}
.collection-card-featured:hover { opacity: .9; transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.collection-card-featured .collection-name { font-size: 1.05rem; font-weight: 700; color: inherit; }
.collection-card-featured .collection-count { font-size: .8rem; color: inherit; opacity: .8; }
.collections-all-heading {
  font-size: .8rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: .75rem;
}
.collections-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.collection-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; gap: .3rem;
  transition: box-shadow .2s, border-color .2s;
}
.collection-card:hover { box-shadow: var(--shadow); border-color: var(--theme); text-decoration: none; }
.collection-name { font-weight: 600; color: var(--text); }
.collection-count { font-size: .8rem; color: var(--text-muted); }
.collection-header { margin-bottom: 1rem; }
.collection-header .back-link { font-size: .875rem; color: var(--text-muted); }
.collection-meta { color: var(--text-muted); font-size: .9rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .55rem 1.1rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
  transition: background .15s, color .15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--theme); color: var(--theme-text, #fff); border-color: var(--theme); }
.btn-primary:hover { background: var(--theme-dark); border-color: var(--theme-dark); }

/* ── Empty / Error ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-state p { margin-bottom: 1rem; }
.error-page { text-align: center; padding: 6rem 1rem; }
.error-page h1 { font-size: 5rem; font-weight: 900; color: var(--theme-fg); line-height: 1; }
.error-page p { color: var(--text-muted); margin: .75rem 0 1.5rem; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--card-bg); border-top: 1px solid var(--border);
  padding: 1.5rem 0;
}
.footer-profiles {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  padding-bottom: 1rem; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.footer-profiles-label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.footer-icons { display: flex; gap: .4rem; flex-wrap: wrap; }
.footer-icon-link {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background .18s, color .18s, border-color .18s, transform .15s;
  text-decoration: none;
}
.footer-icon-link:hover {
  background: var(--theme); color: #fff; border-color: var(--theme);
  transform: translateY(-2px); text-decoration: none;
}
.footer-icon-link svg { display: block; }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-title  { font-weight: 700; font-size: .9rem; }
.footer-nav    { display: flex; gap: 1rem; }
.footer-link   { font-size: .85rem; color: var(--text-muted); }
.footer-link:hover { color: var(--theme-fg); }
.footer-copyright { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; padding-top: .6rem; border-top: 1px solid var(--border); margin-top: .5rem; font-size: .78rem; color: var(--text-muted); }
.mdc-credit a { color: var(--text-muted); text-decoration: none; }
.mdc-credit a:hover { color: var(--theme-fg); }

/* ── Designer Page ───────────────────────────────────────────────────────── */
.designer-page { max-width: 760px; margin: 2rem auto 4rem; }
.designer-profile {
  display: flex; gap: 2rem; align-items: flex-start;
  margin-bottom: 2.5rem;
}
.designer-logo-lg {
  width: 140px; height: 140px; object-fit: contain;
  border-radius: var(--radius); border: 1px solid var(--border);
  flex-shrink: 0; background: var(--bg);
}
.designer-info { flex: 1; }
.designer-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .75rem; }
.designer-bio  { color: var(--text-muted); line-height: 1.7; font-size: 1rem; }
.designer-section { margin-bottom: 2rem; }
.designer-section-title { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .85rem; }
.social-links { display: flex; flex-wrap: wrap; gap: .6rem; }
.social-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 600; color: #fff;
  background: var(--social-color, var(--theme));
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.social-btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; }
/* X and Threads are black — keep white text readable */

/* ── Theme Toggle Button ─────────────────────────────────────────────────── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9999px;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-muted); flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--theme-light); color: var(--theme-fg); border-color: var(--theme); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
/* Show correct icon per mode */
.icon-sun  { display: none; }
.icon-moon { display: block; }
html[data-theme="dark"]  .icon-sun  { display: block; }
html[data-theme="dark"]  .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .icon-sun  { display: block; }
  html:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ── Site Themes ─────────────────────────────────────────────────────────── */
/* The default theme is the base stylesheet — no overrides needed.           */
/* To add a new theme, add a [data-site-theme="key"] block here and a        */
/* matching entry in the siteThemes() function in admin/index.php.           */

/* ── Colorful Theme ──────────────────────────────────────────────────────── */
/* Light: bg/card/borders are tints of the accent color                      */
html[data-site-theme="colorful"] {
  --bg:          color-mix(in srgb, var(--theme)  8%, #ffffff);
  --card-bg:     color-mix(in srgb, var(--theme)  3%, #ffffff);
  --border:      color-mix(in srgb, var(--theme) 22%, #e0e0e8);
  --theme-light: color-mix(in srgb, var(--theme) 18%, #ffffff);
}
/* Light-only header/footer tints */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .site-header {
  background: color-mix(in srgb, var(--theme) 12%, #ffffff);
  border-bottom-color: color-mix(in srgb, var(--theme) 28%, #e0e0e8);
}
html[data-site-theme="colorful"]:not([data-theme="dark"]) .site-footer {
  border-top-color: color-mix(in srgb, var(--theme) 28%, #e0e0e8);
}
@media (prefers-color-scheme: dark) {
  html[data-site-theme="colorful"]:not([data-theme="light"]):not([data-theme="dark"]) .site-header,
  html[data-site-theme="colorful"]:not([data-theme="light"]):not([data-theme="dark"]) .site-footer {
    background: var(--card-bg);
    border-color: var(--border);
  }
}
/* Dark: bg/card/borders are deep shades of the accent color                 */
html[data-site-theme="colorful"][data-theme="dark"] {
  --bg:          color-mix(in srgb, var(--theme) 22%, #030306);
  --card-bg:     color-mix(in srgb, var(--theme) 18%, #0a0a10);
  --border:      color-mix(in srgb, var(--theme) 32%, #0f0f18);
  --text:        color-mix(in srgb, var(--theme)  6%, #e2e8f0);
  --text-muted:  color-mix(in srgb, var(--theme) 18%, #8892b0);
  --theme-light: color-mix(in srgb, var(--theme) 30%, #0a0a10);
  --theme-dark:  color-mix(in srgb, var(--theme) 80%, white);
  --shadow:      0 1px 3px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.45);
  --shadow-hover:0 4px 12px rgba(0,0,0,.65), 0 8px 32px rgba(0,0,0,.55);
}
html[data-site-theme="colorful"][data-theme="dark"] .site-header,
html[data-site-theme="colorful"][data-theme="dark"] .site-footer {
  background: var(--card-bg);
  border-color: var(--border);
}
@media (prefers-color-scheme: dark) {
  html[data-site-theme="colorful"]:not([data-theme="light"]) {
    --bg:          color-mix(in srgb, var(--theme) 22%, #030306);
    --card-bg:     color-mix(in srgb, var(--theme) 18%, #0a0a10);
    --border:      color-mix(in srgb, var(--theme) 32%, #0f0f18);
    --text:        color-mix(in srgb, var(--theme)  6%, #e2e8f0);
    --text-muted:  color-mix(in srgb, var(--theme) 18%, #8892b0);
    --theme-light: color-mix(in srgb, var(--theme) 30%, #0a0a10);
    --theme-dark:  color-mix(in srgb, var(--theme) 80%, white);
    --shadow:      0 1px 3px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.45);
    --shadow-hover:0 4px 12px rgba(0,0,0,.65), 0 8px 32px rgba(0,0,0,.55);
  }
  html[data-site-theme="colorful"]:not([data-theme="light"]) .site-header,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .site-footer {
    background: var(--card-bg);
    border-color: var(--border);
  }
  /* Revert colorful light overrides for system-dark users */
  html[data-site-theme="colorful"]:not([data-theme="light"]) .card-category,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .design-category { color: var(--theme-fg); }
  html[data-site-theme="colorful"]:not([data-theme="light"]) .tag-pill,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .tag-pill:hover,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .tag-pill.active { background: var(--theme-light); color: var(--theme-fg); }
  html[data-site-theme="colorful"]:not([data-theme="light"]) .nav-link:hover,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .nav-link.active,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .sb-nav-link:hover,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .sb-nav-link.active,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .dropdown-item:hover,
  html[data-site-theme="colorful"]:not([data-theme="light"]) .sb-dropdown-item:hover { background: var(--theme-light); color: var(--theme-fg); }
  html[data-site-theme="colorful"]:not([data-theme="light"]) .tag-count { background: var(--theme-light); color: var(--theme-fg); }
}
/* Colorful light: category text darkened for contrast on tinted bg */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .card-category,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .design-category {
  color: color-mix(in srgb, var(--theme) 75%, #000000);
}
/* Colorful light: tag pill is a vibrant tint of the accent with black text */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .tag-pill {
  background: color-mix(in srgb, var(--theme) 50%, #ffffff);
  color: #111111;
}
html[data-site-theme="colorful"]:not([data-theme="dark"]) .tag-pill:hover,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .tag-pill.active {
  background: color-mix(in srgb, var(--theme) 75%, #ffffff);
  color: #111111;
}

/* Colorful light: nav links and dropdowns use vibrant tint + near-black text */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .nav-link:hover,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .nav-link.active,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .sb-nav-link:hover,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .sb-nav-link.active {
  background: color-mix(in srgb, var(--theme) 50%, #ffffff);
  color: #111111;
}
html[data-site-theme="colorful"]:not([data-theme="dark"]) .dropdown-item:hover,
html[data-site-theme="colorful"]:not([data-theme="dark"]) .sb-dropdown-item:hover {
  background: color-mix(in srgb, var(--theme) 50%, #ffffff);
  color: #111111;
}
/* Colorful light: tag count badges — vibrant bg, dark text */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .tag-count {
  background: color-mix(in srgb, var(--theme) 50%, #ffffff);
  color: #111111;
}

/* Sidebar variant of colorful theme — sidebar picks up the accent tints too */
html[data-site-theme="colorful"]:not([data-theme="dark"]) .sb-sidebar {
  background: color-mix(in srgb, var(--theme) 10%, #ffffff);
  border-right-color: color-mix(in srgb, var(--theme) 25%, #e0e0e8);
}
html[data-site-theme="colorful"][data-theme="dark"] .sb-sidebar {
  background: color-mix(in srgb, var(--theme) 20%, #060609);
  border-right-color: color-mix(in srgb, var(--theme) 32%, #0f0f18);
}
@media (prefers-color-scheme: dark) {
  html[data-site-theme="colorful"]:not([data-theme="light"]) .sb-sidebar {
    background: color-mix(in srgb, var(--theme) 20%, #060609);
    border-right-color: color-mix(in srgb, var(--theme) 32%, #0f0f18);
  }
}

/* ── Sidebar Theme ───────────────────────────────────────────────────────── */
.sb-layout { display: flex; min-height: 100vh; }

.sb-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--card-bg); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; z-index: 100;
}
.sb-inner {
  display: flex; flex-direction: column;
  height: 100%; padding: 1.25rem 1rem;
}
.sb-content { flex: 1; min-width: 0; }

/* Brand */
.sb-sidebar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.sb-brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; flex: 1; min-width: 0; }
.sb-brand:hover { text-decoration: none; }
.sb-logo { height: 44px; width: auto; object-fit: contain; flex-shrink: 0; }
.sb-brand-name { font-size: 1.05rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1.2; }
.sb-toggle { display: none; align-items: center; justify-content: center; flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem .5rem; cursor: pointer; color: var(--text-muted); font-size: .95rem; }

/* Search */
.sb-search { display: flex; align-items: center; gap: .35rem; margin-bottom: 1.25rem; }
.sb-search input[type="search"] {
  flex: 1; min-width: 0; padding: .4rem .65rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: .825rem; font-family: var(--font);
}
.sb-search input[type="search"]:focus { outline: none; border-color: var(--theme); box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme) 15%, transparent); }
.sb-search button {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.sb-search button:hover { background: var(--theme); color: var(--theme-text, #fff); border-color: var(--theme); }

/* Nav */
.sb-nav { display: flex; flex-direction: column; gap: .1rem; }
.sb-nav-link {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: .5rem .65rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; color: var(--text-muted);
  text-decoration: none; background: none; border: none; cursor: pointer;
  font-family: var(--font); transition: background .15s, color .15s; text-align: left;
}
.sb-nav-link:hover, .sb-nav-link.active { background: var(--theme-light); color: var(--theme-fg); text-decoration: none; }

/* Sidebar dropdowns */
.sb-dropdown { position: relative; }
.sb-dropdown-menu { display: none; flex-direction: column; padding: .2rem 0 .2rem .85rem; gap: .05rem; }
.sb-dropdown.open .sb-dropdown-menu { display: flex; }
.sb-dropdown-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .35rem .65rem; border-radius: var(--radius-sm);
  font-size: .825rem; color: var(--text-muted); text-decoration: none;
  transition: background .15s, color .15s;
}
.sb-dropdown-item:hover { background: var(--theme-light); color: var(--theme-fg); text-decoration: none; }
.sb-dropdown-item-all { font-weight: 600; font-size: .775rem; }

/* Spacer */
.sb-spacer { flex: 1; }

/* Sidebar footer */
.sb-footer { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.sb-footer-label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .5rem; }
.sb-footer-icons { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .85rem; }
.sb-footer-links { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.sb-footer-link { font-size: .8rem; color: var(--text-muted); text-decoration: none; transition: color .15s; }
.sb-footer-link:hover { color: var(--theme-fg); }
.sb-footer-copyright { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; font-size: .72rem; color: var(--text-muted); }
.sb-footer-bottom { display: flex; align-items: center; justify-content: space-between; }
.sb-site-name { font-size: .72rem; font-weight: 700; color: var(--text-muted); }

/* Mobile */
@media (max-width: 768px) {
  .sb-layout { flex-direction: column; }
  .sb-sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .sb-inner { height: auto; padding: .85rem 1rem; }
  .sb-sidebar-top { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
  .sb-toggle { display: flex; }
  .sb-search, .sb-nav, .sb-footer, .sb-spacer { display: none; }
  .sb-sidebar.open .sb-search { display: flex; margin-top: 1rem; }
  .sb-sidebar.open .sb-nav { display: flex; margin-top: .25rem; }
  .sb-sidebar.open .sb-footer { display: block; }
}

/* ── Dark mode overrides for hardcoded colours ───────────────────────────── */
/* MakerWorld white button: keep intentionally white in both modes */
/* Design description code block: already dark (#1e1e2e), fine in dark mode */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .design-description code { background: #1e1e2e; color: #cdd6f4; }
  html:not([data-theme="light"]) body { color-scheme: dark; }
}
html[data-theme="dark"] .design-description code { background: #1e1e2e; color: #cdd6f4; }
html[data-theme="dark"] body { color-scheme: dark; }

/* ── Admin edit FAB (only rendered when logged in) ───────────────────────── */
.edit-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .9rem;
  background: var(--theme);
  color: var(--theme-text, #fff);
  border-radius: 2rem;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  z-index: 300;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.edit-fab:hover {
  background: color-mix(in srgb, var(--theme) 82%, black);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Row 1: brand | → theme-toggle | hamburger
     Row 2: full-width search
     Row 3: nav (when open) */
  .header-inner   { flex-wrap: wrap; gap: .5rem .5rem; padding-top: .6rem; padding-bottom: .6rem; }
  .site-brand     { order: 1; flex-shrink: 0; }
  .theme-toggle   { order: 2; margin-left: auto; }
  .nav-hamburger  { order: 3; display: block; color: var(--text); font-size: 1.25rem; }
  .header-search  { order: 4; flex: 0 0 100%; width: 100%; }
  .header-search input { width: 100%; }
  .site-nav       { order: 5; display: none; flex-direction: column; width: 100%; flex-basis: 100%; }
  .site-nav.open  { display: flex; }
  .dropdown-menu  { position: static; box-shadow: none; border: none; background: var(--bg); }
  .design-title   { font-size: 1.5rem; }
  .designs-grid   { grid-template-columns: repeat(var(--grid-cols-mobile, 2), minmax(0, 1fr)); }
}

/* ── Public Forms (apply pages, etc.) ───────────────────────────────────── */
.pub-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1.25rem;
}
.pub-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--border);
}
.pub-card-head h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.pub-card-body { padding: 1.25rem; }

.pub-form-group { margin-bottom: 1.1rem; }
.pub-form-group:last-child { margin-bottom: 0; }
.pub-form-group label {
  display: block; font-size: .875rem; font-weight: 600;
  color: var(--text); margin-bottom: .35rem;
}
.pub-form-group label small { font-weight: 400; color: var(--text-muted); }
.pub-form-control {
  width: 100%; padding: .55rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .9375rem;
  background: var(--card-bg); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit; box-sizing: border-box;
}
.pub-form-control:focus {
  outline: none; border-color: var(--theme);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme) 15%, transparent);
}
.pub-form-hint { display: block; font-size: .8rem; color: var(--text-muted); margin-top: .35rem; }
.pub-form-actions { padding-top: .75rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.pub-form-required { color: #ef4444; }

.pub-flash {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .9rem; font-weight: 500;
}
.pub-flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.pub-flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

.pub-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px) { .pub-two-col { grid-template-columns: 1fr; } }

/* Remixes */
.link-discord { background: #5865F2; color: #fff; }

.remix-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #5865F2;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .2rem .45rem;
  border-radius: 3px;
  line-height: 1;
  position: absolute;
  top: .5rem;
  left: .5rem;
}

.remix-badge-lg {
  position: static;
  font-size: .75rem;
  padding: .25rem .6rem;
}

.card-image-wrap { position: relative; }
