:root {
  --bg: #f0f0f0;
  --fg: #181818;
  --accent: #888;
  --border: #e0e0e0;
  --input-bg: #fff;
  --input-border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.04);
  --radius: 16px;
  --font-main: 'Inter', Arial, sans-serif;
  --logo-image: url('sifrzerotext-b.png');
  --gallery-bg-light: #eee;
  --gallery-bg-dark: #ddd;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #181818;
  --fg: #f0f0f0;
  --accent: #ccc;
  --border: #333;
  --input-bg: #000;
  --input-border: #333;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --logo-image: url('sifrzerotext-w.png');
  --gallery-bg-light: #111;
  --gallery-bg-dark: #333;
}

/* General Styles */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-main);
  transition: background 0.2s, color 0.2s;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: flex-start; /* Changed from center */
  justify-content: center;
  padding: 20px 0;
  box-sizing: border-box;
}

/* Wrapper for centering panels */
.page-wrapper {
  display: flex;
  gap: 0.5rem;
  max-width: 815px;
  margin: 0 auto;
  padding: 20px 0;
  box-sizing: border-box;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
}

.container {
  background: var(--input-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 0.35rem 1.5rem;
  width: 400px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  height: 980px;
}

/* Input Styles */
.mint-container input[type="text"],
.mint-container input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}

.optional-inputs {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

/* Heading Logo */
h1 {
  background-image: var(--logo-image);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: left center;
  height: 23px;
  width: 300px;
  text-indent: -9999px;
  overflow: hidden;
  margin: 0;
}

.logo {
  width: 100%;
  max-width: 351px;
  height: 351px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin-bottom: 0.9rem;
}

/* Wallet Row */
.wallet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 0.75rem;
}

.wallet-address-row {
  display: flex;
  align-items: stretch;
  width: 100%;
  gap: 0.5rem;
  min-width: 0;
}

.wallet-connect-button.connected {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  min-width: 0;
  padding-right: 0;
  margin-bottom: 0;
  height: auto;
}

.wallet-address-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-disconnect {
  flex: 0 0 auto;
  align-self: stretch;
  margin: 0;
}

/* Network Indicator */
.network-indicator {
  font-size: 1.7em;
  background: none;
  border: none;
  cursor: help;
  color: var(--gallery-bg-light);
  padding: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  outline: none;
  flex-shrink: 0;
  margin-left: auto;
  line-height: 1;
  height: 1.9em;
}

.network-indicator.mainnet { color: #0066cc; }
.network-indicator.ghostnet { color: #ffaa00; }
.network-indicator.warning { color: #ff4444; }
.network-indicator:hover { opacity: 0.7; }

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg);
  font-size: 1.9em;
  margin-left: 0;
  padding: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  outline: none;
  line-height: 1;
  height: 1.9em;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--accent);
}

/* Form Styles */
form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

form > div,
#optional > div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0;
  display: block;
  white-space: nowrap;
}

input, textarea {
  flex: 1;
  padding: 0.3em;
  border-radius: 3px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--fg);
  font-size: 0.85rem;
  box-sizing: border-box;
  outline: none;
  transition: border 0.2s;
}

input:focus, textarea:focus {
  border-color: var(--accent);
}

#optional > div { margin-top: 0.15rem; }

#optional {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.2rem;
  font-size: 0.95rem;
  text-align: right;
  width: 100%;
  display: block;
}

#optional h3 {
  margin: 0 auto 0.55rem auto;
  font-size: 0.9rem;
  font-weight: normal;
  text-align: center;
  align-items: center;
  color: var(--fg);
}

/* Hazard Group */
.hazard-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  margin-right: 1.5em;
}

/* Submit Button */
button[type="submit"] {
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.75em;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button[type="submit"]:hover,
button[type="submit"]:focus {
  background: var(--accent);
}

/* Wallet Connect */
.wallet-connect {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.wallet-connect-button {
  flex: 1;
  padding: 0.3em;
  border-radius: 3px;
  border: 1px solid var(--input-border);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.85rem;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  text-align: center;
  transition: all 0.2s;
  margin-bottom: 0;
  font-weight: 500;
  height: auto;
  line-height: 1.2;
}

.wallet-connect-button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.wallet-connect-button.connected {
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--input-border);
  font-family: monospace;
  font-size: 0.85rem;
  text-align: left;
  padding: 0.3em 0.5em;
  height: auto;
  line-height: 1.2;
}

/* File Upload */
.file-upload-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.file-upload-button {
  flex: 1;
  padding: 0.3em 0.5em;
  border-radius: 3px;
  border: 1px solid var(--input-border);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.85rem;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  text-align: left;
  transition: border 0.2s;
  margin-bottom: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

/* Disconnect Button */
.disconnect-button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.disconnect-button:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Invalid Field */
.invalid-field {
  border: 1px solid #ff4444 !important;
}



/* Mint Button Styles */
button[type="submit"].mint-btn {
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.8em 2em;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}

button[type="submit"].mint-btn:hover:not(:disabled) {
  background: #225087;
}

button[type="submit"].mint-btn:disabled {
  background: #b5b5b5;
  color: #f0f0f0;
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

button[type="submit"].mint-btn:disabled:hover {
  background: #b5b5b5;
  color: #f0f0f0;
}

/* Links */
.links {
  width: 100%;
  font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
  font-style: italic;
  font-size: 0.8rem;
  margin-top: 0;
  padding-bottom: .35rem;
  text-align: right;
  color: var(--fg);
  display: block;
  align-self: stretch;
}

.links a {
  font-weight: bold;
  font-size: 1rem;
  color: var(--fg);
  text-decoration: none;
}

.links a:hover {
  color: var(--accent);
}

/* Modal Styles */
#confirmation-modal,
#progress-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  background-color: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-content h3 { margin-top: 0; }

.modal-buttons {
  margin-top: 20px;
  display: flex;
  justify-content: space-around;
}

.modal-buttons button {
  padding: 10px 20px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
}

#modal-confirm {
  background-color: var(--fg);
  color: var(--bg);
}

#modal-cancel {
  background-color: #ccc;
  color: #333;
}

/* Progress Modal Specific Styles */
#progress-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
}

.progress-footer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--accent);
}

.progress-footer a {
  color: var(--accent);
  text-decoration: underline;
}

#progress-message a {
  font-weight: bold;
  font-size: 1rem;
  color: var(--fg);
  text-decoration: none;
}

#progress-message a:hover {
  text-decoration: underline;
}

#progress-bar {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.calm-message {
  font-size: 1rem;
  color: var(--fg);
  font-style: italic;
}

#progress-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.7rem;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  line-height: 1;
  width: 1.5em;
  height: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

#progress-modal-close:hover {
  color: #e00;
}

/* Side Panel Styles */
.side-panel {
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  height: 980px;
}

/* Panel Menu */
.panel-menu {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--fg);
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease;
  font-size: 1rem;
  font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
}

.menu-btn:hover,
.menu-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Panel Content */
.panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  color: var(--fg);
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: justify;
  scrollbar-width: none;
}

.panel-contet::-webkit-scrollbar { display: none; }

.panel-content a {
  text-decoration: none;
  color: inherit;
  font-style: italic;
  font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
  font-weight: bold;
}

.panel-content a:hover {
  color: var(--accent);
  text-decoration: underline;
  font-weight: bold;
}

/* Gallery Styles */
#gallery-content {
  position: relative;
  transition: all 0.3s ease;
}

.gallery-scroll-container {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 50px; /* space for the fixed button */
  scrollbar-width: none;
}

.gallery-scroll-container::-webkit-scrollbar { display: none; }

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.gallery-item {
  aspect-ratio: 1/1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; 
}

.gallery-item {
    position: relative;
    min-height: 100px; /* Give placeholder a minimum height */
    background-color: var(--input-bg); /* Match background */
}

.gallery-load-more {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.7rem;
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  z-index: 10;
}

.gallery-load-more:hover {
  color: var(--fg);
}

.gallery-load-more.loading {
  cursor: default;
  color: var(--fg);
}

.gallery-image-wrapper {
  position: relative; /* Container for image and overlay */
  width: 100%;
  height: 100%;
  overflow: hidden; /* Just in case */
}

/* Fullscreen (pop-out) gallery */
#gallery-content.gallery-fullscreen {
  position: fixed;
  top: 40px; 
  left: 0;
  width: 100vw;
  height: calc(100vh - 40px);
  background: var(--bg);
  z-index: 500; /* High enough above anything else */
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
}

.gallery-fullscreen-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 40px;
  background: var(--input-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  z-index: 3100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25em 0 1em;
  font-size: 1.1em;
  font-family: var(--font-main);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
#gallery-content.gallery-fullscreen .gallery-fullscreen-bar {
  display: flex;
}
#gallery-content:not(.gallery-fullscreen) .gallery-fullscreen-bar {
  display: none;
}
.gallery-fullscreen-title {
  font-weight: bold;
  letter-spacing: 0.02em;
  padding-left:0.5em;
}
.gallery-fullscreen-bar .gallery-popout-btn {
  font-size: 1.45em;
  color: var(--fg);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s, color 0.2s;
  margin-right:0.7em;
}
.gallery-fullscreen-bar .gallery-popout-btn:hover {
  color: var(--accent);
  background: rgba(43, 108, 176, 0.08);
}

/* limit gallery images when in fullscreen mode */
#gallery-content.gallery-fullscreen .gallery-item .gallery-image-wrapper {
  width: 180px;
  height: 180px;
  max-width: 180px;
  max-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
}

#gallery-content.gallery-fullscreen .gallery-item .gallery-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* max-width/max-height not needed here; width/height 100% is key */
}

#gallery-content.gallery-fullscreen .gallery-grid {
  display: grid; /* keep grid! */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  justify-items: center;
  align-items: center;
  align-items: center;
}

#gallery-content.gallery-fullscreen .gallery-scroll-container {
  /*height: 100vh;*/
  overflow-y: auto;
  padding-bottom: 60px; /* for pop-out control or load-more */
}

#gallery-content,
#gallery-content.gallery-fullscreen {
  transition: width 0.25s, height 0.25s, left 0.25s, top 0.25s, box-shadow 0.25s;
}

.gallery-popout-btn {
  background: none;
  border: none;
  font-size: 1.35em;
  padding: 0.18em 0.45em 0.18em 0;
  color: var(--fg);
  cursor: pointer;
  vertical-align: middle;
  transition: color 0.2s, background 0.2s;
  margin-right: 0.15em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}

.gallery-popout-btn:hover,
.gallery-popout-btn:focus {
  color: var(--accent);
  outline: none;
}

.img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    var(--gallery-bg-dark),
    var(--gallery-bg-dark) 50%,
    var(--gallery-bg-light) 50%,
    var(--gallery-bg-light)
  );
  background-size: 100% 20px;
  background-opacity: 0.2;
  display: flex;
  align-items: center;
  justify-content: center;
  /*position: relative;*/
}

.img-placeholder .spinner {
  width: 32px;
  height: 32px;
  border: 4px solid #bbb;
  border-top: 4px solid #888;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.gallery-item .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--accent); /* Use your theme's accent color */
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -15px;
    margin-left: -15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.img-placeholder.broken {
  color: darkred;
  font-size: 6rem;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', Arial, sans-serif;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;  
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.3s;
  display: block;
  background: linear-gradient(
    var(--gallery-bg-dark),
    var(--gallery-bg-dark) 50%,
    var(--gallery-bg-light) 50%,
    var(--gallery-bg-light)
  );  
  background-size: 100% 20px;
  background-opacity: 0.2;  
}

.gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Faded dark background */
  color: white;
  display: flex;
  flex-direction: column; /* Stack links vertically */
  justify-content: center;
  align-items: center;
  opacity: 0; /* Hidden by default */
  transition: opacity 0.3s ease; /* Smooth fade effect */
  text-align: center;
  padding: 4px;
  box-sizing: border-box;
  backdrop-filter: blur(2px); /* Optional: blur the image underneath */
}


.overlay-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
  width: 100%;
  align-items: center;
  padding: 0;
  gap: 0;
  position: relative;
}

.overlay-row.overlay-row-top {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 2.2em;
  padding: 0.3em 0.5em 0 0.5em;
  box-sizing: border-box;
}

.overlay-price-wrap {
  display: flex;
  align-items: center;
  position: relative;
  gap: 0.5em;
}

.overlay-price {
  font-size: 1.1em;
  color: #fff;
  background: #2b6cb0;
  padding: 0.22em 0.8em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  /*display: inline-block;*/
  display:none;
}

.overlay-price:hover {
  background: #225087;
  color: #ffe082;
}


.overlay-enlarge-arrow {
  font-size: 2em;
  color: #fff;
  cursor: pointer;
  user-select: none;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding-left: 0.8em;
  line-height: 0.8em;
  position:absolute;
  top:4px;
  right: 4px;
}

.overlay-enlarge-arrow:hover { opacity: 1; }

.overlay-owner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.2em 0 0.2em 0;
  /* Adjust margin as needed for spacing */
}

.overlay-list-btn {
  font-size: 0.8em;
  color: #ffe082;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  font-weight: bold;
  border-radius: 3px;
  padding: 0.2em;
  transition: color 0.2s, background 0.2s;
  display: inline-block;
  /*display:none;*/
}

.overlay-list-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.10);
  text-decoration: none;
}

.overlay-title {
  font-size: 1.0em;
  font-weight: bold;
  color: #fff;
  text-align: center;
  width: 100%;
  margin-top: auto;      /* Pushes this and following elements to the bottom */
  margin-bottom: 0.2em;  /* Small space below title */
}

.overlay-artist {
  font-size: 0.8em;
  color: #ccc;
  text-align: center;
  width: 100%;
  margin-top: 0;
  margin-bottom: 0.4em;  /* Space from bottom of overlay */
}

.gallery-image-wrapper:hover .gallery-overlay {
  opacity: 1; /* Show on hover */
}

.gallery-overlay .overlay-link {
  color: white; /* Link color */
  text-decoration: none;
  font-weight: bold;
  font-size: 0.8rem;
  padding: 1px 8px;
  border: 1px solid rgba(255, 255, 255, 0.5); /* Subtle border for links */
  border-radius: 5px;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap; /* Prevent line breaks within links */
  overflow: hidden;
  text-overflow: ellipsis;
  display:none; /* unhide if we want to show them again */
}

.gallery-loaded-message {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: none;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  z-index: 10;	
  font-size:0.8rem;
  font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
}

/* Mobile Responsive */
@media (max-width: 500px) {
  .container {
    padding: 1.1rem 0.5rem;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    justify-content: center;
  }
  h1 {
    font-size: 1.3rem;
  }
   .panel-content {
    max-width: 100vw;
    overflow-x: hidden;
    padding: 0 10px;
    box-sizing: border-box;
  }

/* HIDE TO KEEP IMAGES 2-WIDE ON MOBILE
  .gallery-grid {
    grid-template-columns: 1fr !important;
  } 
*/

  .gallery-item {
    max-width: 100%;
  }
  
  .error-message {
    word-wrap: break-word;
    max-width: 100%;
  }
}

.artwork-modal {
  position: fixed;
  z-index: 2000;
  left: 0; top: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.artwork-modal-content {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 0;
  max-width: 600px;
  width: 96vw;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  min-width: 340px;
  min-height: 340px;
  position: relative;
}

.artwork-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.4em 0.2em 0.8em 0.6em;
  gap: 2em;
}

.artwork-modal-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 50vw;
}

.artwork-modal-title {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--fg);
  margin-bottom: 0.2em;
  word-break: break-word;
}

.artwork-modal-artist {
  font-size: 0.9em;
  color: var(--accent);
  margin-bottom: 0.2em;
  word-break: break-word;
}

.artwork-modal-topright {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1em;
  min-width: 0;
}
.artwork-modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  padding: 0 0.2em;
  transition: color 0.2s;
  margin: 0;
}
.artwork-modal-close:hover {
  color: #a00;
}


.artwork-modal-price-wrap {
  display: flex;
  /*display:none;*/
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.1em;
}

.artwork-modal-price {
  font-size: 0.95em;
  margin-top:0.4em;
  color: #fff;
  background: #2b6cb0;
  padding: 0.22em 0.8em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  /*display: inline-block;*/
  display:none;
}
.artwork-modal-price:hover {
  background: #225087;
  color: #ffe082;
}

.artwork-modal-view-toggle {
  margin-top: 0.2em;
  margin-bottom: 0.2em;
  width: 100%;
  text-align: right;
}
.artwork-modal-view-link {
  font-size: 0.97em;
  color: #2b6cb0;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  font-weight: bold;
  border-radius: 3px;
  padding: 0.1em 0.7em;
  transition: color 0.2s, background 0.2s;
  display: inline-block;
}
.artwork-modal-view-link:hover {
  color: #225087;
  background: rgba(43,108,176,0.08);
  text-decoration: none;
}

.artwork-modal-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 200px;
  min-width: 200px;
  background: var(--input-bg);
  overflow: auto;
  padding: 0;
}

.artwork-modal-image {
  display: block;
  background: var(--input-bg);
  border: none;
  box-shadow: none;
  /* Responsive sizing: */
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  width: auto;
  height: auto;
}

.artwork-modal-image.fit {
  width: 100%;
  height: 100%;
  max-width: 90vw;
  max-height: 65vh;
  object-fit: contain;
}


.fit-toggle-btn {
  position: absolute;
  top: 10px;
  background: none;
  border: none;
  font-size: 1.3em;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: var(--fg);
}


/* Marketplace Modal Overlay */
#marketplace-modal {
  display: none; /* Hidden by default, shown via JS */
  position: fixed;
  z-index: 2000;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.82);
  display: flex; /* Use flexbox */
  align-items: center; /* Vertically center */
  justify-content: center; /* Horizontally center */
  transition: opacity 0.2s;
}

/* Modal Content Container */
.marketplace-modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  width: 80vw;
  min-height:30vh;
  /*max-height: 96vh;*/
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  padding:15px;
}


/* Modal Close Button */
#marketplace-modal-close {
  position: absolute;
  top: 0.3em; 
  right: 0.3em;
  background: none;
  border: none;
  color: #888;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
  transition: color 0.2s;
}
#marketplace-modal-close:hover {
  color: #a00;
}

/* Modal Body */
#marketplace-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.1em;
  align-items: center;
  justify-content: flex-start;
  min-height: 200px;
  overflow-y: clip;
}

/* Token Info Section */
.marketplace-token-info {
  display: flex;
  align-items: center;
  gap: 1em;
  width: 100%;
  min-height:65px;
}
.marketplace-token-thumb {
  width: 64px; height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--gallery-bg-dark);
  border: 1px solid var(--border);
}
.marketplace-token-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}
.marketplace-token-title {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--fg);
  text-align:left;
}
.marketplace-token-artist {
  font-size: 0.95em;
  color: var(--accent);
  text-align:left;
}

/* Listings Section */
.marketplace-listings {
  width: 100%;
  margin-bottom: 0.5em;
  font-size: 0.9em;
  color: var(--fg);
  text-align:left;
}

/* Listing Form */
.market-list-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.market-list-row-top label,
.market-list-row-top input {
  flex: 0 1 auto;
  min-width: 0;
}

.market-list-row-top input[type="number"] {
  width: 6em;
  min-width: 0;
}

.market-list-row label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  margin-bottom: 0;
}

.market-list-row input[type="text"],
.market-list-row input[type="number"],
.market-list-row input[type="datetime-local"] {
  flex: 1;
  padding: 0.3em;
  border-radius: 3px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--fg);
  font-size: 0.85rem;
  box-sizing: border-box;
  outline: none;
  transition: border 0.2s;
}

.market-list-row input:focus {
  border-color: var(--accent);
}

.market-list-row-bottom {
  gap: 0.75rem;
  align-items: center;
}

.market-list-row-bottom input[type="datetime-local"] {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 180px;
}

.market-list-row-bottom button[type="submit"] {
  margin-left: 1em;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.8em 2em;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}

.market-list-row-bottom button[type="submit"]:hover:not(:disabled) {
  background: #225087;
}

.market-list-row-bottom button[type="submit"]:disabled {
  background: #b5b5b5;
  color: #f0f0f0;
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.market-list-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align:left;
}

.market-list-form > div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

/*
.market-list-form label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0;
  white-space: nowrap;
}
*/

.market-list-form label {
    display: block;
    flex-direction: column;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 0;
    gap: 0.15em;
}

.market-list-form input[type="number"],
.market-list-form input[type="text"],
.market-list-form input[type="datetime-local"] {
  flex: 1 1 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0.3em;
  border-radius: 3px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--fg);
  font-size: 0.95em;
  min-width: 0; /* Prevent overflow in flex */
}

/*
.market-list-form .market-list-row-top input[type="number"] {
  max-width: 120px; 
}

.market-list-form .market-list-row-top label {
  min-width: 50px;
}
*/

.market-list-form button[type="submit"] {
  margin-left: 1em;
 
}

.market-list-form input[type="number"],
.market-list-form input[type="text"],
.market-list-form input[type="datetime-local"] {
    padding: 0.22em 0.5em;
    border-radius: 3px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--fg);
    font-size: 0.95em;
    min-width: 60px;
    box-sizing: border-box;
}

.market-list-form input[readonly] {
  background: #f7f7f7;
  color: #888;
  cursor: not-allowed;
}

.market-list-form input::placeholder {
    color: #bbb;
    font-size: 0.85em;
}

.market-list-form button[type="submit"] {
    background: #2b6cb0;
    color: #fff;
    border-radius: 6px;
    padding: 0.4em 1.2em;
    font-size: 0.85em;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
	width:100px;
}

.market-list-form button[type="submit"]:disabled {
    background: #ccc !important;
    color: #888 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.marketplace-listings ul {
    list-style: none;
    padding: 0;
    margin: 0.2em 0 0 0;
}

.marketplace-listings li {
    display: flex;
    align-items: center;
    gap: 0.6em;
    font-size: 0.97em;
    margin-bottom: 0.2em;
}

.marketplace-listings .listing-address {
    font-family: monospace;
    font-size: 1em;
    color: var(--accent);
}

.cancel-listing-btn {
    color: #e00;
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
}
.cancel-listing-btn:hover {
    color: #a00;
}

/* Message/Status Area */
#marketplace-message {
  margin-top: 0.7em;
  font-size: 0.98em;
  color: var(--accent);
  min-height: 1.2em;
  text-align: center;
  word-break: break-word;
}


/* Responsive: On mobile, stack vertically */
@media (max-width: 600px) {
  .page-wrapper {
    flex-direction: column;
    align-items: center;
  }
  .marketplace-modal-content {
    min-width: 0;
    width: 99vw;
    max-width: 99vw;
    padding: 0;
  }
  #marketplace-modal-body {
    padding: 1em 0.5em 1em 0.5em;
  }
  /*
  .marketplace-token-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
  } */
  .marketplace-token-thumb {
    width: 48px; height: 48px;
  }  
}
