:root {
  --header-height: 0px;
  --footer-height: 0px; 
  --font-system: -apple-system, BlinkMacSystemFont, "Roboto", Segoe UI, Helvetica, Arial, sans-serif;
  --transition-smooth: 0.2s ease;

  --bg-main: #f1f5f9;
  --bg-card: #f8fafc;
  --bg-modal: #f1f5f9;
  --text-primary: #111111;
  --text-muted: #666666;
  --color-accent: #3b82f6;
  --color-accent-hover: #222222;
  --border-ui: #e5e5e5;
  --focus-ring: #0000cc;
}

body.theme-cyber {
  --bg-main: #0d0d11;
  --bg-card: #14141a;
  --bg-modal: #181822;
  --text-primary: #eeeeee;
  --text-muted: #cccccc;
  --color-accent: #3b82f6;
  --color-accent-hover: #dddddd;
  --color-sponsor: #ff8800;
  --border-ui: #2f2f45;
  --focus-ring: #0000cc;
}

body.theme-gallery {
  --bg-main: #f1f5f9;
  --bg-card: #f8fafc;
  --bg-modal: #f1f5f9;
  --text-primary: #111111;
  --text-muted: #666666;
  --color-accent: #3b82f6;
  --color-accent-hover: #222222;
  --border-ui: #e5e5e5;
  --focus-ring: #0000cc;
}

/* ==========================================================================
   RESET & SYSTEM VARIABLE ARCHITECTURE
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   GLOBAL RULES & ACCESSIBILITY ELEMENTS
   ========================================================================== */
html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh; 
  font-family: var(--font-system);
  background-color: var(--bg-main);
  color: var(--text-primary);
  padding-top: var(--header-height);
  padding-bottom: var(--footer-height); 
  min-height: 100vh;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 20px;
  background: var(--color-accent);
  color: white;
  padding: 10px 20px;
  z-index: 2000;
  transition: top var(--transition-smooth);
}
.skip-link:focus-visible { top: 20px; outline: 3px solid var(--focus-ring); }

/* ==========================================================================
   LAYOUT STRUCTURE & HEADER COMPONENTS
   ========================================================================== */
.global-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-ui);
  z-index: 1000;
  padding: 10px 15px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.header-container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 15px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-group h1 { 
  font-size: 1.5rem; 
  font-weight: 800; 
  letter-spacing: 0.05em;
  color: var(--color-accent); }

.live-indicator {
  width: 10px;
  height: 10px;
  background-color: var(--color-accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--color-accent);
}

.main-nav { display: flex; gap: 5px; }
.nav-tab {
  background: none; border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer; border-radius: 4px;
  transition: all var(--transition-smooth);
  text-decoration: none;
}
.nav-tab:hover { color: var(--text-primary); }
.nav-tab.active { color: var(--text-primary); background-color: var(--border-ui); }

.header-actions { display: flex; align-items: center; gap: 10px; }

.theme-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
  padding: 5px;
  font-size: 1.2rem;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  }

.theme-icon-btn:hover { transform: scale(1.1); }

body.theme-cyber .icon-sun { display: block; }
body.theme-cyber .icon-moon { display: none; }

body.theme-gallery .icon-sun { display: none; }
body.theme-gallery .icon-moon { display: block; }

/* ==========================================================================
   BUTTONS & BASE FORMS
   ========================================================================== */
.btn {
  padding: 10px 20px;
  font-weight: 600; font-size: 0.9rem;
  border: none; border-radius: 4px;
  cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
  transition: background-color var(--transition-smooth);
}
.btn-primary { background-color: var(--color-accent); color: var(--text-primary); text-decoration: none; }
.btn-primary:hover { background-color: var(--color-accent-hover); }

.btn-secondary { background-color: var(--border-ui); color: var(--text-primary); text-decoration: none; }
.btn-secondary:hover { background-color: var(--text-muted); color: var(--bg-main); }

body.theme-cyber .btn-primary { color: #000000; }
body.theme-gallery .btn-primary { color: #ffffff; }

.w-full { width: 100%; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-auto { margin-top: auto; }

/* ==========================================================================
   APP VIEWS & GRID ENGINE (MOBILE FIRST)
   ========================================================================== */
main { 
  flex: 1 0 auto; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px; padding-bottom: 60px; outline: none; padding-top: 20px; }
.app-view { display: none; }
.app-view.active-view { display: block; }

.section-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.section-subtitle { color: var(--text-muted); margin-bottom: 30px; }
.counter { font-size: 1rem; color: var(--text-muted); font-weight: 400; }

.stack-grid-matrix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 5px;
}

.stack-grid-matrix .nft-card .card-info {
  display: none;
}
.stack-grid-matrix .nft-card {
  border-radius: 4px;
  border: 1px solid var(--border-ui);
}

.stack-grid-matrix, .nft-grid {
  margin-top: 20px;
  margin-bottom: 40px; 
}

.nft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.nft-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-ui);
  border-radius: 6px; overflow: hidden;
  cursor: pointer; transition: transform var(--transition-smooth);
}
.nft-card:hover { transform: translateY(-4px); }

.card-media { 
  position: relative; 
  width: 100%; 
  aspect-ratio: 1 / 1; 
  background-color: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-media img {
  padding: 10px;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.5s;
}
.card-media img.loaded {
    opacity: 1;
}

.card-info { padding: 15px; display: flex; flex-direction: column; gap: 5px; }
.card-title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-wallet { font-family: monospace; font-size: 0.85rem; color: var(--text-muted); }

@keyframes pulse {
  0% { background-color: var(--border-ui); }
  50% { background-color: var(--bg-main); }
  100% { background-color: var(--border-ui); }
}

.nft-card.loading-state .card-media {
  animation: pulse 1.5s infinite;
}

.nft-card.load-error .card-media::after {
  content: "⚠️ Image Unavailable";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   DESKTOP MEDIA QUERY OVERRIDES (768px and Above)
   ========================================================================== */
@media (min-width: 768px) {
  main { 
  flex: 1 0 auto; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px; padding-bottom: 60px; outline: none; padding-top: 10px; }

  .global-header {
    padding: 0 40px;
    height: 60px; 
  }

  .header-container {
    max-width: 1600px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
  }

  .stack-grid-matrix {
    max-width: 1600px;
    margin: 0 auto;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    padding: 20px 20px 20px;
    margin-bottom: var(--footer-height);
  }

  .stack-grid-matrix .nft-card .card-info {
    display: flex;
    padding: 15px;
    background-color: var(--bg-card);
  }

  .modal-detail-body { flex-direction: row; max-height: unset; overflow-y: hidden; }
  .detail-info-container { border-top: none; border-left: 1px solid var(--border-ui); }
}

/* ==========================================================================
   TEXT VIEWS & INTERMEDIARY PAGES
   ========================================================================== */
.text-content-card {
  max-width: 850px;
  line-height: 1.7;
  margin: 0 auto;
  background-color: var(--bg-card);
  padding: 40px 30px 40px;
  border-radius: 8px;
  border: 1px solid var(--border-ui);
}

.text-content-card h1 {font-size: 2rem; font-weight: 800; margin-bottom: 10px;}
.text-content-card h2 { margin-bottom: 20px; font-weight: 700; }
.text-content-card h3 { margin: 30px 0 15px 0; font-weight: 600; }
.text-content-card p { margin-bottom: 15px; color: var(--text-muted); }
.text-content-card ul { margin-left: 20px; margin-bottom: 25px; color: var(--text-muted); }
.text-content-card li { margin-bottom: 8px; }

a { text-decoration: none; }
a:visited { color: var(--color-accent); }

.faq-item { margin-bottom: 15px; border-bottom: 1px solid var(--border-ui); padding-bottom: 15px; }
.faq-item summary { font-weight: 600; cursor: pointer; padding: 10px 0; outline: none; }
.faq-item summary:focus { color: var(--color-accent); }
.faq-answer { padding-top: 10px; }

/* ==========================================================================
   MODAL PLATFORMS & PORTALS
   ========================================================================== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.85);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 1; transition: opacity var(--transition-smooth);
}
.modal-overlay.hidden-modal { display: none; opacity: 0; pointer-events: none; }

.hidden-modal { display: none !important; }

.modal-wrapper {
  background-color: var(--bg-modal);
  border: 1px solid var(--border-ui);
  border-radius: 8px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; overflow: hidden;
}
.max-w-4xl { max-width: 900px !important; }

.modal-header { padding: 20px; border-bottom: 1px solid var(--border-ui); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 1.2rem; font-weight: 800; color: var(--color-accent) }
.close-icon { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.close-icon:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }
.status-msg { padding: 12px; background-color: var(--border-ui); border-radius: 4px; font-size: 0.85rem; font-weight: 600; text-align: center; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.form-group label { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.form-group input { padding: 12px; border: 1px solid var(--border-ui); border-radius: 4px; background-color: var(--bg-main); color: var(--text-primary); font-size: 1rem; }
.form-group input:focus { outline: 2px solid var(--focus-ring); }

.modal-detail-body { display: flex; padding: 20px; height: 100%; max-height: 85vh; overflow-y: auto; }
.detail-media-container { flex: 1; background-color: var(--bg-card); max-width: 350px; max-height: 350px; display: flex; justify-content: center; object-fit: contain; aspect-ratio: 1/1; }

.detail-media-container img { padding: 10px; max-width: 100%; max-height: 100%; object-fit: contain; display: block; transition: opacity 0.5s; }
.detail-info-container { flex: 1; padding: 30px; display: flex; flex-direction: column; gap: 15px; border-top: 1px solid var(--border-ui); }
.meta-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.wallet-txt { font-family: monospace; font-size: 1rem; color: var(--color-accent); }
.desc-txt { font-size: 0.95rem; color: var(--text-muted); overflow-y: auto; max-height: 150px; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.loading-trigger { text-align: center; padding: 40px; color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 767.98px) {
  .modal-detail-body { display: flex; flex-direction: column; padding: 20px; height: 100%; max-height: 85vh; overflow-y: auto; }
}

.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.global-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000; 
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-ui);
  height: 50px; 
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 0.75rem;
}

.footer-container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  text-align: center;
  justify-content: space-between;
}

.footer-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-right a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-right a:hover {
  color: var(--color-accent);
}
@media (min-width: 900px) {
  .global-footer .footer-inner { flex-direction: row; gap: 24px; }
  .global-footer .footer-inner p { margin: 0; }
}

/* Mobile hamburger (minimal, mobile-first) */
.hamburger { display: none; background: none; border: none; padding: 8px; cursor: pointer; color: var(--text-primary); }
.hamburger .hamburger-box { width: 24px; height: 18px; position: relative; display: inline-block; }
.hamburger .hamburger-inner,
.hamburger .hamburger-inner::before,
.hamburger .hamburger-inner::after {
  position: absolute; left: 0; right: 0; height: 2px; background: currentColor; border-radius: 2px;
}
.hamburger .hamburger-inner { top: 50%; transform: translateY(-50%); }
.hamburger .hamburger-inner::before { content: ""; top: -7px; }
.hamburger .hamburger-inner::after  { content: ""; top: 7px; }

/* Mobile behaviour */
@media (max-width: 767.98px) {
  .main-nav { display: none; }
  .header-actions { display: flex; }
  #theme-toggle, #btn-open-submit { display: none; }
  .hamburger { display: inline-flex; }

  .mobile-nav-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 90%;
    max-width: 360px;
    background: var(--bg-card);
    box-shadow: -12px 0 30px rgba(0,0,0,0.22);
    transform: translateX(110%); 
    transition: transform 300ms ease;
    z-index: 1800;
    display: flex;
    flex-direction: column;
    outline: none;
  }

  .mobile-nav-panel.open { transform: translateX(0); }

  html.mobile-nav-open, body.mobile-nav-open { overflow: hidden; touch-action: none; }
}

@media (min-width: 768px) {
  .hamburger { display: none; }
  .mobile-nav-panel { display: none; }
}

/* ==========================================================================
   MOBILE BEHAVIOUR - FORCED VISIBILITY TEST
   ========================================================================== */
@media (max-width: 767.98px) {
  .header-container {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .header-container h1 {
    font-size: 1.5rem;
  }

  .header-actions {
    display: flex !important;
    align-items: center;
    gap: 5px;
  }

  .theme-icon-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #btn-open-submit {
    display: inline-flex !important;
    padding: 6px 6px !important;
    font-size: 0.8rem !important;
  }

  .mobile-nav-panel {
    display: block !important; 
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    height: 100% !important;
    width: 200px !important;
    text-align: center;
    background: var(--bg-card) !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s ease !important;
    z-index: 2001 !important;
  }

  .mobile-nav-panel.open {
    transform: translateX(0) !important;
  }

  .mobile-nav-inner {
    display: flex;
    flex-direction: column;
    padding: 10px;
  }

  .mobile-nav-link {
    display: block;
    padding: 15px 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--border-ui);
  }

  .mobile-nav-link:hover {
    color: var(--color-accent);
  }

  .mobile-nav-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    align-self: flex-end;
    cursor: pointer;
    margin-bottom: 20px;
  }
}

.placeholder-card {
    border: 2px dashed var(--border-ui) !important;
    opacity: 0.7;
}
.placeholder-card:hover {
    opacity: 1;
    border-color: var(--color-accent) !important;
}

/* Mobile footer */
@media (max-width: 767.98px) {
  .global-footer {
    height: auto !important; /* Allow it to grow on mobile */
    min-height: 50px;
  }
  .global-footer .footer-container {
    flex-direction: column;
    gap: 5px;
    text-align: center;
    padding: 5px 0;
  }
  .footer-right {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }
}

@media (min-width: 768px) {
  .global-footer {
    padding: 0 40px;
    min-height: 40px; 
  }
  .global-footer .footer-container {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
  .footer-right {
    flex-direction: row;
    gap: 10px;
  }
}

#detail-editions {
  font-weight: bold;
  color: var(--color-accent);
  background: var(--border-ui);
  padding: 5px 10px;
  border-radius: 4px;
  display: inline-block;
}

.copy-btn-component {
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit; 
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  margin-left: 4px;
  border: 1px dashed #666666;
  border-radius: 4px;
  cursor: pointer; 
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.copy-btn-component:hover {
  opacity: 0.8;
  border-color: #cccccc;
}

.emoji-small {
  font-size: 0.75rem; 
  line-height: 1;
}