*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--cs-background);
  color: var(--cs-text);
}

/* Hero */
.templates-hero {
  padding: 100px 24px 48px;
  text-align: center;
}

.templates-hero-badge {
  margin-bottom: 16px;
  display: inline-block;
}

.templates-hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin-bottom: 12px;
}

.templates-hero p {
  color: var(--cs-text-muted);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

/* Filters */
.templates-main {
  padding: 0 24px 60px;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 40px;
}

.filter-tab {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--cs-border);
  background: var(--cs-surface);
  color: var(--cs-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.filter-tab:hover {
  color: var(--cs-text);
  border-color: #7c3aed;
}

.filter-tab.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: #7c3aed;
  color: var(--cs-text);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.25);
}

/* Grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .templates-grid {
    grid-template-columns: 1fr;
  }
}

.template-card {
  background: var(--cs-surface);
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.template-card:hover {
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.template-card.hidden {
  display: none;
}

.template-preview {
  height: 200px;
  overflow: hidden;
  position: relative;
  background: #030014;
  border-bottom: 1px solid var(--cs-border);
}

.template-preview-inner {
  width: 200%;
  height: 200%;
  transform: scale(0.5);
  transform-origin: top left;
  pointer-events: none;
}

.template-preview-inner iframe {
  width: 800px;
  height: 600px;
  border: none;
  display: block;
}

.template-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.template-body h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.template-desc {
  font-size: 13px;
  color: var(--cs-text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
  flex: 1;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.template-actions {
  margin-top: auto;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 0, 20, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  background: var(--cs-surface);
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--cs-border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--cs-radius);
  background: transparent;
  color: var(--cs-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--cs-background);
  color: var(--cs-text);
}

.modal-code-wrap {
  flex: 1;
  overflow: auto;
  padding: 16px 24px;
}

.modal-code-wrap pre {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.55;
  color: var(--cs-text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-.logo { font-size:18px;font-weight:800;background:linear-gradient(135deg,#7c3aed,#0ea5e9);-webkit-background-clip:text;-webkit-text-fill-color:transparent;text-decoration:none; }
.nav-right { display:flex;align-items:center;gap:6px;flex-wrap:wrap; }
.nav-more-wrap { position:relative; }
.nav-more-menu { position:absolute;right:0;top:calc(100% + 8px);min-width:200px;max-height:70vh;overflow-y:auto;background:var(--cs-surface);border:1px solid var(--cs-border);border-radius:8px;box-shadow:0 12px 40px rgba(0,0,0,0.35);padding:8px 0;z-index:300; }
.nav-more-menu[hidden] { display:none; }
.nav-more-menu a { display:block;padding:8px 16px;font-size:13px;color:var(--cs-text-muted);text-decoration:none; }
.nav-more-menu a:hover { background:rgba(124,58,237,0.1);color:var(--cs-text); }
