<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>MultiSearch Tag Explorer</title>
  <meta name="description" content="MultiSearch Tag Explorer - Search and discover topics.">
  <style>
    *, *::before, *::after { box-sizing: border-box; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      margin: 0; 
      padding: 4rem 2rem;
      background: #fbfbfd;
      color: #1d1d1f;
      min-height: 100vh;
      display: flex; 
      flex-direction: column; 
      align-items: center;
      -webkit-font-smoothing: antialiased;
      text-rendering: optimizeLegibility;
    }
    h1 {
      font-size: 2.5rem;
      font-weight: 700;
      margin-bottom: 1.5rem;
      letter-spacing: -0.015em;
      color: #1d1d1f;
      text-align: center;
      line-height: 1.1;
    }
    form#searchForm {
      display: flex;
      max-width: 520px;
      width: 100%;
      margin: 1rem auto 3rem auto;
      background: #f5f5f7;
      border: 1px solid transparent;
      border-radius: 12px;
      overflow: hidden;
      transition: all 0.2s ease;
    }
    form#searchForm:focus-within {
      background: #ffffff;
      border-color: #0071e3;
      box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
    }
    #searchBox {
      flex-grow: 1;
      padding: 1rem 1.25rem;
      font-size: 1.05rem;
      border: none;
      outline: none;
      background: transparent;
      color: #1d1d1f;
    }
    #searchBox::placeholder {
      color: #86868b;
    }
    button[type="submit"] {
      background: transparent;
      border: none;
      color: #0071e3;
      font-weight: 600;
      font-size: 1rem;
      padding: 0 1.5rem;
      cursor: pointer;
      transition: opacity 0.2s ease;
    }
    button[type="submit"]:hover {
      opacity: 0.7;
    }
    #searchResults {
      max-width: 520px;
      width: 100%;
    }
    #searchResults a.result-title {
      font-weight: 600;
      font-size: 1.25rem;
      color: #0066cc !important;
      text-decoration: none !important;
      transition: color 0.15s ease;
    }
    #searchResults a.result-title:hover {
      color: #0044bb !important;
      text-decoration: underline !important;
    }
    #searchResults div.result-item {
      margin-bottom: 2rem;
      background: #ffffff;
      border: 1px solid #e3e3e8;
      padding: 1.5rem;
      border-radius: 16px;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    #searchResults div.result-item:hover {
      border-color: #d2d2d7;
      box-shadow: 0 4px 18px rgba(0, 0, 0, 0.03);
    }
    #searchResults p.description {
      margin: 0.6rem 0 1rem 0;
      color: #515154;
      font-size: 0.95rem;
      line-height: 1.5;
    }
    .future-search-container, .ai-links-container {
      display: flex !important;
      flex-wrap: wrap !important;
      gap: 12px 18px;
      justify-content: flex-start !important;
      width: 100% !important;
      margin-top: 10px;
      margin-bottom: 14px;
    }
    .future-link {
      position: relative;
      display: inline-flex !important;
      align-items: center;
      flex-shrink: 0 !important;
      font-size: 0.72rem;
      font-weight: 600;
      text-decoration: none;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: #94a3b8;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      padding-bottom: 4px;
      transition: color 0.25s ease;
    }
    .future-link::after {
      content: '';
      position: absolute;
      bottom: 0; left: 0;
      width: 0; height: 1px;
      transition: width 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    .future-link:hover::after {
      width: 100%;
    }
    .future-link.wp:hover { color: #1d1d1f; }
    .future-link.wp::after { background: #1d1d1f; }
    .future-link.gg:hover { color: #4285F4; }
    .future-link.gg::after { background: #4285F4; box-shadow: 0 0 4px #4285F4; }
    .future-link.yt:hover { color: #FF0000; }
    .future-link.yt::after { background: #FF0000; box-shadow: 0 0 4px #FF0000; }
    .future-link.yh:hover { color: #a855f7; }
    .future-link.yh::after { background: #a855f7; box-shadow: 0 0 4px #a855f7; }
    .future-link.bg:hover { color: #00A4EF; }
    .future-link.bg::after { background: #00A4EF; box-shadow: 0 0 4px #00A4EF; }
    .future-link.yd:hover { color: #ffcc00; }
    .future-link.yd::after { background: #ffcc00; box-shadow: 0 0 4px #ffcc00; }
    .future-link.bd:hover { color: #3b82f6; }
    .future-link.bd::after { background: #3b82f6; box-shadow: 0 0 4px #3b82f6; }
    .future-link.dd:hover { color: #f97316; }
    .future-link.dd::after { background: #f97316; box-shadow: 0 0 4px #f97316; }
    .future-link.brv:hover { color: #ff4500; }
    .future-link.brv::after { background: #ff4500; box-shadow: 0 0 4px #ff4500; }
    .future-link.prp:hover { color: #10b981; }
    .future-link.prp::after { background: #10b981; box-shadow: 0 0 4px #10b981; }
    .future-link.gpt:hover { color: #0f172a; }
    .future-link.gpt::after { background: #0f172a; box-shadow: 0 0 4px #0f172a; }
    .future-link.bd-chat:hover { color: #002fa7; }
    .future-link.bd-chat::after { background: #002fa7; box-shadow: 0 0 4px #002fa7; }
    .future-link:active { opacity: 0.5; }
    .ai-divider {
      border: 0;
      height: 1px;
      background: #e3e3e8;
      margin: 18px -1.5rem 14px -1.5rem;
    }
    #searchResults div.tags {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
    }
    #searchResults div.tags a {
      background: #f0f2f5;
      color: #050505;
      padding: 0.3rem 0.8rem;
      font-size: 0.82rem;
      font-weight: 500;
      border-radius: 8px;
      text-decoration: none;
      white-space: nowrap;
      transition: background-color 0.15s ease;
    }
    #searchResults div.tags a:hover {
      background: #e4e6eb;
    }
    @media (max-width: 480px) {
      body { padding: 2rem 1rem; }
      h1 { font-size: 2rem; }
      form#searchForm, #searchResults { max-width: 100%; }
      #searchResults div.result-item { padding: 1.25rem; border-radius: 12px; margin-bottom: 1.2rem; }
    }
    .dynamic-link { 
        color: #4f46e5 !important; 
        font-weight: 700 !important; 
        font-size: 1.1em !important;
        text-decoration: none !important; 
        background: rgba(79, 70, 229, 0.05) !important;
        border: 1px solid rgba(79, 70, 229, 0.3) !important;
        padding: 2px 6px !important;
        border-radius: 6px !important;
        box-shadow: 0 2px 4px rgba(79, 70, 229, 0.08) !important;
        transition: all 0.2s ease; 
        cursor: help !important; 
        display: inline-block;
    }
    .dynamic-link:hover { 
        background: rgba(79, 70, 229, 0.12) !important;
        border-color: #4f46e5 !important;
        box-shadow: 0 4px 8px rgba(79, 70, 229, 0.15) !important;
        transform: translateY(-1px);
    }
    .random-link { 
        color: #059669 !important; 
        font-weight: 700 !important; 
        font-size: 1.1em !important;
        text-decoration: none !important; 
        background: rgba(5, 150, 105, 0.05) !important;
        border: 1px solid rgba(5, 150, 105, 0.3) !important;
        padding: 2px 6px !important; 
        border-radius: 6px !important; 
        box-shadow: 0 2px 4px rgba(5, 150, 105, 0.08) !important; 
        transition: all 0.2s ease; 
        cursor: help !important; 
        display: inline-block;
    }
    .random-link:hover { 
        background: rgba(5, 150, 105, 0.12) !important; 
        border-color: #059669 !important; 
        box-shadow: 0 4px 8px rgba(5, 150, 105, 0.15) !important; 
        transform: translateY(-1px); 
    }
    .premium-tooltip { position: fixed; z-index: 2147483647; background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(8px); border: 1px solid #d1d5db; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); padding: 18px 22px; border-radius: 18px; font-family: sans-serif; pointer-events: none; display: none; width: calc(100% - 40px); max-width: 320px; opacity: 0; transform: translateY(15px) scale(0.95); transition: opacity 0.2s ease, transform 0.2s ease; box-sizing: border-box; color: #000; }
    .t-label { font-size: 11px; font-weight: 800; text-transform: uppercase; color: #4338ca; letter-spacing: 1.2px; display: block; margin-bottom: 6px; }
    .t-title { font-size: 20px; font-weight: 800; color: #000000; display: block; margin-bottom: 2px; }
    .t-source { font-size: 12px; color: #4f46e5; font-weight: 700; display: block; margin-bottom: 12px; }
    .t-desc { font-size: 14px; color: #1f2937; border-top: 1px solid #f3f4f6; padding-top: 12px; line-height: 1.5; }
    @media (max-width: 768px) { .premium-tooltip { left: 20px !important; right: 20px !important; bottom: 30px !important; top: auto !important; max-width: none; width: auto; } }
    .spinner {
    margin: 0 auto;
    width: 40px;
    height: 40px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    }
    @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
    }
  </style>
</head>
<body>
  <h1>MultiSearch Tag Explorer</h1>
  <form id="searchForm" role="search" aria-label="Wikipedia search form">
    <input
      id="searchBox"
      type="search"
      name="q"
      placeholder="Search…"
      aria-label="Search Wikipedia"
      autocomplete="off"
      spellcheck="false"
      required
    />
    <button type="submit" aria-label="Submit search">Go</button>
  </form>
  <div id="searchResults" role="region" aria-live="polite" aria-atomic="true"></div>
  <script>
  const searchForm = document.getElementById('searchForm');
  const searchBox = document.getElementById('searchBox');
  const resultsDiv = document.getElementById('searchResults');
  const language = 'en';
  const defaultFallback = 'Technology';
  function decodeHTML(html) {
    const txt = document.createElement('textarea');
    txt.innerHTML = html;
    return txt.value;
  }
  function escapeHTML(str) {
    if (!str) return "";
    return str
      .replace(/&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
      .replace(/"/g, '&quot;')
      .replace(/'/g, '&#039;');
  }
  function extractTags(title) {
    const parts = title.split(/[^0-9\p{L}]+/u);
    return parts.filter(w => w.length > 1);
  }
  async function getLiveStartingTag() {
    const url = `https://${language}.wikipedia.org/w/api.php?action=query&list=recentchanges&rcnamespace=0&rclimit=5&rcprop=title&rctype=edit&format=json&origin=*`;
    try {
      const res = await fetch(url);
      const data = await res.json();
      const changes = data.query?.recentchanges || [];
      for (let change of changes) {
        const fullTitle = decodeHTML(change.title).trim();
        if (fullTitle.length > 0 && !fullTitle.includes(':')) return fullTitle;
      }
      return defaultFallback;
    } catch (e) {
      return defaultFallback;
    }
  }
  function updateURLQuery(query) {
    const newUrl = new URL(window.location);
    if (query) {
      newUrl.searchParams.set('q', query);
    } else {
      newUrl.searchParams.delete('q');
    }
    history.pushState(null, '', newUrl);
  }
  function updateMeta(query, description = "", imageUrl = "") {
    const siteTitle = 'MultiSearch Tag Explorer';
    const finalTitle = query ? `${query}` : siteTitle;
    const finalDesc = description ? description.replace(/<\/?[^>]+(>|$)/g, "").trim().substring(0, 160) : `Explore AI insights and tags for ${query || 'any topic'}.`;
    const finalUrl = window.location.href;
    document.title = finalTitle;
    const setMeta = (name, value, isProperty = false) => {
      const attr = isProperty ? 'property' : 'name';
      let el = document.querySelector(`meta[${attr}="${name}"]`);
      if (!el) {
        el = document.createElement('meta');
        el.setAttribute(attr, name);
        document.head.appendChild(el);
      }
      el.setAttribute('content', value);
    };
    setMeta('description', finalDesc);
    setMeta('og:title', finalTitle, true);
    setMeta('og:description', finalDesc, true);
    setMeta('og:url', finalUrl, true);
    setMeta('og:type', 'website', true);
    if (imageUrl) {
        setMeta('og:image', imageUrl, true);
    }
  }
  async function performSearch(query) {
    resultsDiv.innerHTML = `
    <div style="text-align:center; padding:40px; color:#64748b; font-family: sans-serif;">
    <div class="spinner"></div>
    <p style="margin-top:15px; font-weight:500;"></p>
    </div>
    `;
    window.scrollTo({ top: 0, behavior: 'smooth' });
    const apiUrl = `https://${language}.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=${encodeURIComponent(query)}&gsrlimit=10&prop=pageimages|extracts&exintro&explaintext&exsentences=2&exlimit=max&piprop=thumbnail&pithumbsize=500&format=json&origin=*`;
    try {
      const res = await fetch(apiUrl);
      if (!res.ok) throw new Error('Network error');
      const data = await res.json();
      if (!data.query || !data.query.pages) {
        resultsDiv.innerHTML = '<div style="text-align:center; padding:20px;">No specific results found.</div>';
        updateMeta(query, "");
        return;
      }
      const pages = Object.values(data.query.pages).sort((a, b) => a.index - b.index);
      const firstPage = pages[0];
      const mainImage = firstPage.thumbnail ? firstPage.thumbnail.source : "";
      updateMeta(query, firstPage.extract || "", mainImage);
      resultsDiv.innerHTML = pages.map(page => {
        const cleanTitle = page.title;
        const cleanSnippet = page.extract || "";
        const imageUrl = page.thumbnail ? page.thumbnail.source : null;
        const tags = extractTags(cleanTitle);
        const safeTitle = escapeHTML(cleanTitle);
        const safeSnippet = escapeHTML(cleanSnippet);
        const currentFullUrl = window.location.origin + window.location.pathname + '?q=' + encodeURIComponent(cleanTitle);
        const tagsHtml = tags.map(tag => `<a href="?q=${encodeURIComponent(tag)}" class="tag-link">${escapeHTML(tag)}</a>`).join(' ');
        const engines = [
          { id: 'gg', name: 'Google', url: `https://www.google.com/search?q=${encodeURIComponent(cleanTitle)}` },
          { id: 'yt', name: 'YouTube', url: `https://www.youtube.com/results?search_query=${encodeURIComponent(cleanTitle)}` },
          { id: 'bg', name: 'Bing', url: `https://www.bing.com/search?q=${encodeURIComponent(cleanTitle)}` },
          { id: 'yh', name: 'Yahoo', url: `https://search.yahoo.com/search?p=${encodeURIComponent(cleanTitle)}` },
          { id: 'yd', name: 'Yandex', url: `https://yandex.com/search/?text=${encodeURIComponent(cleanTitle)}` },
          { id: 'bd', name: 'Baidu', url: `https://www.baidu.com/s?wd=${encodeURIComponent(cleanTitle)}` },
          { id: 'dd', name: 'DuckGo', url: `https://duckduckgo.com/?q=${encodeURIComponent(cleanTitle)}` }
        ].sort(() => 0.5 - Math.random()).slice(0, 3);
        const aiPrompts = [
  `Provide a comprehensive, multi-dimensional analysis of "${cleanTitle}". Please cover the following aspects in detail: 1) Core definition, historical background, and origin. 2) Social impact, public perception, and contemporary relevance. 3) Cultural significance, presence in art, media, or literature, and global footprint. 4) A curated summary of notable multimedia representations available online (including key imagery, landmark video documentation, and essential web resources). Deliver a highly structured, objective, and deeply informative response suitable for advanced educational research. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Act as an expert academic researcher and provide an in-depth breakdown of "${cleanTitle}". Please analyze: 1) Major chronological milestones, 2) Key debates, controversies, or conflicting perspectives surrounding it, 3) Its long-term future outlook and technological/social implications. Ensure a highly analytical tone. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Create an executive summary and a detailed conceptual guide about "${cleanTitle}". Walk through: 1) A clear, jargon-free explanation for beginners, 2) Core technical or theoretical principles, 3) Real-world use cases and practical applications happening right now. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Conduct a rigorous epistemological and ethical evaluation of "${cleanTitle}". Analyze it through the competing frameworks of utilitarianism, deontological ethics, and virtue ethics. Discuss any inherent paradoxes it presents to modern existential thought and its implications for human agency in the 21st century. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Provide a comprehensive socio-historical analysis of "${cleanTitle}". Identify the precise historical catalysts, geopolitical shifts, and paradigm changes that led to its emergence. Examine how its historical narrative has been revisioned or reinterpreted across different cultures over time. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Deconstruct "${cleanTitle}" from a strictly theoretical and scientific perspective. Detail its foundational mathematical, physical, or computational axioms. Explain the underlying mechanics, current experimental limitations, and the primary theoretical anomalies currently being debated in peer-reviewed literature. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Analyze "${cleanTitle}" through the lens of macroeconomics and behavioral economics. Evaluate its impact on global market structures, resource allocation, and supply chain dynamics. Detail the economic externalities (both positive and negative) it generates and its role in shaping future fiscal policies. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Investigate the sociological dimensions and cultural footprint of "${cleanTitle}". How does it influence collective behavior, social stratification, and institutional power dynamics? Analyze its representation in contemporary media and its role in reshaping identity politics or global subcultures. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Perform an anthropological and semiotic deconstruction of "${cleanTitle}". Map the core symbols, rituals, or foundational myths associated with it across distinct geographical regions. Explain how it reflects fundamental human anxieties, desires, or evolutionary adaptations. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Examine "${cleanTitle}" from the perspective of cognitive psychology and neuroscience. Analyze how it interacts with human perception, memory formation, heuristics, and bias. Discuss its implications for psychological well-being, neuroplasticity, or collective mental models. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Evaluate the technological architecture and long-term evolutionary trajectory of "${cleanTitle}". Discuss its convergence with artificial intelligence, quantum computing, or biotechnology. Map out a plausible 50-year future roadmap, outlining the systemic risks and existential safeguards required. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Conduct a hermeneutic and literary critique of "${cleanTitle}". Trace its thematic development, structural metaphors, and allegorical presence in world literature and advanced narrative theory. Analyze how it challenges traditional storytelling frameworks or semiotic systems. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Analyze the legal, regulatory, and geopolitical dimensions of "${cleanTitle}". Examine the challenges it poses to international law, national sovereignty, and global governance frameworks. Suggest a comprehensive, multidisciplinary policy framework designed to mitigate its institutional risks. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Provide a critical environmental and ecological assessment of "${cleanTitle}". Analyze its relationship with biosphere integrity, climate dynamics, and the Anthropocene epoch. Evaluate it through the principles of industrial ecology, resource circularity, and long-term sustainability metrics. This prompt was created by the free aéPiot application - https://aepiot.com/`,
  `Deconstruct the aesthetic theory and formal design principles underlying "${cleanTitle}". Analyze it through historical and contemporary artistic movements (e.g., modernism, postmodernism, avant-garde). Explain how it redefines the relationship between form, function, and human sensory experience. This prompt was created by the free aéPiot application - https://aepiot.com/`
        ];
        const encodedPrompt = encodeURIComponent(aiPrompts[Math.floor(Math.random() * aiPrompts.length)]);
        return `
          <div class="result-item">
            <div style="display: flex; gap: 15px; align-items: flex-start; margin-bottom: 12px;">
              ${imageUrl ? `
                <div style="flex-shrink: 0; width: 90px; height: 90px; border-radius: 10px; overflow: hidden; background: #f1f5f9; border: 1px solid #e2e8f0;">
                  <img src="${imageUrl}" loading="lazy" style="width: 100%; height: 100%; object-fit: cover;" alt="${safeTitle}">
                </div>
              ` : ''}
              <div style="flex-grow: 1;">
                <a href="?q=${encodeURIComponent(cleanTitle)}" class="tag-link result-title" style="font-size: 1.25rem; font-weight: 700; color: #1e293b; text-decoration: none;">${safeTitle}</a>
                <p class="description" style="margin: 6px 0; color: #475569; font-size: 0.95rem; line-height: 1.5;">${safeSnippet}</p>
              </div>
            </div>
            <div class="search-engines-wrapper">
              <div class="future-search-container" style="display: flex; flex-wrap: wrap; gap: 8px;">
              <div style="font-size: 28px; margin-bottom: 4px; margin-left: 5px;">👉</div>
                <a href="https://en.wikipedia.org/wiki/${encodeURIComponent(cleanTitle)}" target="_blank" class="future-link wp">Wiki</a>
                ${engines.map(e => `<a href="${e.url}" target="_blank" class="future-link ${e.id}">${e.name}</a>`).join('')}
              </div>
            </div>
            <div class="tags" style="margin-top: 10px;">${tagsHtml}</div>
            <hr class="ai-divider" style="border: 0; border-top: 1px solid #e2e8f0; margin: 15px 0;">
            <div class="ai-links-container" style="display: flex; flex-wrap: wrap; gap: 8px;">
            <div style="font-size: 28px; margin-bottom: 4px; margin-left: 5px;">✨</div>
              <a href="https://search.brave.com/ask?q=${encodedPrompt}" target="_blank" class="future-link brv">Brave</a>
              <a href="https://www.perplexity.ai/search/new?q=${encodedPrompt}" target="_blank" class="future-link prp">Perplexity</a>
              <a href="https://chatgpt.com/?prompt=${encodedPrompt}" target="_blank" class="future-link gpt">ChatGPT</a>
              <a href="https://chat.baidu.com/search?word=${encodedPrompt}" target="_blank" class="future-link gpt">BAIDU</a>
            </div>
            <div style="display: flex; justify-content: flex-end; gap: 35px; margin-top: 15px;">
              <svg onclick="window.open('https://www.addtoany.com/share?url=${encodeURIComponent(currentFullUrl)}&title=${encodeURIComponent(safeTitle)}&description=${encodeURIComponent(safeSnippet)}', '_blank');" 
                   style="width: 28px; height: 28px; cursor: pointer; fill: #007bff;" viewBox="0 0 24 24">
                <path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92c0-1.61-1.31-2.92-2.92-2.92z"/>
              </svg>
              <svg onclick="window.location.href = '/';" style="width: 28px; height: 28px; cursor: pointer; stroke: #28a745; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;" viewBox="0 0 24 24"><path d="M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
            </div>
          </div>`;
      }).join('');
    } catch (e) {
      console.error(e);
    }
  }
  searchForm.addEventListener('submit', e => {
    e.preventDefault();
    const q = searchBox.value.trim();
    if (q) { updateURLQuery(q); performSearch(q); }
  });
  resultsDiv.addEventListener('click', e => {
    if (e.target.classList.contains('tag-link')) {
      e.preventDefault();
      const q = new URLSearchParams(e.target.search).get('q');
      if (q) { searchBox.value = q; updateURLQuery(q); performSearch(q); }
    }
  });
  window.addEventListener('popstate', () => {
    const q = new URLSearchParams(window.location.search).get('q') || '';
    searchBox.value = q;
    if (q) performSearch(q);
    else { resultsDiv.textContent = ''; updateMeta(""); }
  });
  window.addEventListener('DOMContentLoaded', async () => {
    const q = new URLSearchParams(window.location.search).get('q');
    if (q) {
      searchBox.value = q;
      performSearch(q);
    } else {
      const start = await getLiveStartingTag();
      searchBox.value = start;
      performSearch(start);
    }
  });
  </script>
  <footer style="margin-top: 4rem; padding: 2rem 1rem; text-align: center; color: #86868b; font-size: 0.85rem; background: transparent; border-top: 1px solid #e3e3e8; width: 100%; max-width: 520px;">
    <div style="font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 1.1rem; font-weight: 500; line-height: 1.5; color: #1e293b; background-color: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 24px; text-align: center; max-width: 500px; margin: 0px auto 20px auto; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);">Loving <span style="color: #3b82f6; font-weight: 700;">aéPiot</span>? Add it to your desktop for quick access or share it with your network!</div>
    <div style="margin-bottom: 0.8rem; font-weight: 500; color: #1d1d1f;">
      &copy; aéPiot - MultiSearch Tag Explorer. All rights reserved.
    </div>
    <div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem 1.2rem; font-size: 0.8rem;">
      <a href="https://headlines-world.com/" target="_self" style="color: #0066cc; text-decoration: none; font-weight: 500; transition: color 0.15s ease;">Headlines World</a>
      <a href="https://aepiot.com/" target="_self" style="color: #0066cc; text-decoration: none; font-weight: 500; transition: color 0.15s ease;">aéPiot.com</a>
      <a href="https://aepiot.ro/" target="_self" style="color: #0066cc; text-decoration: none; font-weight: 500; transition: color 0.15s ease;">aéPiot.ro</a>
      <a href="https://allgraph.ro/" target="_self" style="color: #0066cc; text-decoration: none; font-weight: 500; transition: color 0.15s ease;">allGraph</a>
    </div>
  </footer>
  <script>
    (function() {
        const linkSettings = [
            ["band, orchestra, choir, voice, piano, instrumental, genre, digital, teacher", "https://www.sheetmusicplus.com/en/explore?aff_id=541503&q=%s", 3],
            ["music, sheet music", "https://www.sheetmusicplus.com?aff_id=541503", 1]
        ];
        const randomSettings = [
            ["https://www.sheetmusicplus.com?aff_id=541503", 1],
            ["https://www.sheetmusicplus.com/en/explore?aff_id=541503&q=%s", 10]
        ];
        const blueWords = linkSettings.flatMap(([wordsString]) => 
            wordsString.split(',').map(w => w.trim().toLowerCase())
        );
        let tooltip;
        const createTooltip = () => {
            if (document.querySelector('.premium-tooltip')) { tooltip = document.querySelector('.premium-tooltip'); return; }
            tooltip = document.createElement('div');
            tooltip.className = 'premium-tooltip';
            document.body.appendChild(tooltip);
        };
        const getDomain = (url) => {
            try { return new URL(url.replace('%s', 'search')).hostname.replace('www.', ''); } catch(e) { return "External Link"; }
        };
        function shuffle(array) {
            for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; }
            return array;
        }
        let isProcessing = false;
        function processAllLinks() {
            if (isProcessing) return;
            isProcessing = true;
            linkSettings.forEach(([wordsString, urlPattern, limit]) => {
                const wordsArray = wordsString.split(',').map(c => c.trim());
                const domain = getDomain(urlPattern);
                wordsArray.forEach(word => {
                    const instances = [];
                    const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
                    let node;
                    while(node = walker.nextNode()) {
                        const parent = node.parentElement;
                        if (!parent || parent.closest('.dynamic-link') || parent.closest('.random-link') || ['SCRIPT', 'STYLE', 'A', 'FOOTER', 'NAV', 'HEADER', 'BUTTON', 'INPUT', 'TEXTAREA', 'H1', 'H2', 'H3'].includes(parent.tagName)) continue;
                        const regex = new RegExp(`\\b(${word})\\b`, "gi");
                        if (regex.test(node.nodeValue)) { instances.push({ node, regex }); }
                    }
                    const shuffledInstances = shuffle(instances);
                    let count = 0;
                    shuffledInstances.forEach(item => {
                        if (count < limit && item.node.parentNode) {
                            const span = document.createElement('span');
                            span.innerHTML = item.node.nodeValue.replace(item.regex, (match) => {
                                if (count < limit) { count++; return `<a href="${urlPattern.includes('%s') ? urlPattern.replace('%s', encodeURIComponent(match)) : urlPattern}" target="_blank" class="dynamic-link" data-t="${match}" data-d="${domain}" data-type="indigo">${match}</a>`; }
                                return match;
                            });
                            if (span.innerHTML !== item.node.nodeValue) { item.node.parentNode.replaceChild(span, item.node); }
                        }
                    });
                });
            });
            const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
            let node; 
            let textNodes = [];
            while(node = walker.nextNode()) {
                const parent = node.parentElement;
                if (!parent || 
                    parent.closest('.dynamic-link') || 
                    parent.closest('.random-link') || 
                    parent.closest('#mw-footer, .mw-footer, footer, #footer, .catlinks, #catlinks') || 
                    parent.closest('h1, h2, h3, H1, H2, H3') ||
                    ['SCRIPT', 'STYLE', 'A', 'FOOTER', 'NAV', 'HEADER', 'BUTTON', 'INPUT', 'TEXTAREA'].includes(parent.tagName)) {
                    continue;
                }
                if (node.nodeValue.trim().length > 0) {
                    textNodes.push(node);
                }
            }
            textNodes.sort(() => Math.random() - 0.5);
            randomSettings.forEach(([urlPattern, limit]) => {
                let appliedCount = 0; const domain = getDomain(urlPattern);
                for (let i = 0; i < textNodes.length && appliedCount < limit; i++) {
                    let targetNode = textNodes[i]; if (!targetNode.parentNode) continue;
                    const words = targetNode.nodeValue.match(/[a-zA-Z]{3,12}/g);
                    if (words && words.length > 0) {
                        const picked = words[Math.floor(Math.random() * words.length)];
                        const regex = new RegExp(`\\b(${picked})\\b`, "i");
                        const span = document.createElement('span');
                        span.innerHTML = targetNode.nodeValue.replace(regex, `<a href="${urlPattern.includes('%s') ? urlPattern.replace('%s', encodeURIComponent(picked)) : urlPattern}" target="_blank" class="random-link" data-t="${picked}" data-d="${domain}" data-type="emerald">${picked}</a>`);
                        if (span.innerHTML !== targetNode.nodeValue) { targetNode.parentNode.replaceChild(span, targetNode); appliedCount++; textNodes.splice(i, 1); i--; }
                    }
                }
            });
            setTimeout(() => { isProcessing = false; }, 50);
        }
        const showTooltip = (link) => {
            const { t, d, type } = link.dataset;
            if (type === 'emerald') {
                tooltip.innerHTML = `<span class="t-label" style="color: #059669;">Discovery Mode</span><span class="t-title">${t}</span><span class="t-source" style="color: #059669;">Resource: ${d}</span><div class="t-desc">Explore more about "<b>${t}</b>".</div>`;
            } else {
                tooltip.innerHTML = `<span class="t-label">Quick Insight</span><span class="t-title">${t}</span><span class="t-source">Resource: ${d}</span><div class="t-desc">Discover more about "<b>${t}</b>".</div>`;
            }
            tooltip.style.display = 'block';
            if (window.innerWidth > 768) { setTimeout(() => { tooltip.style.opacity = '1'; tooltip.style.transform = 'translateY(0) scale(1)'; }, 10); } else { tooltip.classList.add('active'); tooltip.style.opacity = '1'; }
        };
        const hideTooltip = () => {
            if (!tooltip) return; tooltip.style.opacity = '0';
            if (window.innerWidth > 768) { tooltip.style.transform = 'translateY(15px) scale(0.95)'; } else { tooltip.classList.remove('active'); }
            setTimeout(() => { if(tooltip && tooltip.style.opacity === '0') tooltip.style.display = 'none'; }, 200);
        };
        document.addEventListener('mouseover', (e) => { const link = e.target.closest('.dynamic-link, .random-link'); if (link) showTooltip(link); });
        document.addEventListener('mousemove', (e) => { if (window.innerWidth > 768 && tooltip && tooltip.style.display === 'block') { let x = e.clientX + 20; let y = e.clientY + 20; if (x + tooltip.offsetWidth > window.innerWidth) x = e.clientX - tooltip.offsetWidth - 20; if (y + tooltip.offsetHeight > window.innerHeight) y = e.clientY - tooltip.offsetHeight - 20; tooltip.style.left = x + 'px'; tooltip.style.top = y + 'px'; } });
        document.addEventListener('mouseout', (e) => { if (e.target.closest('.dynamic-link, .random-link')) hideTooltip(); });
        function init() {
            createTooltip(); processAllLinks();
            const observer = new MutationObserver((mutations) => {
                let shouldProcess = false;
                for (let mutation of mutations) {
                    if (mutation.target.closest && (mutation.target.closest('.premium-tooltip') || mutation.target.closest('.dynamic-link') || mutation.target.closest('.random-link'))) continue;
                    shouldProcess = true; break;
                }
                if (shouldProcess && !isProcessing) { clearTimeout(window.dynamicLinkTimeout); window.dynamicLinkTimeout = setTimeout(processAllLinks, 500); }
            });
            observer.observe(document.body, { childList: true, subtree: true });
        }
        if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); }
    })();
  </script>
</body>
</html>