/* ── GALLERY MODAL (My Sequences / My Layouts / Store) ─────────────── */
.gallery-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 6, 0.85);
  backdrop-filter: blur(4px);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.gallery-overlay.visible { display: flex; }

.gallery-modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  width: 880px;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-float);
  border-radius: var(--r-lg);
}

.gallery-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gallery-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 5px;
  color: var(--accent2);
  text-shadow: 0 0 12px rgba(0, 255, 127, 0.3);
  flex-shrink: 0;
}
.gallery-search {
  flex: 1;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  outline: none;
  letter-spacing: 1px;
  margin-left: 16px;
  max-width: 280px;
  border-radius: var(--r-sm);
}
.gallery-search:focus { border-color: var(--accent2); }
.gallery-close {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  color: var(--label);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 4px 9px;
  margin-left: auto;
  transition: all var(--trans);
  border-radius: var(--r-sm);
}
.gallery-close:hover { color: var(--danger); border-color: var(--danger); }

/* ── GRID OF CARDS ───────────────────────────────────────────────────── */
.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
  min-height: 0;
}
.gallery-grid::-webkit-scrollbar { width: 6px; }
.gallery-grid::-webkit-scrollbar-track { background: transparent; }
.gallery-grid::-webkit-scrollbar-thumb { background: var(--border2); border-radius: var(--r-pill); }

.gallery-empty {
  flex: 1;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--border2);
  padding: 40px;
}

/* When sectioned, the grid container becomes a single column of vertically
   stacked sections; each section has its own internal grid row. */
.gallery-grid:has(.gallery-section-header) {
  display: block;
}
.gallery-section-header {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--label);
  margin: 4px 0 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.gallery-section-header:not(:first-child) { margin-top: 22px; }
.gallery-section-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* ── CARD ────────────────────────────────────────────────────────────── */
.gallery-card {
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  text-align: left;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  padding: 0;
  transition: border-color var(--trans), transform var(--trans);
  border-radius: var(--r-sm);
}
.gallery-card:hover {
  border-color: var(--accent2);
  transform: translateY(-1px);
}

.gallery-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-card-thumb.no-thumb {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: 4px;
  color: var(--border2);
}

.gallery-card-body {
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gallery-card-name {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-card-sub {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--label);
}

.gallery-card-del {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--danger);
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border: 1px solid rgba(255, 77, 0, 0.4);
  cursor: pointer;
  display: none;
  user-select: none;
  border-radius: var(--r-xs);
}
.gallery-card:hover .gallery-card-del { display: block; }
.gallery-card-del:hover { background: rgba(255, 77, 0, 0.2); }

/* ── FOOTER ──────────────────────────────────────────────────────────── */
.gallery-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  flex-shrink: 0;
}
.gallery-extras {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.gallery-extra-btn {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--label);
  cursor: pointer;
  transition: all var(--trans);
  border-radius: var(--r-sm);
}
.gallery-extra-btn:hover { border-color: var(--accent2); color: var(--accent2); }
